]> git.sur5r.net Git - i3/i3/blobdiff - testcases/t/201-config-parser.t
Merge branch 'master' into next
[i3/i3] / testcases / t / 201-config-parser.t
index 711b689db795174aeaae032c38c7c237dc17cc89..9643aa42f5f5678536a181e481cc1a1da00f1fdf 100644 (file)
@@ -26,7 +26,7 @@ sub parser_calls {
 
     my $stdout;
     run [ '../test.config_parser', $command ],
-        '>&-',
+        '>/dev/null',
         '2>', \$stdout;
     # TODO: use a timeout, so that we can error out if it doesn’t terminate
 
@@ -44,13 +44,15 @@ my $config = <<'EOT';
 mode "meh" {
     bindsym Mod1 + Shift +   x resize grow
     bindcode Mod1+44 resize shrink
+    bindsym --release Mod1+x exec foo
 }
 EOT
 
 my $expected = <<'EOT';
 cfg_enter_mode(meh)
-cfg_mode_binding(bindsym, Mod1,Shift, x, (null), resize grow)
-cfg_mode_binding(bindcode, Mod1, 44, (null), resize shrink)
+cfg_mode_binding(bindsym, Mod1,Shift, x, (null), (null), resize grow)
+cfg_mode_binding(bindcode, Mod1, 44, (null), (null), resize shrink)
+cfg_mode_binding(bindsym, Mod1, x, --release, (null), exec foo)
 EOT
 
 is(parser_calls($config),
@@ -142,6 +144,27 @@ is(parser_calls($config),
    $expected,
    'floating_minimum_size ok');
 
+################################################################################
+# popup_during_fullscreen
+################################################################################
+
+$config = <<'EOT';
+popup_during_fullscreen ignore
+popup_during_fullscreen leave_fullscreen
+popup_during_fullscreen SMArt
+EOT
+
+$expected = <<'EOT';
+cfg_popup_during_fullscreen(ignore)
+cfg_popup_during_fullscreen(leave_fullscreen)
+cfg_popup_during_fullscreen(smart)
+EOT
+
+is(parser_calls($config),
+   $expected,
+   'popup_during_fullscreen ok');
+
+
 ################################################################################
 # floating_modifier
 ################################################################################
@@ -202,6 +225,24 @@ is(parser_calls($config),
    $expected,
    'workspace_layout ok');
 
+################################################################################
+# workspace assignments, with trailing whitespace (ticket #921)
+################################################################################
+
+$config = <<'EOT';
+workspace "3" output DP-1 
+workspace "3" output           VGA-1   
+EOT
+
+$expected = <<'EOT';
+cfg_workspace(3, DP-1)
+cfg_workspace(3, VGA-1)
+EOT
+
+is(parser_calls($config),
+   $expected,
+   'workspace assignment ok');
+
 ################################################################################
 # new_window
 ################################################################################
@@ -268,6 +309,24 @@ is(parser_calls($config),
    $expected,
    'focus_follows_mouse ok');
 
+################################################################################
+# mouse_warping
+################################################################################
+
+$config = <<'EOT';
+mouse_warping output
+mouse_warping none
+EOT
+
+$expected = <<'EOT';
+cfg_mouse_warping(output)
+cfg_mouse_warping(none)
+EOT
+
+is(parser_calls($config),
+   $expected,
+   'mouse_warping ok');
+
 ################################################################################
 # force_display_urgency_hint
 ################################################################################
@@ -349,6 +408,7 @@ client.focused          #4c7899 #285577 #ffffff #2e9ef4
 client.focused_inactive #333333 #5f676a #ffffff #484e50
 client.unfocused        #333333 #222222 #888888 #292d2e
 client.urgent           #2f343a #900000 #ffffff #900000
+client.placeholder      #000000 #0c0c0c #ffffff #000000
 EOT
 
 $expected = <<'EOT';
@@ -356,12 +416,74 @@ cfg_color(client.focused, #4c7899, #285577, #ffffff, #2e9ef4)
 cfg_color(client.focused_inactive, #333333, #5f676a, #ffffff, #484e50)
 cfg_color(client.unfocused, #333333, #222222, #888888, #292d2e)
 cfg_color(client.urgent, #2f343a, #900000, #ffffff, #900000)
+cfg_color(client.placeholder, #000000, #0c0c0c, #ffffff, #000000)
 EOT
 
 is(parser_calls($config),
    $expected,
    'colors ok');
 
+################################################################################
+# Verify that errors don’t harm subsequent valid statements
+################################################################################
+
+$config = <<'EOT';
+hide_edge_border both
+client.focused          #4c7899 #285577 #ffffff #2e9ef4
+EOT
+
+my $expected_all_tokens = <<'EOT';
+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', 'mouse_warping', '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', 'client.placeholder'
+EOT
+
+my $expected_end = <<'EOT';
+ERROR: CONFIG: (in file <stdin>)
+ERROR: CONFIG: Line   1: hide_edge_border both
+ERROR: CONFIG:           ^^^^^^^^^^^^^^^^^^^^^
+ERROR: CONFIG: Line   2: client.focused          #4c7899 #285577 #ffffff #2e9ef4
+cfg_color(client.focused, #4c7899, #285577, #ffffff, #2e9ef4)
+EOT
+
+$expected = $expected_all_tokens . $expected_end;
+
+is(parser_calls($config),
+   $expected,
+   'errors dont harm subsequent statements');
+
+$config = <<'EOT';
+hide_edge_borders FOOBAR
+client.focused          #4c7899 #285577 #ffffff #2e9ef4
+EOT
+
+$expected = <<'EOT';
+ERROR: CONFIG: Expected one of these tokens: 'none', 'vertical', 'horizontal', 'both', '1', 'yes', 'true', 'on', 'enable', 'active'
+ERROR: CONFIG: (in file <stdin>)
+ERROR: CONFIG: Line   1: hide_edge_borders FOOBAR
+ERROR: CONFIG:                             ^^^^^^
+ERROR: CONFIG: Line   2: client.focused          #4c7899 #285577 #ffffff #2e9ef4
+cfg_color(client.focused, #4c7899, #285577, #ffffff, #2e9ef4)
+EOT
+
+is(parser_calls($config),
+   $expected,
+   'errors dont harm subsequent statements');
+
+################################################################################
+# Regression: semicolons end comments, but shouldn’t
+################################################################################
+
+$config = <<'EOT';
+# "foo" client.focused          #4c7899 #285577 #ffffff #2e9ef4
+EOT
+
+$expected = <<'EOT';
+
+EOT
+
+is(parser_calls($config),
+   $expected,
+   'semicolon does not end a comment line');
+
 ################################################################################
 # Error message with 2+2 lines of context
 ################################################################################
@@ -377,9 +499,11 @@ unknown qux
 # this should not show up
 EOT
 
-$expected = <<'EOT';
+my $expected_head = <<'EOT';
 cfg_font(foobar)
-ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', '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'
+EOT
+
+my $expected_tail = <<'EOT';
 ERROR: CONFIG: (in file <stdin>)
 ERROR: CONFIG: Line   3: font foobar
 ERROR: CONFIG: Line   4: 
@@ -389,6 +513,8 @@ ERROR: CONFIG: Line   6:
 ERROR: CONFIG: Line   7: # yay
 EOT
 
+$expected = $expected_head . $expected_all_tokens . $expected_tail;
+
 is(parser_calls($config),
    $expected,
    'error message (2+2 context) ok');
@@ -401,13 +527,14 @@ $config = <<'EOT';
 unknown qux
 EOT
 
-$expected = <<'EOT';
-ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', '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'
+$expected_tail = <<'EOT';
 ERROR: CONFIG: (in file <stdin>)
 ERROR: CONFIG: Line   1: unknown qux
 ERROR: CONFIG:           ^^^^^^^^^^^
 EOT
 
+$expected = $expected_all_tokens . $expected_tail;
+
 is(parser_calls($config),
    $expected,
    'error message (0+0 context) ok');
@@ -421,14 +548,15 @@ $config = <<'EOT';
 unknown qux
 EOT
 
-$expected = <<'EOT';
-ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', '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'
+$expected_tail = <<'EOT';
 ERROR: CONFIG: (in file <stdin>)
 ERROR: CONFIG: Line   1: # context before
 ERROR: CONFIG: Line   2: unknown qux
 ERROR: CONFIG:           ^^^^^^^^^^^
 EOT
 
+$expected = $expected_all_tokens . $expected_tail;
+
 is(parser_calls($config),
    $expected,
    'error message (1+0 context) ok');
@@ -442,14 +570,15 @@ unknown qux
 # context after
 EOT
 
-$expected = <<'EOT';
-ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', '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'
+$expected_tail = <<'EOT';
 ERROR: CONFIG: (in file <stdin>)
 ERROR: CONFIG: Line   1: unknown qux
 ERROR: CONFIG:           ^^^^^^^^^^^
 ERROR: CONFIG: Line   2: # context after
 EOT
 
+$expected = $expected_all_tokens . $expected_tail;
+
 is(parser_calls($config),
    $expected,
    'error message (0+1 context) ok');
@@ -464,8 +593,7 @@ unknown qux
 # context 2 after
 EOT
 
-$expected = <<'EOT';
-ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', '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'
+$expected_tail = <<'EOT';
 ERROR: CONFIG: (in file <stdin>)
 ERROR: CONFIG: Line   1: unknown qux
 ERROR: CONFIG:           ^^^^^^^^^^^
@@ -473,6 +601,8 @@ ERROR: CONFIG: Line   2: # context after
 ERROR: CONFIG: Line   3: # context 2 after
 EOT
 
+$expected = $expected_all_tokens . $expected_tail;
+
 is(parser_calls($config),
    $expected,
    'error message (0+2 context) ok');
@@ -490,8 +620,8 @@ EOT
 
 $expected = <<'EOT';
 cfg_enter_mode(yo)
-cfg_mode_binding(bindsym, (null), x, (null), resize shrink left)
-ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', '}'
+cfg_mode_binding(bindsym, (null), x, (null), (null), resize shrink left)
+ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', 'bind', '}'
 ERROR: CONFIG: (in file <stdin>)
 ERROR: CONFIG: Line   1: mode "yo" {
 ERROR: CONFIG: Line   2:     bindsym x resize shrink left
@@ -517,13 +647,14 @@ EOT
 
 $expected = <<'EOT';
 cfg_bar_output(LVDS-1)
-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', '}'
+ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'i3bar_command', 'status_command', 'socket_path', 'mode', 'hidden_state', 'id', 'modifier', 'wheel_up_cmd', 'wheel_down_cmd', 'position', 'output', 'tray_output', 'font', 'binding_mode_indicator', 'workspace_buttons', 'strip_workspace_numbers', 'verbose', 'colors', '}'
 ERROR: CONFIG: (in file <stdin>)
 ERROR: CONFIG: Line   1: bar {
 ERROR: CONFIG: Line   2:     output LVDS-1
 ERROR: CONFIG: Line   3:     unknown qux
 ERROR: CONFIG:               ^^^^^^^^^^^
 ERROR: CONFIG: Line   4: }
+cfg_bar_finish()
 EOT
 
 is(parser_calls($config),