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 ################################################################################
208 # workspace assignments, with trailing whitespace (ticket #921)
209 ################################################################################
212 workspace "3" output DP-1
213 workspace "3" output VGA-1
217 cfg_workspace(3, DP-1)
218 cfg_workspace(3, VGA-1)
221 is(parser_calls($config),
223 'workspace assignment ok');
225 ################################################################################
227 ################################################################################
239 cfg_new_window(new_window, 1pixel, -1)
240 cfg_new_window(new_window, normal, 2)
241 cfg_new_window(new_window, none, -1)
242 cfg_new_window(new_float, 1pixel, -1)
243 cfg_new_window(new_float, normal, 2)
244 cfg_new_window(new_float, none, -1)
247 is(parser_calls($config),
251 ################################################################################
253 ################################################################################
256 hide_edge_borders none
257 hide_edge_borders vertical
258 hide_edge_borders horizontal
259 hide_edge_borders both
263 cfg_hide_edge_borders(none)
264 cfg_hide_edge_borders(vertical)
265 cfg_hide_edge_borders(horizontal)
266 cfg_hide_edge_borders(both)
269 is(parser_calls($config),
271 'hide_edge_borders ok');
273 ################################################################################
274 # focus_follows_mouse
275 ################################################################################
278 focus_follows_mouse yes
279 focus_follows_mouse no
283 cfg_focus_follows_mouse(yes)
284 cfg_focus_follows_mouse(no)
287 is(parser_calls($config),
289 'focus_follows_mouse ok');
291 ################################################################################
292 # force_display_urgency_hint
293 ################################################################################
295 is(parser_calls('force_display_urgency_hint 300'),
296 "cfg_force_display_urgency_hint(300)\n",
297 'force_display_urgency_hint ok');
299 is(parser_calls('force_display_urgency_hint 500 ms'),
300 "cfg_force_display_urgency_hint(500)\n",
301 'force_display_urgency_hint ok');
303 is(parser_calls('force_display_urgency_hint 700ms'),
304 "cfg_force_display_urgency_hint(700)\n",
305 'force_display_urgency_hint ok');
308 force_display_urgency_hint 300
309 force_display_urgency_hint 500 ms
310 force_display_urgency_hint 700ms
311 force_display_urgency_hint 700
315 cfg_force_display_urgency_hint(300)
316 cfg_force_display_urgency_hint(500)
317 cfg_force_display_urgency_hint(700)
318 cfg_force_display_urgency_hint(700)
321 is(parser_calls($config),
323 'force_display_urgency_hint ok');
325 ################################################################################
327 ################################################################################
330 workspace 3 output VGA-1
331 workspace "4: output" output VGA-2
332 workspace bleh output LVDS1/I_1
336 cfg_workspace(3, VGA-1)
337 cfg_workspace(4: output, VGA-2)
338 cfg_workspace(bleh, LVDS1/I_1)
341 is(parser_calls($config),
345 ################################################################################
347 ################################################################################
350 ipc-socket /tmp/i3.sock
351 ipc_socket ~/.i3/i3.sock
355 cfg_ipc_socket(/tmp/i3.sock)
356 cfg_ipc_socket(~/.i3/i3.sock)
359 is(parser_calls($config),
363 ################################################################################
365 ################################################################################
368 client.focused #4c7899 #285577 #ffffff #2e9ef4
369 client.focused_inactive #333333 #5f676a #ffffff #484e50
370 client.unfocused #333333 #222222 #888888 #292d2e
371 client.urgent #2f343a #900000 #ffffff #900000
375 cfg_color(client.focused, #4c7899, #285577, #ffffff, #2e9ef4)
376 cfg_color(client.focused_inactive, #333333, #5f676a, #ffffff, #484e50)
377 cfg_color(client.unfocused, #333333, #222222, #888888, #292d2e)
378 cfg_color(client.urgent, #2f343a, #900000, #ffffff, #900000)
381 is(parser_calls($config),
385 ################################################################################
386 # Verify that errors don’t harm subsequent valid statements
387 ################################################################################
390 hide_edge_border both
391 client.focused #4c7899 #285577 #ffffff #2e9ef4
395 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'
396 ERROR: CONFIG: (in file <stdin>)
397 ERROR: CONFIG: Line 1: hide_edge_border both
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 hide_edge_borders FOOBAR
409 client.focused #4c7899 #285577 #ffffff #2e9ef4
413 ERROR: CONFIG: Expected one of these tokens: 'none', 'vertical', 'horizontal', 'both', '1', 'yes', 'true', 'on', 'enable', 'active'
414 ERROR: CONFIG: (in file <stdin>)
415 ERROR: CONFIG: Line 1: hide_edge_borders FOOBAR
416 ERROR: CONFIG: ^^^^^^
417 ERROR: CONFIG: Line 2: client.focused #4c7899 #285577 #ffffff #2e9ef4
418 cfg_color(client.focused, #4c7899, #285577, #ffffff, #2e9ef4)
421 is(parser_calls($config),
423 'errors dont harm subsequent statements');
426 ################################################################################
427 # Error message with 2+2 lines of context
428 ################################################################################
431 # i3 config file (v4)
438 # this should not show up
443 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'
444 ERROR: CONFIG: (in file <stdin>)
445 ERROR: CONFIG: Line 3: font foobar
446 ERROR: CONFIG: Line 4:
447 ERROR: CONFIG: Line 5: unknown qux
448 ERROR: CONFIG: ^^^^^^^^^^^
449 ERROR: CONFIG: Line 6:
450 ERROR: CONFIG: Line 7: # yay
453 is(parser_calls($config),
455 'error message (2+2 context) ok');
457 ################################################################################
458 # Error message with 0+0 lines of context
459 ################################################################################
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: unknown qux
469 ERROR: CONFIG: ^^^^^^^^^^^
472 is(parser_calls($config),
474 'error message (0+0 context) ok');
476 ################################################################################
477 # Error message with 1+0 lines of context
478 ################################################################################
486 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'
487 ERROR: CONFIG: (in file <stdin>)
488 ERROR: CONFIG: Line 1: # context before
489 ERROR: CONFIG: Line 2: unknown qux
490 ERROR: CONFIG: ^^^^^^^^^^^
493 is(parser_calls($config),
495 'error message (1+0 context) ok');
497 ################################################################################
498 # Error message with 0+1 lines of context
499 ################################################################################
507 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'
508 ERROR: CONFIG: (in file <stdin>)
509 ERROR: CONFIG: Line 1: unknown qux
510 ERROR: CONFIG: ^^^^^^^^^^^
511 ERROR: CONFIG: Line 2: # context after
514 is(parser_calls($config),
516 'error message (0+1 context) ok');
518 ################################################################################
519 # Error message with 0+2 lines of context
520 ################################################################################
529 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'
530 ERROR: CONFIG: (in file <stdin>)
531 ERROR: CONFIG: Line 1: unknown qux
532 ERROR: CONFIG: ^^^^^^^^^^^
533 ERROR: CONFIG: Line 2: # context after
534 ERROR: CONFIG: Line 3: # context 2 after
537 is(parser_calls($config),
539 'error message (0+2 context) ok');
541 ################################################################################
542 # Error message within mode blocks
543 ################################################################################
547 bindsym x resize shrink left
554 cfg_mode_binding(bindsym, (null), x, (null), resize shrink left)
555 ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', 'bind', '}'
556 ERROR: CONFIG: (in file <stdin>)
557 ERROR: CONFIG: Line 1: mode "yo" {
558 ERROR: CONFIG: Line 2: bindsym x resize shrink left
559 ERROR: CONFIG: Line 3: unknown qux
560 ERROR: CONFIG: ^^^^^^^^^^^
561 ERROR: CONFIG: Line 4: }
564 is(parser_calls($config),
566 'error message (mode block) ok');
568 ################################################################################
569 # Error message within bar blocks
570 ################################################################################
580 cfg_bar_output(LVDS-1)
581 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', '}'
582 ERROR: CONFIG: (in file <stdin>)
583 ERROR: CONFIG: Line 1: bar {
584 ERROR: CONFIG: Line 2: output LVDS-1
585 ERROR: CONFIG: Line 3: unknown qux
586 ERROR: CONFIG: ^^^^^^^^^^^
587 ERROR: CONFIG: Line 4: }
591 is(parser_calls($config),
593 'error message (bar block) ok');