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 # Error message with 2+2 lines of context
367 ################################################################################
370 # i3 config file (v4)
377 # this should not show up
382 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'
383 ERROR: CONFIG: (in file <stdin>)
384 ERROR: CONFIG: Line 3: font foobar
385 ERROR: CONFIG: Line 4:
386 ERROR: CONFIG: Line 5: unknown qux
387 ERROR: CONFIG: ^^^^^^^^^^^
388 ERROR: CONFIG: Line 6:
389 ERROR: CONFIG: Line 7: # yay
392 is(parser_calls($config),
394 'error message (2+2 context) ok');
396 ################################################################################
397 # Error message with 0+0 lines of context
398 ################################################################################
405 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'
406 ERROR: CONFIG: (in file <stdin>)
407 ERROR: CONFIG: Line 1: unknown qux
408 ERROR: CONFIG: ^^^^^^^^^^^
411 is(parser_calls($config),
413 'error message (0+0 context) ok');
415 ################################################################################
416 # Error message with 1+0 lines of context
417 ################################################################################
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 1: # context before
428 ERROR: CONFIG: Line 2: unknown qux
429 ERROR: CONFIG: ^^^^^^^^^^^
432 is(parser_calls($config),
434 'error message (1+0 context) ok');
436 ################################################################################
437 # Error message with 0+1 lines of context
438 ################################################################################
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: ^^^^^^^^^^^
450 ERROR: CONFIG: Line 2: # context after
453 is(parser_calls($config),
455 'error message (0+1 context) ok');
457 ################################################################################
458 # Error message with 0+2 lines of context
459 ################################################################################
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: unknown qux
471 ERROR: CONFIG: ^^^^^^^^^^^
472 ERROR: CONFIG: Line 2: # context after
473 ERROR: CONFIG: Line 3: # context 2 after
476 is(parser_calls($config),
478 'error message (0+2 context) ok');
480 ################################################################################
481 # Error message within mode blocks
482 ################################################################################
486 bindsym x resize shrink left
493 cfg_mode_binding(bindsym, (null), x, (null), resize shrink left)
494 ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', 'bind', '}'
495 ERROR: CONFIG: (in file <stdin>)
496 ERROR: CONFIG: Line 1: mode "yo" {
497 ERROR: CONFIG: Line 2: bindsym x resize shrink left
498 ERROR: CONFIG: Line 3: unknown qux
499 ERROR: CONFIG: ^^^^^^^^^^^
500 ERROR: CONFIG: Line 4: }
503 is(parser_calls($config),
505 'error message (mode block) ok');
507 ################################################################################
508 # Error message within bar blocks
509 ################################################################################
519 cfg_bar_output(LVDS-1)
520 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', '}'
521 ERROR: CONFIG: (in file <stdin>)
522 ERROR: CONFIG: Line 1: bar {
523 ERROR: CONFIG: Line 2: output LVDS-1
524 ERROR: CONFIG: Line 3: unknown qux
525 ERROR: CONFIG: ^^^^^^^^^^^
526 ERROR: CONFIG: Line 4: }
529 is(parser_calls($config),
531 'error message (bar block) ok');