]> git.sur5r.net Git - i3/i3/blobdiff - testcases/t/187-commands-parser.t
Bugfix: Properly handle workspace names with double quotes (+test) (Thanks kvapen)
[i3/i3] / testcases / t / 187-commands-parser.t
index 35eaef7308bb4a3365e449005979d20bd9066fce..ca81e2f6b66350af1f4ec2a574f61712457e791e 100644 (file)
@@ -12,7 +12,7 @@ sub parser_calls {
 
     # TODO: use a timeout, so that we can error out if it doesn’t terminate
     # TODO: better way of passing arguments
-    my $stdout = qx(../test.commands_parser '$command');
+    my $stdout = qx(../test.commands_parser '$command' 2>&-);
 
     # Filter out all debugging output.
     my @lines = split("\n", $stdout);
@@ -129,6 +129,17 @@ is(parser_calls('[con_mark="yay"] focus'),
    "cmd_focus()",
    'quoted criteria focus ok');
 
+# Make sure trailing whitespace is stripped off: While this is not an issue for
+# commands being parsed due to the configuration, people might send IPC
+# commands with leading or trailing newlines.
+is(parser_calls("workspace test\n"),
+   'cmd_workspace_name(test)',
+   'trailing whitespace stripped off ok');
+
+is(parser_calls("\nworkspace test"),
+   'cmd_workspace_name(test)',
+   'trailing whitespace stripped off ok');
+
 ################################################################################
 # 2: Verify that the parser spits out the right error message on commands which
 # are not ok.
@@ -146,4 +157,16 @@ is(parser_calls('move something to somewhere'),
    "                   ^^^^^^^^^^^^^^^^^^^^^^",
    'error for unknown literal ok');
 
+################################################################################
+# 3: Verify that escaping of double quotes works correctly
+################################################################################
+
+is(parser_calls('workspace "foo"'),
+   'cmd_workspace_name(foo)',
+   'Command with simple double quotes ok');
+
+is(parser_calls('workspace "foo \"bar"'),
+   'cmd_workspace_name(foo "bar)',
+   'Command with escaped double quotes ok');
+
 done_testing;