new parser: correctly handle leading/trailing newlines (+test) (Thanks helgikrs)

This commit is contained in:
Michael Stapelberg
2012-01-25 22:00:32 +00:00
parent 57a96bb61f
commit 19dc92a9a5
2 changed files with 26 additions and 9 deletions

View File

@ -12,7 +12,7 @@ sub parser_calls {
# TODO: use a timeout, so that we can error out if it doesnt 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.