From 93ead396473526e5f4849ad2f4194b8cc6c9ce45 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Thu, 8 Oct 2020 17:04:32 +0200 Subject: Added flow syntax error tests --- src/args.py | 7 +++- src/suites/flow.py | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 109 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/args.py b/src/args.py index 5536ff5..7d1f260 100644 --- a/src/args.py +++ b/src/args.py @@ -6,7 +6,7 @@ # By: charles +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 18:24:32 by charles #+# #+# # -# Updated: 2020/10/08 09:02:52 by cacharle ### ########.fr # +# Updated: 2020/10/08 16:29:25 by cacharle ### ########.fr # # # # ############################################################################ # @@ -16,7 +16,10 @@ import argparse def parse_args(): """Parse command line arguments""" - parser = argparse.ArgumentParser(description="Minishell test") + parser = argparse.ArgumentParser( + description="Minishell test", + epilog="Signal handling is not tested" + ) parser.add_argument( "-k", "--check-leaks", action="store_true", help="Run valgrind on tests (disable usual comparison with bash)" diff --git a/src/suites/flow.py b/src/suites/flow.py index bcee31e..eac9459 100644 --- a/src/suites/flow.py +++ b/src/suites/flow.py @@ -6,10 +6,11 @@ # By: charles +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 18:24:52 by charles #+# #+# # -# Updated: 2020/10/08 08:40:56 by cacharle ### ########.fr # +# Updated: 2020/10/08 16:45:19 by cacharle ### ########.fr # # # # ############################################################################ # +import config from suite import suite from hooks import error_line0, platform_status, discard, replace_double_semi_colon @@ -202,3 +203,105 @@ def suite_parenthesis(test): test("( echo salut && echo bonjours ) ; echo comment ca va") test("(cd /; echo $PWD; pwd); echo $PWD; pwd") test("(export A=a; echo $A); echo $A") + + +@suite() +def suite_syntax_error(test): + """ separator syntax error test """ + test("< |", hook=error_line0) + test("> |", hook=error_line0) + test(">> |", hook=error_line0) + test("< ;", hook=error_line0) + test("> ;", hook=error_line0) + test(">> ;", hook=error_line0) + test("; |", hook=error_line0) + test("; |", hook=error_line0) + test("; |", hook=error_line0) + test("; <", hook=error_line0) + test("; >", hook=error_line0) + test("; >>", hook=error_line0) + test("| ;", hook=error_line0) + test("| ;", hook=error_line0) + test("| ;", hook=error_line0) + test("| <", hook=error_line0) + test("| >", hook=error_line0) + test("| >>", hook=error_line0) + test("> a ;", hook=error_line0) + test("< a ;", hook=error_line0) + test(">> a ;", hook=error_line0) + test(config.LOREM + " > >" + config.LOREM, hook=error_line0) + test(config.LOREM + " < <" + config.LOREM, hook=error_line0) + test(config.LOREM + " ; |" + config.LOREM, hook=error_line0) + test(config.LOREM + " | ;" + config.LOREM, hook=error_line0) + + +@suite(bonus=True) +def suite_syntax_error_bonus(test): + """ separator syntax error bonus test """ + test("< &&", hook=error_line0) + test("> &&", hook=error_line0) + test(">> &&", hook=error_line0) + test("< ||", hook=error_line0) + test("> ||", hook=error_line0) + test(">> ||", hook=error_line0) + test("< (", hook=error_line0) + test("> (", hook=error_line0) + test(">> (", hook=error_line0) + test("< )", hook=error_line0) + test("> )", hook=error_line0) + test(">> )", hook=error_line0) + test("&& <", hook=error_line0) + test("&& >", hook=error_line0) + test("&& >>", hook=error_line0) + test("&& ||", hook=error_line0) + test("&& ||", hook=error_line0) + test("&& ||", hook=error_line0) + test("&& (", hook=error_line0) + test("&& (", hook=error_line0) + test("&& (", hook=error_line0) + test("&& )", hook=error_line0) + test("&& )", hook=error_line0) + test("&& )", hook=error_line0) + test("|| <", hook=error_line0) + test("|| >", hook=error_line0) + test("|| >>", hook=error_line0) + test("|| &&", hook=error_line0) + test("|| &&", hook=error_line0) + test("|| &&", hook=error_line0) + test("|| (", hook=error_line0) + test("|| (", hook=error_line0) + test("|| (", hook=error_line0) + test("|| )", hook=error_line0) + test("|| )", hook=error_line0) + test("|| )", hook=error_line0) + test("( <", hook=error_line0) + test("( >", hook=error_line0) + test("( >>", hook=error_line0) + test("( &&", hook=error_line0) + test("( &&", hook=error_line0) + test("( &&", hook=error_line0) + test("( ||", hook=error_line0) + test("( ||", hook=error_line0) + test("( ||", hook=error_line0) + test("( )", hook=error_line0) + test("( )", hook=error_line0) + test("( )", hook=error_line0) + test(") <", hook=error_line0) + test(") >", hook=error_line0) + test(") >>", hook=error_line0) + test(") &&", hook=error_line0) + test(") &&", hook=error_line0) + test(") &&", hook=error_line0) + test(") ||", hook=error_line0) + test(") ||", hook=error_line0) + test(") ||", hook=error_line0) + test(") (", hook=error_line0) + test(") (", hook=error_line0) + test(") (", hook=error_line0) + test("()", hook=error_line0) + test("(", hook=[error_line0, lambda o: o.replace("-c: line 1: ", "")]) + test(")", hook=error_line0) + test(config.LOREM + " && &&" + config.LOREM, hook=error_line0) + test(config.LOREM + " || ||" + config.LOREM, hook=error_line0) + test(config.LOREM + " ( (" + config.LOREM, hook=error_line0) + test(config.LOREM + " ) )" + config.LOREM, hook=error_line0) -- cgit