2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • http://build.i3wm.org/docs/ipc.html
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 # (unless you are already familiar with Perl)
17 # Tests the standalone parser binary to see if it calls the right code when
18 # confronted with various commands, if it prints proper error messages for
19 # wrong commands and if it terminates in every case.
21 use i3test i3_autostart => 0;
28 run [ '../test.config_parser', $command ],
31 # TODO: use a timeout, so that we can error out if it doesn’t terminate
33 # Filter out all debugging output.
34 my @lines = split("\n", $stdout);
35 @lines = grep { not /^# / } @lines;
37 # The criteria management calls are irrelevant and not what we want to test
39 @lines = grep { !(/cfg_criteria_init/ || /cfg_criteria_pop_state/) } @lines;
40 return join("\n", @lines) . "\n";
45 bindsym Mod1 + Shift + x resize grow
46 bindcode Mod1+44 resize shrink
50 my $expected = <<'EOT';
52 cfg_mode_binding(bindsym, Mod1,Shift, x, (null), resize grow)
53 cfg_mode_binding(bindcode, Mod1, 44, (null), resize shrink)
56 is(parser_calls($config),
58 'single number (move workspace 3) ok');
60 ################################################################################
61 # exec and exec_always
62 ################################################################################
66 exec --no-startup-id /tmp/foo.sh
68 exec_always --no-startup-id /tmp/bar.sh
72 cfg_exec(exec, (null), geeqie)
73 cfg_exec(exec, --no-startup-id, /tmp/foo.sh)
74 cfg_exec(exec_always, (null), firefox)
75 cfg_exec(exec_always, --no-startup-id, /tmp/bar.sh)
78 is(parser_calls($config),
82 ################################################################################
84 ################################################################################
87 for_window [class="^Chrome"] floating enable
91 cfg_criteria_add(class, ^Chrome)
92 cfg_for_window(floating enable)
95 is(parser_calls($config),
99 ################################################################################
101 ################################################################################
104 assign [class="^Chrome"] 4
105 assign [class="^Chrome"] named workspace
106 assign [class="^Chrome"] "quoted named workspace"
107 assign [class="^Chrome"] → "quoted named workspace"
111 cfg_criteria_add(class, ^Chrome)
113 cfg_criteria_add(class, ^Chrome)
114 cfg_assign(named workspace)
115 cfg_criteria_add(class, ^Chrome)
116 cfg_assign(quoted named workspace)
117 cfg_criteria_add(class, ^Chrome)
118 cfg_assign(quoted named workspace)
121 is(parser_calls($config),
125 ################################################################################
126 # floating_minimum_size / floating_maximum_size
127 ################################################################################
130 floating_minimum_size 80x55
131 floating_minimum_size 80 x 55
132 floating_maximum_size 73 x 10
136 cfg_floating_minimum_size(80, 55)
137 cfg_floating_minimum_size(80, 55)
138 cfg_floating_maximum_size(73, 10)
141 is(parser_calls($config),
143 'floating_minimum_size ok');
145 ################################################################################
147 ################################################################################
150 floating_modifier Mod1
151 floating_modifier mOd1
155 cfg_floating_modifier(Mod1)
156 cfg_floating_modifier(Mod1)
159 is(parser_calls($config),
161 'floating_modifier ok');
163 ################################################################################
164 # default_orientation
165 ################################################################################
168 default_orientation horizontal
169 default_orientation vertical
170 default_orientation auto
174 cfg_default_orientation(horizontal)
175 cfg_default_orientation(vertical)
176 cfg_default_orientation(auto)
179 is(parser_calls($config),
181 'default_orientation ok');
183 ################################################################################
185 ################################################################################
188 workspace_layout default
189 workspace_layout stacked
190 workspace_layout stacking
191 workspace_layout tabbed
195 cfg_workspace_layout(default)
196 cfg_workspace_layout(stacked)
197 cfg_workspace_layout(stacking)
198 cfg_workspace_layout(tabbed)
201 is(parser_calls($config),
203 'workspace_layout ok');
205 ################################################################################
207 ################################################################################
219 cfg_new_window(new_window, 1pixel, -1)
220 cfg_new_window(new_window, normal, 2)
221 cfg_new_window(new_window, none, -1)
222 cfg_new_window(new_float, 1pixel, -1)
223 cfg_new_window(new_float, normal, 2)
224 cfg_new_window(new_float, none, -1)
227 is(parser_calls($config),
231 ################################################################################
233 ################################################################################
236 hide_edge_borders none
237 hide_edge_borders vertical
238 hide_edge_borders horizontal
239 hide_edge_borders both
243 cfg_hide_edge_borders(none)
244 cfg_hide_edge_borders(vertical)
245 cfg_hide_edge_borders(horizontal)
246 cfg_hide_edge_borders(both)
249 is(parser_calls($config),
251 'hide_edge_borders ok');
253 ################################################################################
254 # focus_follows_mouse
255 ################################################################################
258 focus_follows_mouse yes
259 focus_follows_mouse no
263 cfg_focus_follows_mouse(yes)
264 cfg_focus_follows_mouse(no)
267 is(parser_calls($config),
269 'focus_follows_mouse ok');
271 ################################################################################
272 # force_display_urgency_hint
273 ################################################################################
275 is(parser_calls('force_display_urgency_hint 300'),
276 "cfg_force_display_urgency_hint(300)\n",
277 'force_display_urgency_hint ok');
279 is(parser_calls('force_display_urgency_hint 500 ms'),
280 "cfg_force_display_urgency_hint(500)\n",
281 'force_display_urgency_hint ok');
283 is(parser_calls('force_display_urgency_hint 700ms'),
284 "cfg_force_display_urgency_hint(700)\n",
285 'force_display_urgency_hint ok');
288 force_display_urgency_hint 300
289 force_display_urgency_hint 500 ms
290 force_display_urgency_hint 700ms
291 force_display_urgency_hint 700
295 cfg_force_display_urgency_hint(300)
296 cfg_force_display_urgency_hint(500)
297 cfg_force_display_urgency_hint(700)
298 cfg_force_display_urgency_hint(700)
301 is(parser_calls($config),
303 'force_display_urgency_hint ok');
305 ################################################################################
307 ################################################################################
310 workspace 3 output VGA-1
311 workspace "4: output" output VGA-2
312 workspace bleh output LVDS1/I_1
316 cfg_workspace(3, VGA-1)
317 cfg_workspace(4: output, VGA-2)
318 cfg_workspace(bleh, LVDS1/I_1)
321 is(parser_calls($config),
325 ################################################################################
327 ################################################################################
330 ipc-socket /tmp/i3.sock
331 ipc_socket ~/.i3/i3.sock
335 cfg_ipc_socket(/tmp/i3.sock)
336 cfg_ipc_socket(~/.i3/i3.sock)
339 is(parser_calls($config),
343 ################################################################################
345 ################################################################################
348 client.focused #4c7899 #285577 #ffffff #2e9ef4
349 client.focused_inactive #333333 #5f676a #ffffff #484e50
350 client.unfocused #333333 #222222 #888888 #292d2e
351 client.urgent #2f343a #900000 #ffffff #900000
355 cfg_color(client.focused, #4c7899, #285577, #ffffff, #2e9ef4)
356 cfg_color(client.focused_inactive, #333333, #5f676a, #ffffff, #484e50)
357 cfg_color(client.unfocused, #333333, #222222, #888888, #292d2e)
358 cfg_color(client.urgent, #2f343a, #900000, #ffffff, #900000)
361 is(parser_calls($config),
365 ################################################################################
366 # Verify that errors don’t harm subsequent valid statements
367 ################################################################################
370 hide_edge_border both
371 client.focused #4c7899 #285577 #ffffff #2e9ef4
375 ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', 'bind', 'bar', 'font', 'mode', 'floating_minimum_size', 'floating_maximum_size', 'floating_modifier', 'default_orientation', 'workspace_layout', 'new_window', 'new_float', 'hide_edge_borders', 'for_window', 'assign', 'focus_follows_mouse', 'force_focus_wrapping', 'force_xinerama', 'force-xinerama', 'workspace_auto_back_and_forth', 'fake_outputs', 'fake-outputs', 'force_display_urgency_hint', 'workspace', 'ipc_socket', 'ipc-socket', 'restart_state', 'popup_during_fullscreen', 'exec_always', 'exec', 'client.background', 'client.focused_inactive', 'client.focused', 'client.unfocused', 'client.urgent'
376 ERROR: CONFIG: (in file <stdin>)
377 ERROR: CONFIG: Line 1: hide_edge_border both
378 ERROR: CONFIG: ^^^^^^^^^^^^^^^^^^^^^
379 ERROR: CONFIG: Line 2: client.focused #4c7899 #285577 #ffffff #2e9ef4
380 cfg_color(client.focused, #4c7899, #285577, #ffffff, #2e9ef4)
383 is(parser_calls($config),
385 'errors dont harm subsequent statements');
388 hide_edge_borders FOOBAR
389 client.focused #4c7899 #285577 #ffffff #2e9ef4
393 ERROR: CONFIG: Expected one of these tokens: 'none', 'vertical', 'horizontal', 'both', '1', 'yes', 'true', 'on', 'enable', 'active'
394 ERROR: CONFIG: (in file <stdin>)
395 ERROR: CONFIG: Line 1: hide_edge_borders FOOBAR
396 ERROR: CONFIG: ^^^^^^
397 ERROR: CONFIG: Line 2: client.focused #4c7899 #285577 #ffffff #2e9ef4
398 cfg_color(client.focused, #4c7899, #285577, #ffffff, #2e9ef4)
401 is(parser_calls($config),
403 'errors dont harm subsequent statements');
406 ################################################################################
407 # Error message with 2+2 lines of context
408 ################################################################################
411 # i3 config file (v4)
418 # this should not show up
423 ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', 'bind', 'bar', 'font', 'mode', 'floating_minimum_size', 'floating_maximum_size', 'floating_modifier', 'default_orientation', 'workspace_layout', 'new_window', 'new_float', 'hide_edge_borders', 'for_window', 'assign', 'focus_follows_mouse', 'force_focus_wrapping', 'force_xinerama', 'force-xinerama', 'workspace_auto_back_and_forth', 'fake_outputs', 'fake-outputs', 'force_display_urgency_hint', 'workspace', 'ipc_socket', 'ipc-socket', 'restart_state', 'popup_during_fullscreen', 'exec_always', 'exec', 'client.background', 'client.focused_inactive', 'client.focused', 'client.unfocused', 'client.urgent'
424 ERROR: CONFIG: (in file <stdin>)
425 ERROR: CONFIG: Line 3: font foobar
426 ERROR: CONFIG: Line 4:
427 ERROR: CONFIG: Line 5: unknown qux
428 ERROR: CONFIG: ^^^^^^^^^^^
429 ERROR: CONFIG: Line 6:
430 ERROR: CONFIG: Line 7: # yay
433 is(parser_calls($config),
435 'error message (2+2 context) ok');
437 ################################################################################
438 # Error message with 0+0 lines of context
439 ################################################################################
446 ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', 'bind', 'bar', 'font', 'mode', 'floating_minimum_size', 'floating_maximum_size', 'floating_modifier', 'default_orientation', 'workspace_layout', 'new_window', 'new_float', 'hide_edge_borders', 'for_window', 'assign', 'focus_follows_mouse', 'force_focus_wrapping', 'force_xinerama', 'force-xinerama', 'workspace_auto_back_and_forth', 'fake_outputs', 'fake-outputs', 'force_display_urgency_hint', 'workspace', 'ipc_socket', 'ipc-socket', 'restart_state', 'popup_during_fullscreen', 'exec_always', 'exec', 'client.background', 'client.focused_inactive', 'client.focused', 'client.unfocused', 'client.urgent'
447 ERROR: CONFIG: (in file <stdin>)
448 ERROR: CONFIG: Line 1: unknown qux
449 ERROR: CONFIG: ^^^^^^^^^^^
452 is(parser_calls($config),
454 'error message (0+0 context) ok');
456 ################################################################################
457 # Error message with 1+0 lines of context
458 ################################################################################
466 ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', 'bind', 'bar', 'font', 'mode', 'floating_minimum_size', 'floating_maximum_size', 'floating_modifier', 'default_orientation', 'workspace_layout', 'new_window', 'new_float', 'hide_edge_borders', 'for_window', 'assign', 'focus_follows_mouse', 'force_focus_wrapping', 'force_xinerama', 'force-xinerama', 'workspace_auto_back_and_forth', 'fake_outputs', 'fake-outputs', 'force_display_urgency_hint', 'workspace', 'ipc_socket', 'ipc-socket', 'restart_state', 'popup_during_fullscreen', 'exec_always', 'exec', 'client.background', 'client.focused_inactive', 'client.focused', 'client.unfocused', 'client.urgent'
467 ERROR: CONFIG: (in file <stdin>)
468 ERROR: CONFIG: Line 1: # context before
469 ERROR: CONFIG: Line 2: unknown qux
470 ERROR: CONFIG: ^^^^^^^^^^^
473 is(parser_calls($config),
475 'error message (1+0 context) ok');
477 ################################################################################
478 # Error message with 0+1 lines of context
479 ################################################################################
487 ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', 'bind', 'bar', 'font', 'mode', 'floating_minimum_size', 'floating_maximum_size', 'floating_modifier', 'default_orientation', 'workspace_layout', 'new_window', 'new_float', 'hide_edge_borders', 'for_window', 'assign', 'focus_follows_mouse', 'force_focus_wrapping', 'force_xinerama', 'force-xinerama', 'workspace_auto_back_and_forth', 'fake_outputs', 'fake-outputs', 'force_display_urgency_hint', 'workspace', 'ipc_socket', 'ipc-socket', 'restart_state', 'popup_during_fullscreen', 'exec_always', 'exec', 'client.background', 'client.focused_inactive', 'client.focused', 'client.unfocused', 'client.urgent'
488 ERROR: CONFIG: (in file <stdin>)
489 ERROR: CONFIG: Line 1: unknown qux
490 ERROR: CONFIG: ^^^^^^^^^^^
491 ERROR: CONFIG: Line 2: # context after
494 is(parser_calls($config),
496 'error message (0+1 context) ok');
498 ################################################################################
499 # Error message with 0+2 lines of context
500 ################################################################################
509 ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', 'bind', 'bar', 'font', 'mode', 'floating_minimum_size', 'floating_maximum_size', 'floating_modifier', 'default_orientation', 'workspace_layout', 'new_window', 'new_float', 'hide_edge_borders', 'for_window', 'assign', 'focus_follows_mouse', 'force_focus_wrapping', 'force_xinerama', 'force-xinerama', 'workspace_auto_back_and_forth', 'fake_outputs', 'fake-outputs', 'force_display_urgency_hint', 'workspace', 'ipc_socket', 'ipc-socket', 'restart_state', 'popup_during_fullscreen', 'exec_always', 'exec', 'client.background', 'client.focused_inactive', 'client.focused', 'client.unfocused', 'client.urgent'
510 ERROR: CONFIG: (in file <stdin>)
511 ERROR: CONFIG: Line 1: unknown qux
512 ERROR: CONFIG: ^^^^^^^^^^^
513 ERROR: CONFIG: Line 2: # context after
514 ERROR: CONFIG: Line 3: # context 2 after
517 is(parser_calls($config),
519 'error message (0+2 context) ok');
521 ################################################################################
522 # Error message within mode blocks
523 ################################################################################
527 bindsym x resize shrink left
534 cfg_mode_binding(bindsym, (null), x, (null), resize shrink left)
535 ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', 'bind', '}'
536 ERROR: CONFIG: (in file <stdin>)
537 ERROR: CONFIG: Line 1: mode "yo" {
538 ERROR: CONFIG: Line 2: bindsym x resize shrink left
539 ERROR: CONFIG: Line 3: unknown qux
540 ERROR: CONFIG: ^^^^^^^^^^^
541 ERROR: CONFIG: Line 4: }
544 is(parser_calls($config),
546 'error message (mode block) ok');
548 ################################################################################
549 # Error message within bar blocks
550 ################################################################################
560 cfg_bar_output(LVDS-1)
561 ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'i3bar_command', 'status_command', 'socket_path', 'mode', 'modifier', 'position', 'output', 'tray_output', 'font', 'workspace_buttons', 'verbose', 'colors', '}'
562 ERROR: CONFIG: (in file <stdin>)
563 ERROR: CONFIG: Line 1: bar {
564 ERROR: CONFIG: Line 2: output LVDS-1
565 ERROR: CONFIG: Line 3: unknown qux
566 ERROR: CONFIG: ^^^^^^^^^^^
567 ERROR: CONFIG: Line 4: }
571 is(parser_calls($config),
573 'error message (bar block) ok');