diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-10-07 12:25:35 +0200 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-10-07 12:25:35 +0200 |
| commit | 2a93ed69f7ee88c26b1edfb1f58a8f4d6d842bd4 (patch) | |
| tree | e2ca0048b77c333bcaa4cb31c87c1af851520a8c /src | |
| parent | 06f6eeee3a7aaea881d7b399454762f65c8cec87 (diff) | |
| download | minishell_test-2a93ed69f7ee88c26b1edfb1f58a8f4d6d842bd4.tar.gz minishell_test-2a93ed69f7ee88c26b1edfb1f58a8f4d6d842bd4.tar.bz2 minishell_test-2a93ed69f7ee88c26b1edfb1f58a8f4d6d842bd4.zip | |
Removing cursed cd test
Diffstat (limited to 'src')
| -rwxr-xr-x | src/main.py | 4 | ||||
| -rw-r--r-- | src/suite/suite.py | 9 | ||||
| -rw-r--r-- | src/suites/builtin.py | 7 | ||||
| -rw-r--r-- | src/suites/flow.py | 86 | ||||
| -rw-r--r-- | src/suites/path.py | 4 |
5 files changed, 58 insertions, 52 deletions
diff --git a/src/main.py b/src/main.py index 2ed2e00..e9d83f4 100755 --- a/src/main.py +++ b/src/main.py @@ -36,11 +36,11 @@ def main(): if config.MINISHELL_MAKE or args.make: try: - print("========================================MAKE====================================") + print("{:=^{width}}".format("MAKE", width=config.TERM_COLS)) subprocess.run(["make", "--no-print-directory", "-C", config.MINISHELL_DIR], check=True, env={"MINISHELL_TEST_FLAGS": "-DMINISHELL_TEST", **os.environ}) - print("================================================================================") + print("=" * config.TERM_COLS) except subprocess.CalledProcessError: sys.exit(1) if args.make: diff --git a/src/suite/suite.py b/src/suite/suite.py index 91cfaa4..61f1cbc 100644 --- a/src/suite/suite.py +++ b/src/suite/suite.py @@ -6,7 +6,7 @@ # By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 18:24:29 by charles #+# #+# # -# Updated: 2020/10/06 17:04:25 by cacharle ### ########.fr # +# Updated: 2020/10/06 17:10:43 by cacharle ### ########.fr # # # # ############################################################################ # @@ -94,12 +94,11 @@ class Suite: if config.VERBOSE_LEVEL == 0: print(self.name + ": ", end="") else: - print("{}{} {:#<{width}}{}".format( + print("{}{:#^{width}}{}".format( self.BLUE_CHARS, - "#" * (config.TERM_COLS // 2 - 1), - self.name + " ", + " " + self.name + " ", self.CLOSE_CHARS, - width=config.TERM_COLS // 2 + width=config.TERM_COLS )) for t in self.tests: t.run() diff --git a/src/suites/builtin.py b/src/suites/builtin.py index 6788553..e90b798 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/10/07 08:20:48 by charles ### ########.fr # +# Updated: 2020/10/07 11:56:46 by cacharle ### ########.fr # # Updated: 2020/09/11 18:01:27 by juligonz ### ########.fr # # # # **************************************************************************** # @@ -123,7 +123,9 @@ def suite_cd(test): test("cd ../../../../..; pwd; echo $PWD") test("cd ../../../../../..; pwd; echo $PWD") test("cd /; pwd; echo $PWD") - test("cd /etc; pwd; echo $PWD") + # /etc is a link to /etc/private + # hard and weird to implement with pwd + # test("cd /etc; pwd; echo $PWD") test("cd ''; pwd; echo $PWD") test("cd '' ''; pwd; echo $PWD") test("cd '' '' ''; pwd; echo $PWD") @@ -244,6 +246,7 @@ def suite_pwd(test): test("pwd", setup="cd /") test("pwd", setup="cd $HOME") test("pwd | cat -e") + test("pwd", exports={"PWD": "/etc"}) # test("cd lnk; rmdir ../d; pwd", setup="mkdir d; ln -s d lnk") diff --git a/src/suites/flow.py b/src/suites/flow.py index 64eda86..d1b70d7 100644 --- a/src/suites/flow.py +++ b/src/suites/flow.py @@ -6,12 +6,12 @@ # By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 18:24:52 by charles #+# #+# # -# Updated: 2020/10/07 08:23:50 by charles ### ########.fr # +# Updated: 2020/10/07 11:59:21 by cacharle ### ########.fr # # # # ############################################################################ # from suite import suite -import hooks +from hooks import error_line0, platform_status, discard, replace_double_semi_colon @suite() @@ -23,9 +23,9 @@ def suite_end(test): test("echo; ") test("echo ; ") test("echo ;") - 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=error_line0, hook_status=platform_status(2, 1)) + test(" ;echo", hook=error_line0, hook_status=platform_status(2, 1)) + test(" ; echo", hook=error_line0, hook_status=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, 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("echo a ; ;", hook=error_line0, hook_status=platform_status(2, 1)) + test("echo a ; ;", hook=error_line0, hook_status=platform_status(2, 1)) + test(";", hook=error_line0, hook_status=platform_status(2, 1)) + test("; ;", hook=error_line0, hook_status=platform_status(2, 1)) + test("; ; ;", hook=error_line0, hook_status=platform_status(2, 1)) + test("echo a ; ; echo b", hook=error_line0, hook_status=platform_status(2, 1)) + test(";;", hook=[error_line0, replace_double_semi_colon], hook_status=platform_status(2, 1)) + test(";;;", hook=[error_line0, replace_double_semi_colon], hook_status=platform_status(2, 1)) + test(";;;;;", hook=[error_line0, replace_double_semi_colon], hook_status=platform_status(2, 1)) + test("echo a ;; echo b", hook=[error_line0, replace_double_semi_colon], hook_status=platform_status(2, 1)) + test("echo a ;;;;; echo b", hook=[error_line0, replace_double_semi_colon], hook_status=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") @@ -58,9 +58,9 @@ def suite_pipe(test): test("cat -e /etc/shells | head -c 10") test("cat -e /etc/shells | cat -e | head -c 10") test("cat -e /etc/shells | cat -e | cat -e | head -c 10") - test("cat -e /dev/random | head -c 10", hook=hooks.discard) - test("cat -e /dev/random | cat -e | head -c 10", hook=hooks.discard) - test("cat -e /dev/random | cat -e | cat -e | head -c 10", hook=hooks.discard) + test("cat -e /dev/random | head -c 10", hook=discard) + test("cat -e /dev/random | cat -e | head -c 10", hook=discard) + test("cat -e /dev/random | cat -e | cat -e | head -c 10", hook=discard) test("echo bonjour | cat") test("echo bonjour | cat -e") test("echo bonjour | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e") @@ -69,22 +69,26 @@ 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, 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|", hook=discard, hook_status=platform_status(2, 1)) + test("echo |", hook=discard, hook_status=platform_status(2, 1)) + test("echo | ", hook=discard, hook_status=platform_status(2, 1)) + test("|cat", hook=error_line0, hook_status=platform_status(2, 1)) + test("| cat", hook=error_line0, hook_status=platform_status(2, 1)) + test(" | cat", hook=error_line0, hook_status=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, hook_status=hooks.platform_status(2, 1)) + test("echo bonjour | | cat -e", hook=error_line0, hook_status=platform_status(2, 1)) test("echo bonjour | asdf") test("asdf | echo bonjour") - test("echo a ||| echo b", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) + test("echo a ||| echo b", hook=error_line0, hook_status=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") test("echo bonjour " + 80 * " | cat -e") + test("ls asdfasdf | echo a") + test("echo a | ls asdfasdf") + test("ls asdfasdf | echo a; echo b") + test("echo a | ls asdfasdf; echo b") @suite(bonus=True) @@ -92,13 +96,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, 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 bonjour&&", hook=discard, hook_status=platform_status(2, 1)) + test("echo&& ", hook=discard, hook_status=platform_status(2, 1)) + test("echo && ", hook=discard, hook_status=platform_status(2, 1)) + test("echo &&", hook=discard, hook_status=platform_status(2, 1)) + test("&&echo", hook=error_line0, hook_status=platform_status(2, 1)) + test("&& echo", hook=error_line0, hook_status=platform_status(2, 1)) + test(" && echo", hook=error_line0, hook_status=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 +121,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, 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 bonjour||", hook=discard, hook_status=platform_status(2, 1)) + test("echo|| ", hook=discard, hook_status=platform_status(2, 1)) + test("echo || ", hook=discard, hook_status=platform_status(2, 1)) + test("echo ||", hook=discard, hook_status=platform_status(2, 1)) + test("||echo", hook=error_line0, hook_status=platform_status(2, 1)) + test("|| echo", hook=error_line0, hook_status=platform_status(2, 1)) + test(" || echo", hook=error_line0, hook_status=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/path.py b/src/suites/path.py index 21085b3..3bf38c6 100644 --- a/src/suites/path.py +++ b/src/suites/path.py @@ -6,7 +6,7 @@ # By: charles <me@cacharle.xyz> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/09/09 15:12:58 by charles #+# #+# # -# Updated: 2020/09/28 10:49:12 by cacharle ### ########.fr # +# Updated: 2020/10/07 11:12:56 by cacharle ### ########.fr # # # # ############################################################################ # @@ -76,7 +76,7 @@ def suite_path(test): @suite() -def suites_path_variable(test): +def suite_path_variable(test): test("echo $PATH", exports={"PATH": "doesnotexits"}) test("echo $PATH", exports={"PATH": "doesnotexits:asdfasdfas"}) test("echo $PATH", exports={"PATH": "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:w:x:y:z"}) |
