diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-10-07 08:29:32 +0200 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-10-07 08:32:55 +0200 |
| commit | 06f6eeee3a7aaea881d7b399454762f65c8cec87 (patch) | |
| tree | 5fcdf9a6283d61069c1226c4876c99af0da2ab83 /src | |
| parent | 058491e35baa8bc73e14b48ceb765a3fe3c07e1f (diff) | |
| download | minishell_test-06f6eeee3a7aaea881d7b399454762f65c8cec87.tar.gz minishell_test-06f6eeee3a7aaea881d7b399454762f65c8cec87.tar.bz2 minishell_test-06f6eeee3a7aaea881d7b399454762f65c8cec87.zip | |
Added Linux exit status and output conversion to macos
Diffstat (limited to 'src')
| -rw-r--r-- | src/args.py | 7 | ||||
| -rw-r--r-- | src/config.py | 4 | ||||
| -rw-r--r-- | src/hooks.py | 36 | ||||
| -rwxr-xr-x | src/main.py | 2 | ||||
| -rw-r--r-- | src/suites/builtin.py | 72 | ||||
| -rw-r--r-- | src/suites/cmd.py | 72 | ||||
| -rw-r--r-- | src/suites/flow.py | 74 | ||||
| -rw-r--r-- | src/suites/preprocess.py | 22 | ||||
| -rw-r--r-- | src/test/test.py | 4 |
9 files changed, 160 insertions, 133 deletions
diff --git a/src/args.py b/src/args.py index a7dda05..9110073 100644 --- a/src/args.py +++ b/src/args.py @@ -6,7 +6,7 @@ # By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 18:24:32 by charles #+# #+# # -# Updated: 2020/09/13 14:45:15 by charles ### ########.fr # +# Updated: 2020/09/27 11:08:49 by charles ### ########.fr # # # # ############################################################################ # @@ -16,10 +16,7 @@ import argparse def parse_args(): """Parse command line arguments""" - parser = argparse.ArgumentParser( - description="Minishell test", - epilog="Make sure read the README.md" - ) + parser = argparse.ArgumentParser(description="Minishell test") parser.add_argument( "-v", "--verbose", action="count", help="Increase verbosity level (e.g -vv == 2)" diff --git a/src/config.py b/src/config.py index 0390194..e77a94d 100644 --- a/src/config.py +++ b/src/config.py @@ -6,7 +6,7 @@ # By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 18:24:19 by charles #+# #+# # -# Updated: 2020/10/06 17:06:17 by cacharle ### ########.fr # +# Updated: 2020/10/07 08:07:25 by charles ### ########.fr # # # # ############################################################################ # @@ -93,3 +93,5 @@ REFERENCE_ERROR_BEGIN = REFERENCE_PATH + ": line 0: " TERM_COLS = shutil.get_terminal_size().columns if TERM_COLS < 40: raise RuntimeError("You're terminal isn't wide enough") + +PLATFORM = os.uname().sysname diff --git a/src/hooks.py b/src/hooks.py index 01319d1..8439c0a 100644 --- a/src/hooks.py +++ b/src/hooks.py @@ -6,7 +6,7 @@ # By: charles <me@cacharle.xyz> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/09/11 16:10:20 by charles #+# #+# # -# Updated: 2020/10/06 09:12:52 by cacharle ### ########.fr # +# Updated: 2020/10/07 08:27:49 by charles ### ########.fr # # # # ############################################################################ # @@ -57,15 +57,41 @@ def replace_double_semi_colon(output): return output.replace(";;", ";") -def platform_exit_status(darwin_status, linux_status, windows_status=None): +def platform_status(darwin_status, linux_status, windows_status=None): def hook(status): - name = os.uname().sysname - if name == "Darwin": + if config.PLATFORM == "Darwin": return status - elif name == "Linux": + elif config.PLATFORM == "Linux": return (darwin_status if status == linux_status else status) else: raise RuntimeError("This platform exit codes are not supported yet," "feel free to contact me to add it.") sys.exit(2) return status + return hook + + +def is_directory(output): + if config.PLATFORM == "Linux": + return output.replace("Is a directory", "is a directory") + else: + return output + + +# def no_cd_too_many_arguments(output): +# for i, line in output.split("\n"): +# if line.find("too many arguments") + + +def shlvl_0_to_1(output): + if config.PLATFORM == "Linux": + return output.replace("SHLVL=0", "SHLVL=1") + else: + return output + + +def delete_escape(output): + if config.PLATFORM == "Linux": + return output.replace("\\", "") + else: + return output diff --git a/src/main.py b/src/main.py index fcb228f..2ed2e00 100755 --- a/src/main.py +++ b/src/main.py @@ -37,7 +37,7 @@ def main(): if config.MINISHELL_MAKE or args.make: try: print("========================================MAKE====================================") - subprocess.run(["make", "-C", config.MINISHELL_DIR], + subprocess.run(["make", "--no-print-directory", "-C", config.MINISHELL_DIR], check=True, env={"MINISHELL_TEST_FLAGS": "-DMINISHELL_TEST", **os.environ}) print("================================================================================") diff --git a/src/suites/builtin.py b/src/suites/builtin.py index 3aecfb9..6788553 100644 --- a/src/suites/builtin.py +++ b/src/suites/builtin.py @@ -6,7 +6,7 @@ # By: juligonz <juligonz@student.42.fr> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 18:24:43 by charles #+# #+# # -# Updated: 2020/09/15 17:29:35 by charles ### ########.fr # +# Updated: 2020/10/07 08:20:48 by charles ### ########.fr # # Updated: 2020/09/11 18:01:27 by juligonz ### ########.fr # # # # **************************************************************************** # @@ -249,10 +249,10 @@ def suite_pwd(test): @suite() def suite_env(test): - test("env", hook=hooks.sort_lines) - test("env", setup="export A=a", hook=hooks.sort_lines) - test("env", setup="export A=a B=b C=c", hook=hooks.sort_lines) - test("env | cat -e", setup="export A=a B=b C=c", hook=hooks.sort_lines) + test("env", hook=[hooks.sort_lines, hooks.shlvl_0_to_1]) + test("env", setup="export A=a", hook=[hooks.sort_lines, hooks.shlvl_0_to_1]) + test("env", setup="export A=a B=b C=c", hook=[hooks.sort_lines, hooks.shlvl_0_to_1]) + test("env | cat -e", setup="export A=a B=b C=c", hook=[hooks.sort_lines, hooks.shlvl_0_to_1]) @suite() @@ -266,10 +266,10 @@ def suite_exit(test): test("exit '\t\f\r 3'") test("exit '3 '") test("exit '3\t'") - test("exit '3\r'") - test("exit '3\t\f\r '") - test("exit '3 a'") - test("exit '3\t\t\ta'") + test("exit '3\r'", hook_status=hooks.platform_status(255, 2)) + test("exit '3\t\f\r '", hook_status=hooks.platform_status(255, 2)) + test("exit '3 a'", hook_status=hooks.platform_status(255, 2)) + test("exit '3\t\t\ta'", hook_status=hooks.platform_status(255, 2)) test("exit 0") test("exit -0") test("exit -1") @@ -287,10 +287,10 @@ def suite_exit(test): test("exit 4294967296") test("exit -9223372036854775808") test("exit 9223372036854775807") - test("exit -9223372036854775809") - test("exit 9223372036854775808") - test("exit 18446744073709551615") - test("exit 18446744073709551616") + test("exit -9223372036854775809", hook_status=hooks.platform_status(255, 2)) + test("exit 9223372036854775808", hook_status=hooks.platform_status(255, 2)) + test("exit 18446744073709551615", hook_status=hooks.platform_status(255, 2)) + test("exit 18446744073709551616", hook_status=hooks.platform_status(255, 2)) test("exit +1") test("exit +2") test("exit +3") @@ -299,25 +299,25 @@ def suite_exit(test): test("exit +256") test("exit +2000000") test("exit +2147483647") - test("exit ++1") - test("exit ++2") - test("exit ++3") - test("exit ++0") - test("exit ++255") - test("exit ++256") - test("exit ++2000000") - test("exit ++2147483647") - test("exit --1") - test("exit --2") - test("exit --3") - test("exit --0") - test("exit --255") - test("exit --256") - test("exit --2000000") - test("exit --2147483647") - test("exit bonjour") - test("exit 0_") - test("exit _0") + test("exit ++1", hook_status=hooks.platform_status(255, 2)) + test("exit ++2", hook_status=hooks.platform_status(255, 2)) + test("exit ++3", hook_status=hooks.platform_status(255, 2)) + test("exit ++0", hook_status=hooks.platform_status(255, 2)) + test("exit ++255", hook_status=hooks.platform_status(255, 2)) + test("exit ++256", hook_status=hooks.platform_status(255, 2)) + test("exit ++2000000", hook_status=hooks.platform_status(255, 2)) + test("exit ++2147483647", hook_status=hooks.platform_status(255, 2)) + test("exit --1", hook_status=hooks.platform_status(255, 2)) + test("exit --2", hook_status=hooks.platform_status(255, 2)) + test("exit --3", hook_status=hooks.platform_status(255, 2)) + test("exit --0", hook_status=hooks.platform_status(255, 2)) + test("exit --255", hook_status=hooks.platform_status(255, 2)) + test("exit --256", hook_status=hooks.platform_status(255, 2)) + test("exit --2000000", hook_status=hooks.platform_status(255, 2)) + test("exit --2147483647", hook_status=hooks.platform_status(255, 2)) + test("exit bonjour", hook_status=hooks.platform_status(255, 2)) + test("exit 0_", hook_status=hooks.platform_status(255, 2)) + test("exit _0", hook_status=hooks.platform_status(255, 2)) test("exit 0123456789") test("exit -0123456789") test("exit 00000000000000000000000000000000000000000000001") @@ -328,11 +328,11 @@ def suite_exit(test): test("exit -00000000000000000000000000000000000000000000000" "00000000000000000000000000000000000000000000001") test("exit -99999999999999999999999999999999999999999999" - "99999999999999999999999999999999999999999999") + "99999999999999999999999999999999999999999999", hook_status=hooks.platform_status(255, 2)) test("exit 99999999999999999999999999999999999999999999" - "99999999999999999999999999999999999999999999") + "99999999999999999999999999999999999999999999", hook_status=hooks.platform_status(255, 2)) test("exit 0 bonjour") - test("exit bonjour 0") + test("exit bonjour 0", hook_status=hooks.platform_status(255, 2)) test("exit 0 1") test("exit 0 1 2 3 4 5 6 7 8 9") - test("exit " + config.LOREM) + test("exit " + config.LOREM, hook_status=hooks.platform_status(255, 2)) diff --git a/src/suites/cmd.py b/src/suites/cmd.py index 196ed85..25ca49b 100644 --- a/src/suites/cmd.py +++ b/src/suites/cmd.py @@ -6,7 +6,7 @@ # By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 15:11:46 by charles #+# #+# # -# Updated: 2020/09/28 10:40:39 by cacharle ### ########.fr # +# Updated: 2020/10/07 08:11:04 by charles ### ########.fr # # # # ############################################################################ # @@ -67,21 +67,21 @@ def suite_redirection(test): files=["abcdefghijklmnopqrstuvwxyz"]) test("> file", files=["file"]) test("< file", setup="echo bonjour > file") - test(">", hook=hooks.error_line0) - test(">>", hook=hooks.error_line0) - test("<", hook=hooks.error_line0) - test("echo >", hook=hooks.error_line0) - test("echo >>", hook=hooks.error_line0) - test("echo <", hook=hooks.error_line0) + test(">", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) + test(">>", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) + test("<", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) + test("echo >", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) + test("echo >>", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) + test("echo <", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) test("> test", files=["test"]) test(">> test", files=["test"]) test("< test", setup="touch test") - test("echo foo >>> bar", hook=hooks.error_line0) - test("echo foo >>>> bar", hook=hooks.error_line0) - test("echo foo >>>>> bar", hook=hooks.error_line0) - test("cat << < bar", setup="echo bonjour > bar", hook=hooks.error_line0) - test("cat << << bar", setup="echo bonjour > bar", hook=hooks.error_line0) - test("cat <<<<< bar", setup="echo bonjour > bar", hook=hooks.error_line0) + test("echo foo >>> bar", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) + test("echo foo >>>> bar", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) + test("echo foo >>>>> bar", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) + test("cat << < bar", setup="echo bonjour > bar", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) + test("cat << << bar", setup="echo bonjour > bar", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) + test("cat <<<<< bar", setup="echo bonjour > bar", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) test("cat < doesnotexist") @@ -159,15 +159,15 @@ def suite_cmd_path(test): test("./somefile", setup="echo > somefile; chmod 111 somefile") test("./somefile", setup="echo > somefile; chmod 222 somefile") test("./somefile", setup="echo > somefile; chmod 333 somefile") - test("somedir/", setup="mkdir somedir") - test("./somedir/", setup="mkdir somedir") + test("somedir/", setup="mkdir somedir", hook=hooks.is_directory) + test("./somedir/", setup="mkdir somedir", hook=hooks.is_directory) test("somedir", setup="mkdir somedir") - test("./somedir", setup="mkdir somedir") + test("./somedir", setup="mkdir somedir", hook=hooks.is_directory) test("somedir", setup="mkdir somedir") - test("somedirsoftlink/", setup="mkdir somedir; ln -s somedir somedirsoftlink") - test("./somedirsoftlink/", setup="mkdir somedir; ln -s somedir somedirsoftlink") + test("somedirsoftlink/", setup="mkdir somedir; ln -s somedir somedirsoftlink", hook=hooks.is_directory) + test("./somedirsoftlink/", setup="mkdir somedir; ln -s somedir somedirsoftlink", hook=hooks.is_directory) test("somedirsoftlink", setup="mkdir somedir; ln -s somedir somedirsoftlink") - test("./somedirsoftlink", setup="mkdir somedir; ln -s somedir somedirsoftlink") + test("./somedirsoftlink", setup="mkdir somedir; ln -s somedir somedirsoftlink", hook=hooks.is_directory) test("somedirsoftlink", setup="mkdir somedir; ln -s somedir somedirsoftlink") test("./someremovedlink", setup="touch somefile; ln -s somefile someremovedlink; rm -f somefile") test("./somelink2", setup="touch somefile; ln -s somefile somelink1; ln -s somelink1 somelink2") @@ -187,8 +187,8 @@ def suite_cmd_path(test): test("'-'", setup="touch -") test("./_", setup="touch _") test("./-", setup="touch a; mv a ./-") - test("./.", setup="touch .") - test("./..", setup="touch ..") + test("./.", setup="touch .", hook=hooks.is_directory) + test("./..", setup="touch ..", hook=hooks.is_directory) test("./somefile", setup='echo > somefile && chmod 0777 somefile') test("./somefile", setup='echo > somefile && chmod 1000 somefile') test("./somefile", setup='echo > somefile && chmod 2000 somefile') @@ -205,21 +205,21 @@ def suite_cmd_path(test): test("./somefile", setup='echo > somefile && chmod 6777 somefile') test("./somefile", setup='echo > somefile && chmod 7777 somefile') test("./somefile", setup='echo > somefile && chmod 0000 somefile') - test("./somedir", setup='mkdir -m 0777 somedir') - test("./somedir", setup='mkdir -m 1000 somedir') - test("./somedir", setup='mkdir -m 2000 somedir') - test("./somedir", setup='mkdir -m 3000 somedir') - test("./somedir", setup='mkdir -m 4000 somedir') - test("./somedir", setup='mkdir -m 5000 somedir') - test("./somedir", setup='mkdir -m 6000 somedir') - test("./somedir", setup='mkdir -m 7000 somedir') - test("./somedir", setup='mkdir -m 1777 somedir') - test("./somedir", setup='mkdir -m 2777 somedir') - test("./somedir", setup='mkdir -m 3777 somedir') - test("./somedir", setup='mkdir -m 4777 somedir') - test("./somedir", setup='mkdir -m 5777 somedir') - test("./somedir", setup='mkdir -m 6777 somedir') - test("./somedir", setup='mkdir -m 0000 somedir') + test("./somedir", setup='mkdir -m 0777 somedir', hook=hooks.is_directory) + test("./somedir", setup='mkdir -m 1000 somedir', hook=hooks.is_directory) + test("./somedir", setup='mkdir -m 2000 somedir', hook=hooks.is_directory) + test("./somedir", setup='mkdir -m 3000 somedir', hook=hooks.is_directory) + test("./somedir", setup='mkdir -m 4000 somedir', hook=hooks.is_directory) + test("./somedir", setup='mkdir -m 5000 somedir', hook=hooks.is_directory) + test("./somedir", setup='mkdir -m 6000 somedir', hook=hooks.is_directory) + test("./somedir", setup='mkdir -m 7000 somedir', hook=hooks.is_directory) + test("./somedir", setup='mkdir -m 1777 somedir', hook=hooks.is_directory) + test("./somedir", setup='mkdir -m 2777 somedir', hook=hooks.is_directory) + test("./somedir", setup='mkdir -m 3777 somedir', hook=hooks.is_directory) + test("./somedir", setup='mkdir -m 4777 somedir', hook=hooks.is_directory) + test("./somedir", setup='mkdir -m 5777 somedir', hook=hooks.is_directory) + test("./somedir", setup='mkdir -m 6777 somedir', hook=hooks.is_directory) + test("./somedir", setup='mkdir -m 0000 somedir', hook=hooks.is_directory) # @suite(bonus=True) diff --git a/src/suites/flow.py b/src/suites/flow.py index 4f61283..64eda86 100644 --- a/src/suites/flow.py +++ b/src/suites/flow.py @@ -6,7 +6,7 @@ # By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 18:24:52 by charles #+# #+# # -# Updated: 2020/10/06 16:16:12 by cacharle ### ########.fr # +# Updated: 2020/10/07 08:23:50 by charles ### ########.fr # # # # ############################################################################ # @@ -23,9 +23,9 @@ def suite_end(test): test("echo; ") test("echo ; ") test("echo ;") - test("; echo", hook=hooks.error_line0) - test(" ;echo", hook=hooks.error_line0) - test(" ; echo", hook=hooks.error_line0) + test("; echo", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) + test(" ;echo", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) + test(" ; echo", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) test("echo a; echo b; echo c; echo d; echo e; echo f; echo g; echo h; echo i;" "echo j; echo k; echo l; echo m; echo c; echo c; echo c; echo c; echo c;" "echo c; echo c; echo c; echo v; echo w; echo x; echo y; echo z") @@ -35,17 +35,17 @@ def suite_end(test): test("ls doesnotexists ; echo bonjour") test("ls doesnotexists; echo bonjour") test("echo bonjour; ls doesnotexists") - test("echo a ; ;", hook=hooks.error_line0) - test("echo a ; ;", hook=hooks.error_line0) - test(";", hook=hooks.error_line0) - test("; ;", hook=hooks.error_line0) - test("; ; ;", hook=hooks.error_line0) - test("echo a ; ; echo b", hook=hooks.error_line0) - test(";;", hook=[hooks.error_line0, hooks.replace_double_semi_colon]) - test(";;;", hook=[hooks.error_line0, hooks.replace_double_semi_colon]) - test(";;;;;", hook=[hooks.error_line0, hooks.replace_double_semi_colon]) - test("echo a ;; echo b", hook=[hooks.error_line0, hooks.replace_double_semi_colon]) - test("echo a ;;;;; echo b", hook=[hooks.error_line0, hooks.replace_double_semi_colon]) + test("echo a ; ;", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) + test("echo a ; ;", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) + test(";", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) + test("; ;", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) + test("; ; ;", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) + test("echo a ; ; echo b", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) + test(";;", hook=[hooks.error_line0, hooks.replace_double_semi_colon], hook_status=hooks.platform_status(2, 1)) + test(";;;", hook=[hooks.error_line0, hooks.replace_double_semi_colon], hook_status=hooks.platform_status(2, 1)) + test(";;;;;", hook=[hooks.error_line0, hooks.replace_double_semi_colon], hook_status=hooks.platform_status(2, 1)) + test("echo a ;; echo b", hook=[hooks.error_line0, hooks.replace_double_semi_colon], hook_status=hooks.platform_status(2, 1)) + test("echo a ;;;;; echo b", hook=[hooks.error_line0, hooks.replace_double_semi_colon], hook_status=hooks.platform_status(2, 1)) test("ls " + 40 * " ; ls", setup="touch a b c") test("ls " + 80 * " ; ls", setup="touch a b c") test("ls " + 40 * " ; ls" + ";", setup="touch a b c") @@ -69,18 +69,18 @@ def suite_pipe(test): test("ls -l | cat -e | cat | cat | cat", setup="touch a b c d; mkdir m1 m2 m3") test("ls -l | cat -e | cat -e | cat -e | cat -e", setup="touch a b c d; mkdir m1 m2 m3") test("ls -l | cat -e < a", setup="touch a b c d; mkdir m1 m2 m3; echo bonjour > a") - test("echo|", hook=hooks.discard) - test("echo |", hook=hooks.discard) - test("echo | ", hook=hooks.discard) - test("|cat", hook=hooks.error_line0) - test("| cat", hook=hooks.error_line0) - test(" | cat", hook=hooks.error_line0) + test("echo|", hook=hooks.discard, hook_status=hooks.platform_status(2, 1)) + test("echo |", hook=hooks.discard, hook_status=hooks.platform_status(2, 1)) + test("echo | ", hook=hooks.discard, hook_status=hooks.platform_status(2, 1)) + test("|cat", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) + test("| cat", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) + test(" | cat", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) test("echo a | export A=a; echo $A") test("export A=a | cat; echo $A") - test("echo bonjour | | cat -e", hook=hooks.error_line0) + test("echo bonjour | | cat -e", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) test("echo bonjour | asdf") test("asdf | echo bonjour") - test("echo a ||| echo b", hook=hooks.error_line0) + test("echo a ||| echo b", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) test("ls " + 40 * " | ls", setup="touch a b c") test("ls " + 80 * " | ls", setup="touch a b c") test("echo bonjour " + 40 * " | cat -e") @@ -92,13 +92,13 @@ def suite_and(test): test("echo bonjour&& echo je") test("echo bonjour &&echo je") test("echo bonjour && echo je") - test("echo bonjour&&", hook=hooks.discard) - test("echo&& ", hook=hooks.discard) - test("echo && ", hook=hooks.discard) - test("echo &&", hook=hooks.discard) - test("&&echo", hook=hooks.error_line0) - test("&& echo", hook=hooks.error_line0) - test(" && echo", hook=hooks.error_line0) + test("echo bonjour&&", hook=hooks.discard, hook_status=hooks.platform_status(2, 1)) + test("echo&& ", hook=hooks.discard, hook_status=hooks.platform_status(2, 1)) + test("echo && ", hook=hooks.discard, hook_status=hooks.platform_status(2, 1)) + test("echo &&", hook=hooks.discard, hook_status=hooks.platform_status(2, 1)) + test("&&echo", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) + test("&& echo", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) + test(" && echo", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) test("echo a&& echo b&& echo c&& echo d&& echo e&& echo f&& echo g&& echo h&& echo i&&" "echo j&& echo k&& echo l&& echo m&& echo c&& echo c&& echo c&& echo c&& echo c&&" "echo c&& echo c&& echo c&& echo v&& echo w&& echo x&& echo y&& echo z") @@ -117,13 +117,13 @@ def suite_or(test): test("echo bonjour|| echo je") test("echo bonjour ||echo je") test("echo bonjour || echo je") - test("echo bonjour||", hook=hooks.discard) - test("echo|| ", hook=hooks.discard) - test("echo || ", hook=hooks.discard) - test("echo ||", hook=hooks.discard) - test("||echo", hook=hooks.error_line0) - test("|| echo", hook=hooks.error_line0) - test(" || echo", hook=hooks.error_line0) + test("echo bonjour||", hook=hooks.discard, hook_status=hooks.platform_status(2, 1)) + test("echo|| ", hook=hooks.discard, hook_status=hooks.platform_status(2, 1)) + test("echo || ", hook=hooks.discard, hook_status=hooks.platform_status(2, 1)) + test("echo ||", hook=hooks.discard, hook_status=hooks.platform_status(2, 1)) + test("||echo", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) + test("|| echo", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) + test(" || echo", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) test("echo a|| echo b|| echo c|| echo d|| echo e|| echo f|| echo g|| echo h|| echo i||" "echo j|| echo k|| echo l|| echo m|| echo c|| echo c|| echo c|| echo c|| echo c||" "echo c|| echo c|| echo c|| echo v|| echo w|| echo x|| echo y|| echo z") diff --git a/src/suites/preprocess.py b/src/suites/preprocess.py index fde8cc5..506cb32 100644 --- a/src/suites/preprocess.py +++ b/src/suites/preprocess.py @@ -6,7 +6,7 @@ # By: juligonz <juligonz@student.42.fr> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 18:25:00 by charles #+# #+# # -# Updated: 2020/10/06 16:31:11 by cacharle ### ########.fr # +# Updated: 2020/10/07 08:27:57 by charles ### ########.fr # # # # **************************************************************************** # @@ -55,18 +55,18 @@ def suite_quote(test): test("echo '\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"'") test('echo "\'"') test('echo "\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'"') - test("echo '", hook=hooks.error_line0) - test('echo "', hook=hooks.error_line0) - test("echo '''", hook=hooks.error_line0) - test('echo """', hook=hooks.error_line0) - test("echo '''''''''''''''''''''''''''''''''''''''''''", hook=hooks.error_line0) - test('echo """""""""""""""""""""""""""""""""""""""""""', hook=hooks.error_line0) + test("echo '", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) + test('echo "', hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) + test("echo '''", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) + test('echo """', hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) + test("echo '''''''''''''''''''''''''''''''''''''''''''", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) + test('echo """""""""""""""""""""""""""""""""""""""""""', hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) test("echo 'AH\\'") - test('echo "AH\\"', hook=hooks.error_line0) + test('echo "AH\\"', hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) test('echo "AH\\""') - test("echo '\\''", hook=hooks.error_line0) + test("echo '\\''", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) test('echo "\\""') - test('echo "\\\\""', hook=hooks.error_line0) + test('echo "\\\\""', hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) @suite() @@ -217,7 +217,7 @@ def suite_escape(test): test(r"/bin/echo ' \$? '") test(r"/bin/echo ' \\ '") test(r"/bin/echo ' \\\ '") - test("echo \\") # noting on linux + test("echo \\", hook=hooks.delete_escape) test("echo \"\\\"\"'bonjour'") diff --git a/src/test/test.py b/src/test/test.py index da013d1..c4e183c 100644 --- a/src/test/test.py +++ b/src/test/test.py @@ -6,7 +6,7 @@ # By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/06/16 21:48:50 by charles #+# #+# # -# Updated: 2020/10/06 15:54:12 by cacharle ### ########.fr # +# Updated: 2020/10/07 08:12:00 by charles ### ########.fr # # # # ############################################################################ # @@ -52,6 +52,8 @@ class Test: self.hook_status = hook_status if type(self.hook) is not list: self.hook = [self.hook] + if type(self.hook_status) is not list: + self.hook_status = [self.hook_status] def run(self): """ Run the test for minishell and the reference shell and print the result out """ |
