From a0c0db15103a54dba20fb309956a7b3cf90bc645 Mon Sep 17 00:00:00 2001 From: kotfu Date: Sun, 6 May 2018 00:20:46 -0600 Subject: Fix alias expansion when not followed by whitespace --- tests/test_parsing.py | 85 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 66 insertions(+), 19 deletions(-) (limited to 'tests/test_parsing.py') diff --git a/tests/test_parsing.py b/tests/test_parsing.py index 7940bbd8..9e48bcf9 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -49,7 +49,7 @@ def test_tokenize(parser, line, tokens): (['command'], 'command', None), (['command', 'arg1', 'arg2'], 'command', 'arg1 arg2') ]) -def test_command_and_args(parser, tokens, command, args): +def test_parse_command_and_args(parser, tokens, command, args): (parsed_command, parsed_args) = parser._command_and_args(tokens) assert command == parsed_command assert args == parsed_args @@ -59,20 +59,20 @@ def test_command_and_args(parser, tokens, command, args): '"one word"', "'one word'", ]) -def test_single_word(parser, line): +def test_parse_single_word(parser, line): statement = parser.parse(line) assert statement.command == line assert not statement.args assert statement.argv == [utils.strip_quotes(line)] -def test_word_plus_terminator(parser): +def test_parse_word_plus_terminator(parser): line = 'termbare;' statement = parser.parse(line) assert statement.command == 'termbare' assert statement.terminator == ';' assert statement.argv == ['termbare'] -def test_suffix_after_terminator(parser): +def test_parse_suffix_after_terminator(parser): line = 'termbare; suffx' statement = parser.parse(line) assert statement.command == 'termbare' @@ -80,14 +80,14 @@ def test_suffix_after_terminator(parser): assert statement.suffix == 'suffx' assert statement.argv == ['termbare'] -def test_command_with_args(parser): +def test_parse_command_with_args(parser): line = 'command with args' statement = parser.parse(line) assert statement.command == 'command' assert statement.args == 'with args' assert statement.argv == ['command', 'with', 'args'] -def test_command_with_quoted_args(parser): +def test_parse_command_with_quoted_args(parser): line = 'command with "quoted args" and "some not"' statement = parser.parse(line) assert statement.command == 'command' @@ -103,20 +103,20 @@ def test_parse_command_with_args_terminator_and_suffix(parser): assert statement.suffix == 'and suffix' assert statement.argv == ['command', 'with', 'args', 'and', 'terminator'] -def test_hashcomment(parser): +def test_parse_hashcomment(parser): statement = parser.parse('hi # this is all a comment') assert statement.command == 'hi' assert not statement.args assert statement.argv == ['hi'] -def test_c_comment(parser): +def test_parse_c_comment(parser): statement = parser.parse('hi /* this is | all a comment */') assert statement.command == 'hi' assert not statement.args assert not statement.pipe_to assert statement.argv == ['hi'] -def test_c_comment_empty(parser): +def test_parse_c_comment_empty(parser): statement = parser.parse('/* this is | all a comment */') assert not statement.command assert not statement.args @@ -130,14 +130,18 @@ def test_parse_what_if_quoted_strings_seem_to_start_comments(parser): assert not statement.pipe_to assert statement.argv == ['what', 'if', 'quoted strings /* seem to ', 'start', 'comments?'] -def test_simple_piped(parser): - statement = parser.parse('simple | piped') +@pytest.mark.parametrize('line',[ + 'simple | piped', + 'simple|piped', +]) +def test_parse_simple_pipe(parser, line): + statement = parser.parse(line) assert statement.command == 'simple' assert not statement.args assert statement.argv == ['simple'] assert statement.pipe_to == 'piped' -def test_double_pipe_is_not_a_pipe(parser): +def test_parse_double_pipe_is_not_a_pipe(parser): line = 'double-pipe || is not a pipe' statement = parser.parse(line) assert statement.command == 'double-pipe' @@ -145,7 +149,7 @@ def test_double_pipe_is_not_a_pipe(parser): assert statement.argv == ['double-pipe', '||', 'is', 'not', 'a', 'pipe'] assert not statement.pipe_to -def test_complex_pipe(parser): +def test_parse_complex_pipe(parser): line = 'command with args, terminator;sufx | piped' statement = parser.parse(line) assert statement.command == 'command' @@ -155,7 +159,20 @@ def test_complex_pipe(parser): assert statement.suffix == 'sufx' assert statement.pipe_to == 'piped' -def test_output_redirect(parser): +@pytest.mark.parametrize('line,output', [ + ('help > out.txt', '>'), + ('help>out.txt', '>'), + ('help >> out.txt', '>>'), + ('help>>out.txt', '>>'), +]) +def test_parse_redirect(parser,line): + statement = parser.parse(line) + assert statement.command == 'help' + assert not statement.args + assert statement.output == '>' + assert statement.output_to == 'out.txt' + +def test_parse_redirect_with_args(parser): line = 'output into > afile.txt' statement = parser.parse(line) assert statement.command == 'output' @@ -164,7 +181,7 @@ def test_output_redirect(parser): assert statement.output == '>' assert statement.output_to == 'afile.txt' -def test_output_redirect_with_dash_in_path(parser): +def test_parse_redirect_with_dash_in_path(parser): line = 'output into > python-cmd2/afile.txt' statement = parser.parse(line) assert statement.command == 'output' @@ -173,7 +190,7 @@ def test_output_redirect_with_dash_in_path(parser): assert statement.output == '>' assert statement.output_to == 'python-cmd2/afile.txt' -def test_output_redirect_append(parser): +def test_parse_redirect_append(parser): line = 'output appended to >> /tmp/afile.txt' statement = parser.parse(line) assert statement.command == 'output' @@ -182,7 +199,7 @@ def test_output_redirect_append(parser): assert statement.output == '>>' assert statement.output_to == '/tmp/afile.txt' -def test_pipe_and_redirect(parser): +def test_parse_pipe_and_redirect(parser): line = 'output into;sufx | pipethrume plz > afile.txt' statement = parser.parse(line) assert statement.command == 'output' @@ -307,12 +324,12 @@ def test_empty_statement_raises_exception(): ('!ls -al /tmp', 'shell', 'ls -al /tmp'), ('l', 'shell', 'ls -al') ]) -def test_alias_and_shortcut_expansion(parser, line, command, args): +def test_parse_alias_and_shortcut_expansion(parser, line, command, args): statement = parser.parse(line) assert statement.command == command assert statement.args == args -def test_alias_on_multiline_command(parser): +def test_parse_alias_on_multiline_command(parser): line = 'anothermultiline has > inside an unfinished command' statement = parser.parse(line) assert statement.multiline_command == 'multiline' @@ -320,6 +337,36 @@ def test_alias_on_multiline_command(parser): assert statement.args == 'has > inside an unfinished command' assert not statement.terminator +@pytest.mark.parametrize('line,output', [ + ('helpalias > out.txt', '>'), + ('helpalias>out.txt', '>'), + ('helpalias >> out.txt', '>>'), + ('helpalias>>out.txt', '>>'), +]) +def test_parse_alias_redirection(parser, line, output): + statement = parser.parse(line) + assert statement.command == 'help' + assert not statement.args + assert statement.output == output + assert statement.output_to == 'out.txt' + +@pytest.mark.parametrize('line', [ + 'helpalias | less', + 'helpalias|less', +]) +def test_parse_alias_pipe(parser, line): + statement = parser.parse(line) + assert statement.command == 'help' + assert not statement.args + assert statement.pipe_to == 'less' + +def test_parse_alias_terminator_no_whitespace(parser): + line = 'helpalias;' + statement = parser.parse(line) + assert statement.command == 'help' + assert not statement.args + assert statement.terminator == ';' + def test_parse_command_only_command_and_args(parser): line = 'help history' statement = parser.parse_command_only(line) -- cgit v1.2.1 From 285b45bfa9ae79a936c35fd9c4b0ea0706082a3d Mon Sep 17 00:00:00 2001 From: kotfu Date: Sun, 6 May 2018 00:22:41 -0600 Subject: Oops, fixed an oversight that broke the build This is what you get for being too hasty when you push. --- tests/test_parsing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/test_parsing.py') diff --git a/tests/test_parsing.py b/tests/test_parsing.py index 9e48bcf9..2f3f338f 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -165,11 +165,11 @@ def test_parse_complex_pipe(parser): ('help >> out.txt', '>>'), ('help>>out.txt', '>>'), ]) -def test_parse_redirect(parser,line): +def test_parse_redirect(parser,line, output): statement = parser.parse(line) assert statement.command == 'help' assert not statement.args - assert statement.output == '>' + assert statement.output == output assert statement.output_to == 'out.txt' def test_parse_redirect_with_args(parser): -- cgit v1.2.1 From e945560fe80087bbd0bf91c41e37b17131e83e69 Mon Sep 17 00:00:00 2001 From: kotfu Date: Sun, 6 May 2018 10:07:27 -0600 Subject: Fix pylint warnings --- tests/test_parsing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/test_parsing.py') diff --git a/tests/test_parsing.py b/tests/test_parsing.py index 1ebadae8..4b972d51 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -46,7 +46,7 @@ def test_tokenize(parser, line, tokens): def test_tokenize_unclosed_quotes(parser): with pytest.raises(ValueError): - tokens = parser.tokenize('command with "unclosed quotes') + _ = parser.tokenize('command with "unclosed quotes') @pytest.mark.parametrize('tokens,command,args', [ ([], None, None), @@ -313,7 +313,7 @@ def test_parse_redirect_to_unicode_filename(parser): def test_parse_unclosed_quotes(parser): with pytest.raises(ValueError): - tokens = parser.tokenize("command with 'unclosed quotes") + _ = parser.tokenize("command with 'unclosed quotes") def test_empty_statement_raises_exception(): app = cmd2.Cmd() -- cgit v1.2.1 From 3343aad02757739fd7ddb91b095db277a59574d9 Mon Sep 17 00:00:00 2001 From: kotfu Date: Sun, 6 May 2018 10:15:42 -0600 Subject: Add more unit tests --- tests/test_parsing.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'tests/test_parsing.py') diff --git a/tests/test_parsing.py b/tests/test_parsing.py index 4b972d51..f560f993 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -38,7 +38,10 @@ def test_parse_empty_string(parser): ('command /* with some comment */ arg', ['command', 'arg']), ('command arg1 arg2 # comment at the end', ['command', 'arg1', 'arg2']), ('42 arg1 arg2', ['theanswer', 'arg1', 'arg2']), - ('l', ['shell', 'ls', '-al']) + ('l', ['shell', 'ls', '-al']), + ('termbare ; > /tmp/output', ['termbare', ';', '>', '/tmp/output']), + ('help|less', ['help', '|', 'less']), + ('l|less', ['shell', 'ls', '-al', '|', 'less']), ]) def test_tokenize(parser, line, tokens): tokens_to_test = parser.tokenize(line) @@ -69,15 +72,21 @@ def test_parse_single_word(parser, line): assert not statement.args assert statement.argv == [utils.strip_quotes(line)] -def test_parse_word_plus_terminator(parser): - line = 'termbare;' +@pytest.mark.parametrize('line', [ + 'termbare;', + 'termbare ;', +]) +def test_parse_word_plus_terminator(parser, line): statement = parser.parse(line) assert statement.command == 'termbare' assert statement.terminator == ';' assert statement.argv == ['termbare'] -def test_parse_suffix_after_terminator(parser): - line = 'termbare; suffx' +@pytest.mark.parametrize('line', [ + 'termbare; suffx', + 'termbare ;suffx', +]) +def test_parse_suffix_after_terminator(parser, line): statement = parser.parse(line) assert statement.command == 'termbare' assert statement.terminator == ';' -- cgit v1.2.1 From 76e7e67e45ca2cac8339a3c3fe56d91d730ad58a Mon Sep 17 00:00:00 2001 From: kotfu Date: Sun, 6 May 2018 10:22:45 -0600 Subject: Rename unit test --- tests/test_parsing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_parsing.py') diff --git a/tests/test_parsing.py b/tests/test_parsing.py index f560f993..43baa0f4 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -56,7 +56,7 @@ def test_tokenize_unclosed_quotes(parser): (['command'], 'command', None), (['command', 'arg1', 'arg2'], 'command', 'arg1 arg2') ]) -def test_parse_command_and_args(parser, tokens, command, args): +def test_command_and_args(parser, tokens, command, args): (parsed_command, parsed_args) = parser._command_and_args(tokens) assert command == parsed_command assert args == parsed_args -- cgit v1.2.1 From d6d92949784b223ad03f70999bc55518c92d9fc9 Mon Sep 17 00:00:00 2001 From: kotfu Date: Sun, 6 May 2018 10:29:55 -0600 Subject: Add unit tests to ensure multiple terminator chars works --- tests/test_parsing.py | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) (limited to 'tests/test_parsing.py') diff --git a/tests/test_parsing.py b/tests/test_parsing.py index 43baa0f4..ad4d31cd 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -16,7 +16,7 @@ from cmd2 import utils def parser(): parser = StatementParser( allow_redirection=True, - terminators=[';'], + terminators=[';', '&'], multiline_commands=['multiline'], aliases={'helpalias': 'help', '42': 'theanswer', @@ -40,6 +40,9 @@ def test_parse_empty_string(parser): ('42 arg1 arg2', ['theanswer', 'arg1', 'arg2']), ('l', ['shell', 'ls', '-al']), ('termbare ; > /tmp/output', ['termbare', ';', '>', '/tmp/output']), + ('termbare; > /tmp/output', ['termbare', ';', '>', '/tmp/output']), + ('termbare & > /tmp/output', ['termbare', '&', '>', '/tmp/output']), + ('termbare& > /tmp/output', ['termbare', '&', '>', '/tmp/output']), ('help|less', ['help', '|', 'less']), ('l|less', ['shell', 'ls', '-al', '|', 'less']), ]) @@ -72,24 +75,28 @@ def test_parse_single_word(parser, line): assert not statement.args assert statement.argv == [utils.strip_quotes(line)] -@pytest.mark.parametrize('line', [ - 'termbare;', - 'termbare ;', +@pytest.mark.parametrize('line,terminator', [ + ('termbare;', ';'), + ('termbare ;', ';'), + ('termbare&', '&'), + ('termbare &', '&'), ]) -def test_parse_word_plus_terminator(parser, line): +def test_parse_word_plus_terminator(parser, line, terminator): statement = parser.parse(line) assert statement.command == 'termbare' - assert statement.terminator == ';' + assert statement.terminator == terminator assert statement.argv == ['termbare'] -@pytest.mark.parametrize('line', [ - 'termbare; suffx', - 'termbare ;suffx', +@pytest.mark.parametrize('line,terminator', [ + ('termbare; suffx', ';'), + ('termbare ;suffx', ';'), + ('termbare& suffx', '&'), + ('termbare &suffx', '&'), ]) -def test_parse_suffix_after_terminator(parser, line): +def test_parse_suffix_after_terminator(parser, line, terminator): statement = parser.parse(line) assert statement.command == 'termbare' - assert statement.terminator == ';' + assert statement.terminator == terminator assert statement.suffix == 'suffx' assert statement.argv == ['termbare'] @@ -163,12 +170,12 @@ def test_parse_double_pipe_is_not_a_pipe(parser): assert not statement.pipe_to def test_parse_complex_pipe(parser): - line = 'command with args, terminator;sufx | piped' + line = 'command with args, terminator&sufx | piped' statement = parser.parse(line) assert statement.command == 'command' assert statement.args == "with args, terminator" assert statement.argv == ['command', 'with', 'args,', 'terminator'] - assert statement.terminator == ';' + assert statement.terminator == '&' assert statement.suffix == 'sufx' assert statement.pipe_to == 'piped' @@ -251,13 +258,16 @@ def test_parse_unfinished_multiliine_command(parser): assert statement.argv == ['multiline', 'has', '>', 'inside', 'an', 'unfinished', 'command'] assert not statement.terminator -def test_parse_multiline_command_ignores_redirectors_within_it(parser): - line = 'multiline has > inside;' +@pytest.mark.parametrize('line,terminator',[ + ('multiline has > inside;', ';'), + ('multiline has > inside &', '&'), +]) +def test_parse_multiline_command_ignores_redirectors_within_it(parser, line, terminator): statement = parser.parse(line) assert statement.multiline_command == 'multiline' assert statement.args == 'has > inside' assert statement.argv == ['multiline', 'has', '>', 'inside'] - assert statement.terminator == ';' + assert statement.terminator == terminator def test_parse_multiline_with_incomplete_comment(parser): """A terminator within a comment will be ignored and won't terminate a multiline command. -- cgit v1.2.1 From f5f0c90aa44ec658b33da422c4f0dc1cea2e6b98 Mon Sep 17 00:00:00 2001 From: kotfu Date: Mon, 7 May 2018 21:01:56 -0600 Subject: Make alias checking and command parsing use the same regex MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provide a new is_valid_command() method on StatementParser to determine whether a string of characters could be a valid command. That means it can’t include any redirection, quote chars, whitespace, or terminator characters. This method is used when someone tries to create an alias, to ensure when we try and parse the alias that it will actually parse. This nicely encapsulates and standardizes all the logic for parsing and expansion into the StatementParser class. Also fix a bug in the regex to match valid command names, and add a bunch of new unit tests to ensure the bug stays fixed. --- tests/test_parsing.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests/test_parsing.py') diff --git a/tests/test_parsing.py b/tests/test_parsing.py index ad4d31cd..bfb55b23 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -439,3 +439,27 @@ def test_parse_command_only_quoted_args(parser): assert statement.command == 'shell' assert statement.args == 'ls -al "/tmp/directory with spaces/doit.sh"' assert statement.command_and_args == line.replace('l', 'shell ls -al') + +@pytest.mark.parametrize('line', [ + 'helpalias > out.txt', + 'helpalias>out.txt', + 'helpalias >> out.txt', + 'helpalias>>out.txt', + 'help|less', + 'helpalias;', +]) +def test_parse_command_only_specialchars(parser, line): + statement = parser.parse_command_only(line) + assert statement.command == 'help' + +@pytest.mark.parametrize('line', [ + ';', + '>', + "'", + '"', + '|', +]) +def test_parse_command_only_none(parser, line): + statement = parser.parse_command_only(line) + assert statement.command == None + assert statement.args == None -- cgit v1.2.1 From ce5092fd9c2e23baa0952aac665e7c26ed85a03a Mon Sep 17 00:00:00 2001 From: kotfu Date: Thu, 10 May 2018 11:11:40 -0600 Subject: Remove cmd2.Cmd.redirector for #381 --- tests/test_parsing.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'tests/test_parsing.py') diff --git a/tests/test_parsing.py b/tests/test_parsing.py index bfb55b23..41966c71 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -159,7 +159,7 @@ def test_parse_simple_pipe(parser, line): assert statement.command == 'simple' assert not statement.args assert statement.argv == ['simple'] - assert statement.pipe_to == 'piped' + assert statement.pipe_to == ['piped'] def test_parse_double_pipe_is_not_a_pipe(parser): line = 'double-pipe || is not a pipe' @@ -177,7 +177,7 @@ def test_parse_complex_pipe(parser): assert statement.argv == ['command', 'with', 'args,', 'terminator'] assert statement.terminator == '&' assert statement.suffix == 'sufx' - assert statement.pipe_to == 'piped' + assert statement.pipe_to == ['piped'] @pytest.mark.parametrize('line,output', [ ('help > out.txt', '>'), @@ -227,9 +227,9 @@ def test_parse_pipe_and_redirect(parser): assert statement.argv == ['output', 'into'] assert statement.terminator == ';' assert statement.suffix == 'sufx' - assert statement.pipe_to == 'pipethrume plz' - assert statement.output == '>' - assert statement.output_to == 'afile.txt' + assert statement.pipe_to == ['pipethrume', 'plz', '>', 'afile.txt'] + assert not statement.output + assert not statement.output_to def test_parse_output_to_paste_buffer(parser): line = 'output to paste buffer >> ' @@ -240,8 +240,9 @@ def test_parse_output_to_paste_buffer(parser): assert statement.output == '>>' def test_parse_redirect_inside_terminator(parser): - """The terminator designates the end of the commmand/arguments portion. If a redirector - occurs before a terminator, then it will be treated as part of the arguments and not as a redirector.""" + """The terminator designates the end of the commmand/arguments portion. + If a redirector occurs before a terminator, then it will be treated as + part of the arguments and not as a redirector.""" line = 'has > inside;' statement = parser.parse(line) assert statement.command == 'has' @@ -385,7 +386,7 @@ def test_parse_alias_pipe(parser, line): statement = parser.parse(line) assert statement.command == 'help' assert not statement.args - assert statement.pipe_to == 'less' + assert statement.pipe_to == ['less'] def test_parse_alias_terminator_no_whitespace(parser): line = 'helpalias;' -- cgit v1.2.1 From 5c1c427bbe724d1ad002c86c097a6d25ca73909c Mon Sep 17 00:00:00 2001 From: kotfu Date: Wed, 16 May 2018 10:19:55 -0600 Subject: Add unit tests to check for multiple terminators --- tests/test_parsing.py | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'tests/test_parsing.py') diff --git a/tests/test_parsing.py b/tests/test_parsing.py index 41966c71..d147c6a1 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -250,6 +250,23 @@ def test_parse_redirect_inside_terminator(parser): assert statement.argv == ['has', '>', 'inside'] assert statement.terminator == ';' +@pytest.mark.parametrize('line,terminator',[ + ('multiline with | inside;', ';'), + ('multiline with | inside ;', ';'), + ('multiline with | inside;;;', ';'), + ('multiline with | inside;; ;;', ';'), + ('multiline with | inside&', '&'), + ('multiline with | inside &;', '&'), + ('multiline with | inside&&;', '&'), + ('multiline with | inside &; &;', '&'), +]) +def test_parse_multiple_terminators(parser, line, terminator): + statement = parser.parse(line) + assert statement.multiline_command == 'multiline' + assert statement.args == 'has | inside' + assert statement.argv == ['multiline', 'has', '|', 'inside'] + assert statement.terminator == terminator + def test_parse_unfinished_multiliine_command(parser): line = 'multiline has > inside an unfinished command' statement = parser.parse(line) @@ -261,7 +278,10 @@ def test_parse_unfinished_multiliine_command(parser): @pytest.mark.parametrize('line,terminator',[ ('multiline has > inside;', ';'), + ('multiline has > inside;;;', ';'), + ('multiline has > inside;; ;;', ';'), ('multiline has > inside &', '&'), + ('multiline has > inside & &', '&'), ]) def test_parse_multiline_command_ignores_redirectors_within_it(parser, line, terminator): statement = parser.parse(line) @@ -388,8 +408,15 @@ def test_parse_alias_pipe(parser, line): assert not statement.args assert statement.pipe_to == ['less'] -def test_parse_alias_terminator_no_whitespace(parser): - line = 'helpalias;' +@pytest.mark.parametrize('line', [ + 'helpalias;', + 'helpalias;;', + 'helpalias;; ;', + 'helpalias ;', + 'helpalias ; ;', + 'helpalias ;; ;', +]) +def test_parse_alias_terminator_no_whitespace(parser, line): statement = parser.parse(line) assert statement.command == 'help' assert not statement.args @@ -448,6 +475,8 @@ def test_parse_command_only_quoted_args(parser): 'helpalias>>out.txt', 'help|less', 'helpalias;', + 'help ;;', + 'help; ;;', ]) def test_parse_command_only_specialchars(parser, line): statement = parser.parse_command_only(line) @@ -455,6 +484,11 @@ def test_parse_command_only_specialchars(parser, line): @pytest.mark.parametrize('line', [ ';', + ';;', + ';; ;', + '&', + '& &', + ' && &', '>', "'", '"', -- cgit v1.2.1 From 490c8424c9be872538a5130734f120d0a34fdcaf Mon Sep 17 00:00:00 2001 From: kotfu Date: Thu, 17 May 2018 10:04:47 -0600 Subject: Fix bug in sequential terminator logic --- tests/test_parsing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/test_parsing.py') diff --git a/tests/test_parsing.py b/tests/test_parsing.py index d147c6a1..7b361b7e 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -263,8 +263,8 @@ def test_parse_redirect_inside_terminator(parser): def test_parse_multiple_terminators(parser, line, terminator): statement = parser.parse(line) assert statement.multiline_command == 'multiline' - assert statement.args == 'has | inside' - assert statement.argv == ['multiline', 'has', '|', 'inside'] + assert statement.args == 'with | inside' + assert statement.argv == ['multiline', 'with', '|', 'inside'] assert statement.terminator == terminator def test_parse_unfinished_multiliine_command(parser): -- cgit v1.2.1