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
47 bindsym --release Mod1+x exec foo
51 my $expected = <<'EOT';
53 cfg_mode_binding(bindsym, Mod1,Shift, x, (null), resize grow)
54 cfg_mode_binding(bindcode, Mod1, 44, (null), resize shrink)
55 cfg_mode_binding(bindsym, Mod1, x, --release, exec foo)
58 is(parser_calls($config),
60 'single number (move workspace 3) ok');
62 ################################################################################
63 # exec and exec_always
64 ################################################################################
68 exec --no-startup-id /tmp/foo.sh
70 exec_always --no-startup-id /tmp/bar.sh
74 cfg_exec(exec, (null), geeqie)
75 cfg_exec(exec, --no-startup-id, /tmp/foo.sh)
76 cfg_exec(exec_always, (null), firefox)
77 cfg_exec(exec_always, --no-startup-id, /tmp/bar.sh)
80 is(parser_calls($config),
84 ################################################################################
86 ################################################################################
89 for_window [class="^Chrome"] floating enable
93 cfg_criteria_add(class, ^Chrome)
94 cfg_for_window(floating enable)
97 is(parser_calls($config),
101 ################################################################################
103 ################################################################################
106 assign [class="^Chrome"] 4
107 assign [class="^Chrome"] named workspace
108 assign [class="^Chrome"] "quoted named workspace"
109 assign [class="^Chrome"] → "quoted named workspace"
113 cfg_criteria_add(class, ^Chrome)
115 cfg_criteria_add(class, ^Chrome)
116 cfg_assign(named workspace)
117 cfg_criteria_add(class, ^Chrome)
118 cfg_assign(quoted named workspace)
119 cfg_criteria_add(class, ^Chrome)
120 cfg_assign(quoted named workspace)
123 is(parser_calls($config),
127 ################################################################################
128 # floating_minimum_size / floating_maximum_size
129 ################################################################################
132 floating_minimum_size 80x55
133 floating_minimum_size 80 x 55
134 floating_maximum_size 73 x 10
138 cfg_floating_minimum_size(80, 55)
139 cfg_floating_minimum_size(80, 55)
140 cfg_floating_maximum_size(73, 10)
143 is(parser_calls($config),
145 'floating_minimum_size ok');
147 ################################################################################
149 ################################################################################
152 floating_modifier Mod1
153 floating_modifier mOd1
157 cfg_floating_modifier(Mod1)
158 cfg_floating_modifier(Mod1)
161 is(parser_calls($config),
163 'floating_modifier ok');
165 ################################################################################
166 # default_orientation
167 ################################################################################
170 default_orientation horizontal
171 default_orientation vertical
172 default_orientation auto
176 cfg_default_orientation(horizontal)
177 cfg_default_orientation(vertical)
178 cfg_default_orientation(auto)
181 is(parser_calls($config),
183 'default_orientation ok');
185 ################################################################################
187 ################################################################################
190 workspace_layout default
191 workspace_layout stacked
192 workspace_layout stacking
193 workspace_layout tabbed
197 cfg_workspace_layout(default)
198 cfg_workspace_layout(stacked)
199 cfg_workspace_layout(stacking)
200 cfg_workspace_layout(tabbed)
203 is(parser_calls($config),
205 'workspace_layout ok');
207 ################################################################################
209 ################################################################################
221 cfg_new_window(new_window, 1pixel, -1)
222 cfg_new_window(new_window, normal, 2)
223 cfg_new_window(new_window, none, -1)
224 cfg_new_window(new_float, 1pixel, -1)
225 cfg_new_window(new_float, normal, 2)
226 cfg_new_window(new_float, none, -1)
229 is(parser_calls($config),
233 ################################################################################
235 ################################################################################
238 hide_edge_borders none
239 hide_edge_borders vertical
240 hide_edge_borders horizontal
241 hide_edge_borders both
245 cfg_hide_edge_borders(none)
246 cfg_hide_edge_borders(vertical)
247 cfg_hide_edge_borders(horizontal)
248 cfg_hide_edge_borders(both)
251 is(parser_calls($config),
253 'hide_edge_borders ok');
255 ################################################################################
256 # focus_follows_mouse
257 ################################################################################
260 focus_follows_mouse yes
261 focus_follows_mouse no
265 cfg_focus_follows_mouse(yes)
266 cfg_focus_follows_mouse(no)
269 is(parser_calls($config),
271 'focus_follows_mouse ok');
273 ################################################################################
274 # force_display_urgency_hint
275 ################################################################################
277 is(parser_calls('force_display_urgency_hint 300'),
278 "cfg_force_display_urgency_hint(300)\n",
279 'force_display_urgency_hint ok');
281 is(parser_calls('force_display_urgency_hint 500 ms'),
282 "cfg_force_display_urgency_hint(500)\n",
283 'force_display_urgency_hint ok');
285 is(parser_calls('force_display_urgency_hint 700ms'),
286 "cfg_force_display_urgency_hint(700)\n",
287 'force_display_urgency_hint ok');
290 force_display_urgency_hint 300
291 force_display_urgency_hint 500 ms
292 force_display_urgency_hint 700ms
293 force_display_urgency_hint 700
297 cfg_force_display_urgency_hint(300)
298 cfg_force_display_urgency_hint(500)
299 cfg_force_display_urgency_hint(700)
300 cfg_force_display_urgency_hint(700)
303 is(parser_calls($config),
305 'force_display_urgency_hint ok');
307 ################################################################################
309 ################################################################################
312 workspace 3 output VGA-1
313 workspace "4: output" output VGA-2
314 workspace bleh output LVDS1/I_1
318 cfg_workspace(3, VGA-1)
319 cfg_workspace(4: output, VGA-2)
320 cfg_workspace(bleh, LVDS1/I_1)
323 is(parser_calls($config),
327 ################################################################################
329 ################################################################################
332 ipc-socket /tmp/i3.sock
333 ipc_socket ~/.i3/i3.sock
337 cfg_ipc_socket(/tmp/i3.sock)
338 cfg_ipc_socket(~/.i3/i3.sock)
341 is(parser_calls($config),
345 ################################################################################
347 ################################################################################
350 client.focused #4c7899 #285577 #ffffff #2e9ef4
351 client.focused_inactive #333333 #5f676a #ffffff #484e50
352 client.unfocused #333333 #222222 #888888 #292d2e
353 client.urgent #2f343a #900000 #ffffff #900000
357 cfg_color(client.focused, #4c7899, #285577, #ffffff, #2e9ef4)
358 cfg_color(client.focused_inactive, #333333, #5f676a, #ffffff, #484e50)
359 cfg_color(client.unfocused, #333333, #222222, #888888, #292d2e)
360 cfg_color(client.urgent, #2f343a, #900000, #ffffff, #900000)
363 is(parser_calls($config),
367 ################################################################################
368 # Verify that errors don’t harm subsequent valid statements
369 ################################################################################
372 hide_edge_border both
373 client.focused #4c7899 #285577 #ffffff #2e9ef4
377 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'
378 ERROR: CONFIG: (in file <stdin>)
379 ERROR: CONFIG: Line 1: hide_edge_border both
380 ERROR: CONFIG: ^^^^^^^^^^^^^^^^^^^^^
381 ERROR: CONFIG: Line 2: client.focused #4c7899 #285577 #ffffff #2e9ef4
382 cfg_color(client.focused, #4c7899, #285577, #ffffff, #2e9ef4)
385 is(parser_calls($config),
387 'errors dont harm subsequent statements');
390 hide_edge_borders FOOBAR
391 client.focused #4c7899 #285577 #ffffff #2e9ef4
395 ERROR: CONFIG: Expected one of these tokens: 'none', 'vertical', 'horizontal', 'both', '1', 'yes', 'true', 'on', 'enable', 'active'
396 ERROR: CONFIG: (in file <stdin>)
397 ERROR: CONFIG: Line 1: hide_edge_borders FOOBAR
398 ERROR: CONFIG: ^^^^^^
399 ERROR: CONFIG: Line 2: client.focused #4c7899 #285577 #ffffff #2e9ef4
400 cfg_color(client.focused, #4c7899, #285577, #ffffff, #2e9ef4)
403 is(parser_calls($config),
405 'errors dont harm subsequent statements');
408 ################################################################################
409 # Error message with 2+2 lines of context
410 ################################################################################
413 # i3 config file (v4)
420 # this should not show up
425 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'
426 ERROR: CONFIG: (in file <stdin>)
427 ERROR: CONFIG: Line 3: font foobar
428 ERROR: CONFIG: Line 4:
429 ERROR: CONFIG: Line 5: unknown qux
430 ERROR: CONFIG: ^^^^^^^^^^^
431 ERROR: CONFIG: Line 6:
432 ERROR: CONFIG: Line 7: # yay
435 is(parser_calls($config),
437 'error message (2+2 context) ok');
439 ################################################################################
440 # Error message with 0+0 lines of context
441 ################################################################################
448 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'
449 ERROR: CONFIG: (in file <stdin>)
450 ERROR: CONFIG: Line 1: unknown qux
451 ERROR: CONFIG: ^^^^^^^^^^^
454 is(parser_calls($config),
456 'error message (0+0 context) ok');
458 ################################################################################
459 # Error message with 1+0 lines of context
460 ################################################################################
468 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'
469 ERROR: CONFIG: (in file <stdin>)
470 ERROR: CONFIG: Line 1: # context before
471 ERROR: CONFIG: Line 2: unknown qux
472 ERROR: CONFIG: ^^^^^^^^^^^
475 is(parser_calls($config),
477 'error message (1+0 context) ok');
479 ################################################################################
480 # Error message with 0+1 lines of context
481 ################################################################################
489 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'
490 ERROR: CONFIG: (in file <stdin>)
491 ERROR: CONFIG: Line 1: unknown qux
492 ERROR: CONFIG: ^^^^^^^^^^^
493 ERROR: CONFIG: Line 2: # context after
496 is(parser_calls($config),
498 'error message (0+1 context) ok');
500 ################################################################################
501 # Error message with 0+2 lines of context
502 ################################################################################
511 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'
512 ERROR: CONFIG: (in file <stdin>)
513 ERROR: CONFIG: Line 1: unknown qux
514 ERROR: CONFIG: ^^^^^^^^^^^
515 ERROR: CONFIG: Line 2: # context after
516 ERROR: CONFIG: Line 3: # context 2 after
519 is(parser_calls($config),
521 'error message (0+2 context) ok');
523 ################################################################################
524 # Error message within mode blocks
525 ################################################################################
529 bindsym x resize shrink left
536 cfg_mode_binding(bindsym, (null), x, (null), resize shrink left)
537 ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', 'bind', '}'
538 ERROR: CONFIG: (in file <stdin>)
539 ERROR: CONFIG: Line 1: mode "yo" {
540 ERROR: CONFIG: Line 2: bindsym x resize shrink left
541 ERROR: CONFIG: Line 3: unknown qux
542 ERROR: CONFIG: ^^^^^^^^^^^
543 ERROR: CONFIG: Line 4: }
546 is(parser_calls($config),
548 'error message (mode block) ok');
550 ################################################################################
551 # Error message within bar blocks
552 ################################################################################
562 cfg_bar_output(LVDS-1)
563 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', '}'
564 ERROR: CONFIG: (in file <stdin>)
565 ERROR: CONFIG: Line 1: bar {
566 ERROR: CONFIG: Line 2: output LVDS-1
567 ERROR: CONFIG: Line 3: unknown qux
568 ERROR: CONFIG: ^^^^^^^^^^^
569 ERROR: CONFIG: Line 4: }
573 is(parser_calls($config),
575 'error message (bar block) ok');