aboutsummaryrefslogtreecommitdiff
path: root/src/suites
diff options
context:
space:
mode:
Diffstat (limited to 'src/suites')
-rw-r--r--src/suites/__init__.py4
-rw-r--r--src/suites/builtin.py14
-rw-r--r--src/suites/cmd.py20
-rw-r--r--src/suites/operation.py54
-rw-r--r--src/suites/parenthesis.py4
-rw-r--r--src/suites/path.py2
-rw-r--r--src/suites/preprocess.py40
-rw-r--r--src/suites/status.py2
8 files changed, 66 insertions, 74 deletions
diff --git a/src/suites/__init__.py b/src/suites/__init__.py
index 68bad1f..b6b3b68 100644
--- a/src/suites/__init__.py
+++ b/src/suites/__init__.py
@@ -6,7 +6,7 @@
# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/07/15 18:24:48 by charles #+# #+# #
-# Updated: 2020/09/09 15:20:22 by charles ### ########.fr #
+# Updated: 2020/09/11 13:25:26 by charles ### ########.fr #
# #
# ############################################################################ #
@@ -15,5 +15,3 @@ import glob
modules = glob.glob(os.path.join(os.path.dirname(__file__), "*.py"))
__all__ = [os.path.basename(f)[:-3] for f in modules if os.path.isfile(f) and not f.endswith("__init__.py")]
-
-# print(__all__)
diff --git a/src/suites/builtin.py b/src/suites/builtin.py
index 30297e0..da146e0 100644
--- a/src/suites/builtin.py
+++ b/src/suites/builtin.py
@@ -15,7 +15,7 @@ import os
import config
from suite import suite
-@suite
+@suite()
def suite_echo(test):
test("echo")
test("echo bonjour")
@@ -40,7 +40,7 @@ def suite_echo(test):
test('echo -n a "" b "" c "" d')
test("echo '' '' ''")
-@suite
+@suite()
def suite_export(test):
test("export")
# test("export A=; env | grep A=; echo $A")
@@ -90,7 +90,7 @@ def suite_export(test):
test("export $TEST", exports={"TEST": "A=a"})
-@suite
+@suite()
def suite_cd(test):
test("cd .; pwd; echo $PWD");
test("cd ..; pwd; echo $PWD");
@@ -182,7 +182,7 @@ def suite_cd(test):
test("cd d", setup="mkdir -m 7777 d")
test("cd d", setup="mkdir -m 0000 d")
-@suite
+@suite()
def suite_unset(test):
test("unset")
test("unset A; echo $A", setup="export A=a")
@@ -207,7 +207,7 @@ def suite_unset(test):
setup="export A=a B=b C=c")
test("unset A", setup="export A=a B=b C=c")
-@suite
+@suite()
def suite_pwd(test):
test("pwd")
test("pwd", setup="cd ..")
@@ -218,14 +218,14 @@ def suite_pwd(test):
test("pwd | cat -e")
test("cd lnk; rmdir ../d; pwd", setup="mkdir d; ln -s d lnk")
-@suite
+@suite()
def suite_env(test):
test("env") # TODO ordering doesn't mater flag
test("env", setup="export A=a")
test("env", setup="export A=a B=b C=c")
test("env | cat -e", setup="export A=a B=b C=c")
-@suite
+@suite()
def suite_exit(test):
test("exit")
test("exit 1")
diff --git a/src/suites/cmd.py b/src/suites/cmd.py
index 1302ae3..4fc5f55 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/10 14:25:40 by charles ### ########.fr #
+# Updated: 2020/09/11 14:25:04 by charles ### ########.fr #
# #
# ############################################################################ #
@@ -16,7 +16,7 @@ import config
from suite import suite
-@suite
+@suite()
def suite_redirection(test):
test("echo bonjour > test", setup="", files=["test"])
test("echo > test bonjour", setup="", files=["test"])
@@ -96,9 +96,10 @@ def suite_redirection(test):
test("cat < doesnotexist")
-
-@suite
-def suite_edgecases(test):
+@suite()
+def suite_cmd(test):
+ test("notfound")
+ test("notfound a b c")
test('echo "\\"" >>a"b""c" ', files=["abc"])
test("echo " + ''.join([chr(i) for i in range(1, 127) if chr(i) not in '\n`"\'()|&><']))
test("echo foo>bar", files=["bar"])
@@ -106,12 +107,7 @@ def suite_edgecases(test):
test("echo foo> bar", files=["bar"])
test("echo foo > bar", files=["bar"])
-@suite
-def suite_cmd(test):
- test("notfound")
- test("notfound a b c")
-
-@suite
+@suite(bonus=True)
def suite_cmd_variable(test):
test("A=a sh -c 'echo $A'")
test("A=a B=b sh -c 'echo $A$B'")
@@ -202,7 +198,7 @@ def suite_cmd_variable(test):
test("'BONJOURJESUIS''=''a' sh -c 'echo $BONJOURJESUIS'")
test('"BONJOURJESUIS""=""a" sh -c "echo $BONJOURJESUIS"')
-@suite
+@suite()
def suite_cmd_path(test):
ls_path = distutils.spawn.find_executable("ls")
cat_path = distutils.spawn.find_executable("cat")
diff --git a/src/suites/operation.py b/src/suites/operation.py
index 3c89589..d58953b 100644
--- a/src/suites/operation.py
+++ b/src/suites/operation.py
@@ -6,13 +6,13 @@
# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/07/15 18:24:52 by charles #+# #+# #
-# Updated: 2020/07/19 10:23:22 by charles ### ########.fr #
+# Updated: 2020/09/11 14:19:14 by charles ### ########.fr #
# #
# ############################################################################ #
from suite import suite
-@suite
+@suite()
def suite_end(test):
test("echo bonjour; echo je")
test("echo bonjour ;echo je")
@@ -35,7 +35,30 @@ def suite_end(test):
test("ls doesnotexists; echo bonjour")
test("echo bonjour; ls doesnotexists")
-@suite
+@suite()
+def suite_pipe(test):
+ test("echo bonjour | cat")
+ test("echo bonjour | cat -e")
+ test("ls | cat -e", setup="touch a b c d; mkdir m1 m2 m3")
+ test("ls -l | cat -e", setup="touch a b c d; mkdir m1 m2 m3")
+ 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")
+
+ # TODO special test for potential segfault
+ # test("echo|")
+ # test("echo |")
+ # test("echo | ")
+ test("|cat")
+ test("| cat")
+ test(" | cat")
+
+ test("echo a | export A=a; echo $A")
+ test("export A=a | cat; echo $A")
+ test("echo a | A=a; echo $A")
+ test("A=a | cat; echo $A")
+
+@suite(bonus=True)
def suite_and(test):
test("echo bonjour&& echo je")
test("echo bonjour &&echo je")
@@ -58,7 +81,7 @@ def suite_and(test):
test("ls doesnotexists&& echo bonjour")
test("echo bonjour&& ls doesnotexists")
-@suite
+@suite(bonus=True)
def suite_or(test):
test("echo bonjour|| echo je")
test("echo bonjour ||echo je")
@@ -80,26 +103,3 @@ def suite_or(test):
test("ls doesnotexists || echo bonjour")
test("ls doesnotexists|| echo bonjour")
test("echo bonjour|| ls doesnotexists")
-
-@suite
-def suite_pipe(test):
- test("echo bonjour | cat")
- test("echo bonjour | cat -e")
- test("ls | cat -e", setup="touch a b c d; mkdir m1 m2 m3")
- test("ls -l | cat -e", setup="touch a b c d; mkdir m1 m2 m3")
- 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")
-
- # TODO special test for potential segfault
- # test("echo|")
- # test("echo |")
- # test("echo | ")
- test("|cat")
- test("| cat")
- test(" | cat")
-
- test("echo a | export A=a; echo $A")
- test("export A=a | cat; echo $A")
- test("echo a | A=a; echo $A")
- test("A=a | cat; echo $A")
diff --git a/src/suites/parenthesis.py b/src/suites/parenthesis.py
index a06fdda..98320e8 100644
--- a/src/suites/parenthesis.py
+++ b/src/suites/parenthesis.py
@@ -6,13 +6,13 @@
# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/07/15 18:24:57 by charles #+# #+# #
-# Updated: 2020/07/15 18:24:57 by charles ### ########.fr #
+# Updated: 2020/09/11 14:23:35 by charles ### ########.fr #
# #
# ############################################################################ #
from suite import suite
-@suite
+@suite(bonus=True)
def suite_parenthesis(test):
test("(echo bonjour)")
test("(echo bonjour )")
diff --git a/src/suites/path.py b/src/suites/path.py
index b30215f..e4a650b 100644
--- a/src/suites/path.py
+++ b/src/suites/path.py
@@ -13,7 +13,7 @@
import config
from suite import suite
-@suite
+@suite()
def suite_path(test):
test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 000 ./path/a", exports={"PATH": "path"})
test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 001 ./path/a", exports={"PATH": "path"})
diff --git a/src/suites/preprocess.py b/src/suites/preprocess.py
index a34e18d..2f36e64 100644
--- a/src/suites/preprocess.py
+++ b/src/suites/preprocess.py
@@ -6,14 +6,14 @@
# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/07/15 18:25:00 by charles #+# #+# #
-# Updated: 2020/09/09 12:50:34 by charles ### ########.fr #
+# Updated: 2020/09/11 14:24:47 by charles ### ########.fr #
# #
# ############################################################################ #
import config
from suite import suite
-@suite
+@suite()
def suite_quote(test):
test("'echo' 'bonjour'")
test("'echo' 'je' 'suis' 'charles'")
@@ -56,7 +56,7 @@ def suite_quote(test):
test("'''''''e''''''''''c''''''''''''h''''''''o''''''''''''''''''''' bonjour")
test('"""""""e""""""""""c""""""""""""h""""""""o""""""""""""""""""""" bonjour')
-@suite
+@suite()
def suite_interpolation(test):
test("echo $TEST", exports={"TEST": "bonjour"})
test("echo $TES", exports={"TEST": "bonjour"})
@@ -171,7 +171,7 @@ def suite_interpolation(test):
test('echo $A$B$C', exports={"A": "", "B": "", "C": ""})
-@suite
+@suite()
def suite_escape(test):
test(r"echo \a")
test(r"\e\c\h\o bonjour")
@@ -193,24 +193,8 @@ def suite_escape(test):
test(r" \ echo bonjour")
test(r" \ echo bonjour")
-# @suite
-# def suite_preprocess(test):
-# test(r"echo \*", setup="touch a b c")
-# test(r"echo \*\*", setup="touch a b c")
-# test(r"echo \ *", setup="touch a b c")
-# test(r"echo *\.c", setup="touch a.c b.c c.c")
-# test(r"echo *.\c", setup="touch a.c b.c c.c")
-# test(r"echo *.c\ ", setup="touch a.c b.c c.c")
-# test("echo $A$B",
-# setup="mkdir src; touch src/a src/b src/c src/foo.c src/bar.c;\
-# mkdir inc; touch inc/a inc/b inc/c inc/foo.c inc/bar.c",
-# exports={"A": "*", "B": "/*.c"})
-# test("echo $A$B",
-# setup="mkdir src; touch src/a src/b src/c src/foo.c src/bar.c;\
-# mkdir inc; touch inc/a inc/b inc/c inc/foo.c inc/bar.c",
-# exports={"A": "*/.", "B": "*.c"})
-# @suite
+# @suite(bonus=True)
# def suite_glob(test):
# test("echo *")
# test("echo *", setup="touch a b c")
@@ -404,3 +388,17 @@ def suite_escape(test):
# test("echo *", setup="touch a; ln -s a b; ln -s b c; ln -s c d")
# test("echo d/*", setup="mkdir d; touch a b c d/d d/e d/f")
# test("echo d/*", setup="mkdir d; touch a b c d/d d/e d/f; chmod 000 d")
+# test(r"echo \*", setup="touch a b c")
+# test(r"echo \*\*", setup="touch a b c")
+# test(r"echo \ *", setup="touch a b c")
+# test(r"echo *\.c", setup="touch a.c b.c c.c")
+# test(r"echo *.\c", setup="touch a.c b.c c.c")
+# test(r"echo *.c\ ", setup="touch a.c b.c c.c")
+# test("echo $A$B",
+# setup="mkdir src; touch src/a src/b src/c src/foo.c src/bar.c;\
+# mkdir inc; touch inc/a inc/b inc/c inc/foo.c inc/bar.c",
+# exports={"A": "*", "B": "/*.c"})
+# test("echo $A$B",
+# setup="mkdir src; touch src/a src/b src/c src/foo.c src/bar.c;\
+# mkdir inc; touch inc/a inc/b inc/c inc/foo.c inc/bar.c",
+# exports={"A": "*/.", "B": "*.c"})
diff --git a/src/suites/status.py b/src/suites/status.py
index 62c076e..416b69a 100644
--- a/src/suites/status.py
+++ b/src/suites/status.py
@@ -12,7 +12,7 @@
from suite import suite
-@suite
+@suite()
def suite_status(test):
test("echo $?")
test("echo; echo $?")