aboutsummaryrefslogtreecommitdiff
path: root/src/suites
diff options
context:
space:
mode:
Diffstat (limited to 'src/suites')
-rw-r--r--src/suites/builtin.py7
-rw-r--r--src/suites/flow.py86
-rw-r--r--src/suites/path.py4
3 files changed, 52 insertions, 45 deletions
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"})