aboutsummaryrefslogtreecommitdiff
path: root/src/suites
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-09-11 12:33:34 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-09-11 12:33:34 +0200
commit46ba2708f83bf46186c33bf84975d39e87f467c1 (patch)
tree8275c80bba98d63e81e3af9a1df8be62e0419003 /src/suites
parentc0b1a90cf9c52a0c9b1623ac695516031d5ccdba (diff)
downloadminishell_test-46ba2708f83bf46186c33bf84975d39e87f467c1.tar.gz
minishell_test-46ba2708f83bf46186c33bf84975d39e87f467c1.tar.bz2
minishell_test-46ba2708f83bf46186c33bf84975d39e87f467c1.zip
Refactoring files, splited test.py and suite.py in packages
Diffstat (limited to 'src/suites')
-rw-r--r--src/suites/__init__.py19
-rw-r--r--src/suites/builtin.py314
-rw-r--r--src/suites/cmd.py321
-rw-r--r--src/suites/operation.py105
-rw-r--r--src/suites/parenthesis.py57
-rw-r--r--src/suites/path.py71
-rw-r--r--src/suites/preprocess.py406
-rw-r--r--src/suites/status.py30
8 files changed, 1323 insertions, 0 deletions
diff --git a/src/suites/__init__.py b/src/suites/__init__.py
new file mode 100644
index 0000000..68bad1f
--- /dev/null
+++ b/src/suites/__init__.py
@@ -0,0 +1,19 @@
+# ############################################################################ #
+# #
+# ::: :::::::: #
+# __init__.py :+: :+: :+: #
+# +:+ +:+ +:+ #
+# 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 #
+# #
+# ############################################################################ #
+
+import os
+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
new file mode 100644
index 0000000..30297e0
--- /dev/null
+++ b/src/suites/builtin.py
@@ -0,0 +1,314 @@
+# ############################################################################ #
+# #
+# ::: :::::::: #
+# builtin.py :+: :+: :+: #
+# +:+ +:+ +:+ #
+# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
+# +#+#+#+#+#+ +#+ #
+# Created: 2020/07/15 18:24:43 by charles #+# #+# #
+# Updated: 2020/09/09 13:28:02 by charles ### ########.fr #
+# #
+# ############################################################################ #
+
+import os
+
+import config
+from suite import suite
+
+@suite
+def suite_echo(test):
+ test("echo")
+ test("echo bonjour")
+ test("echo lalalala lalalalal alalalalal alalalala")
+ test("echo lalalala lalalalal alalalalal alalalala")
+ test("echo " + config.LOREM)
+
+ test("echo -n")
+ test("echo -n bonjour")
+ test("echo -n lalalala lalalalal alalalalal alalalala")
+ test("echo -n lalalala lalalalal alalalalal alalalala")
+ test("echo -n " + config.LOREM)
+
+ test("echo bonjour -n")
+ test("echo -n bonjour -n")
+ test(" echo bonjour je")
+ test(" echo -n bonjour je")
+
+ test("echo a '' b '' c '' d")
+ test('echo a "" b "" c "" d')
+ test("echo -n a '' b '' c '' d")
+ test('echo -n a "" b "" c "" d')
+ test("echo '' '' ''")
+
+@suite
+def suite_export(test):
+ test("export")
+ # test("export A=; env | grep A=; echo $A")
+ # test("export A; env | grep A; echo $A")
+ test("export A=a; echo $A")
+ test("export A=a B=b C=c; echo $A$B$C")
+ test("export A=a B=b C=c D=d E=e F=f G=g H=h I=i J=j K=k L=l" +
+ "M=m N=n O=o P=p Q=q R=r S=s T=t U=u V=v W=w X=x Y=y Z=z" +
+ "; echo $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")
+ test("export BONJOURJESUIS=a; echo $BONJOURJESUIS")
+ test("export bonjourjesuis=a; echo $bonjourjesuis")
+ test("export bonjour_je_suis=a; echo $bonjour_je_suis")
+ test("export BONJOURJESUIS1=a; echo $BONJOURJESUIS1")
+ test("export bO_nJq123o__1ju_je3234sui__a=a; echo $bO_nJq123o__1ju_je3234sui__a")
+ test("export a0123456789=a; echo $a0123456789")
+ test("export abcdefghijklmnopqrstuvwxyz=a; echo $abcdefghijklmnopqrstuvwxyz")
+ test("export ABCDEFGHIJKLMNOPQRSTUVWXYZ=a; echo $ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+ test("export __________________________=a; echo $__________________________")
+ test("export _bonjour_=a; echo $_bonjour_")
+ test("export _=a; echo $_a")
+ test("export 1=a")
+ test("export BONJOURJESUIS =a")
+ test("export BONJOURJESUIS= a")
+ test(r"export BONJOUR\\JESUIS=a")
+ test(r"export BONJOUR\'JESUIS=a")
+ test(r'export BONJOUR\"JESUIS=a')
+ test(r"export BONJOUR\$JESUIS=a")
+ test(r"export BONJOUR\&JESUIS=a")
+ test(r"export BONJOUR\|JESUIS=a")
+ test(r"export BONJOUR\;JESUIS=a")
+ test(r"export BONJOUR\_JESUIS=a")
+ test(r"export BONJOUR\0JESUIS=a")
+ test(r"export \B\O\N\ \ \ \ \ \ \ JOURJESUIS=a")
+ test(r"export A=\B\O\N\ \ \ \ \ \ \ JOURJESUIS; echo $A")
+ test(r"export A='bonjour je suis charles'; echo $A")
+ test(r'export A="bonjour je suis charles"; echo $A')
+ test(r"export A==a; echo $A")
+ test(r"export A===a; echo $A")
+ test(r"export A====a; echo $A")
+ test(r"export A=====a; echo $A")
+ test(r"export A======a; echo $A")
+ test(r"export A=a=a=a=a=a; echo $A")
+ test("export A 'asdf ' B ' asdf asdf asd f' ' asdf ' '' 'asdf ' C; echo $A$B$C")
+ test("export 'asdf ' B ' asdf asdf asd f' ' asdf ' '' 'asdf ' C; echo $A$B$C")
+ test("export A 'asdf ' B ' asdf asdf asd f' ' asdf ' '' 'asdf '; echo $A$B$C")
+ test("export A B C; echo $A$B$C")
+
+ test("export $TEST", exports={"TEST": "A=a"})
+
+@suite
+def suite_cd(test):
+ test("cd .; pwd; echo $PWD");
+ test("cd ..; pwd; echo $PWD");
+ test("cd ../..; pwd; echo $PWD");
+ test("cd ../../..; pwd; echo $PWD");
+ test("cd ../../../..; pwd; echo $PWD");
+ test("cd ../../../../..; pwd; echo $PWD");
+ test("cd ../../../../../..; pwd; echo $PWD");
+ test("cd /; pwd; echo $PWD");
+ test("cd /etc; pwd; echo $PWD");
+ test("cd ''; pwd; echo $PWD");
+ test("cd '' ''; pwd; echo $PWD");
+ test("cd '' '' ''; pwd; echo $PWD");
+ test("cd ' '; pwd; echo $PWD");
+ test("cd '\t'; pwd; echo $PWD");
+ test("cd '\t \t\t\t '; pwd; echo $PWD");
+ test("cd d ''; pwd; echo $PWD", setup="mkdir d")
+ test("cd d d; pwd; echo $PWD", setup="mkdir d")
+ test("cd d ' '; pwd; echo $PWD", setup="mkdir d")
+ test("cd $HOME; pwd; echo $PWD");
+ test("cd $HOME; pwd; echo $PWD", exports={"HOME": os.getenv("HOME")});
+ # test("cd ~; pwd; echo $PWD"); # do we have to handle ~ ?
+ # test("cd ~/..; pwd; echo $PWD");
+ # test("cd ~/../..; pwd; echo $PWD");
+ test("cd /; pwd; echo $PWD");
+ test("cd /.; pwd; echo $PWD");
+ test("cd /./; pwd; echo $PWD");
+ test("cd /././././; pwd; echo $PWD");
+ test("cd //; pwd; echo $PWD");
+ test("cd ///; pwd; echo $PWD");
+ test("cd ////; pwd; echo $PWD");
+ test("cd //////////////////////////////////////////////////////; pwd; echo $PWD");
+ test("cd")
+
+ test("cd ' /'; pwd; echo $PWD")
+ test("cd ' / '; pwd; echo $PWD")
+ test("cd ' /'; pwd; echo $PWD")
+ test("cd ' / '; pwd; echo $PWD")
+ test("cd ' // '; pwd; echo $PWD")
+
+ test("cd //home; pwd; echo $PWD")
+ test("cd ' //home'; pwd; echo $PWD")
+ test("cd ' //home '; pwd; echo $PWD")
+
+ test("cd d", setup="mkdir -m 000 d")
+ test("cd d", setup="mkdir -m 001 d")
+ test("cd d", setup="mkdir -m 002 d")
+ test("cd d", setup="mkdir -m 003 d")
+ test("cd d", setup="mkdir -m 004 d")
+ test("cd d", setup="mkdir -m 005 d")
+ test("cd d", setup="mkdir -m 006 d")
+ test("cd d", setup="mkdir -m 007 d")
+ test("cd d", setup="mkdir -m 010 d")
+ test("cd d", setup="mkdir -m 020 d")
+ test("cd d", setup="mkdir -m 030 d")
+ test("cd d", setup="mkdir -m 040 d")
+ test("cd d", setup="mkdir -m 050 d")
+ test("cd d", setup="mkdir -m 060 d")
+ test("cd d", setup="mkdir -m 070 d")
+ test("cd d", setup="mkdir -m 100 d")
+ test("cd d", setup="mkdir -m 200 d")
+ test("cd d", setup="mkdir -m 300 d")
+ test("cd d", setup="mkdir -m 400 d")
+ test("cd d", setup="mkdir -m 500 d")
+ test("cd d", setup="mkdir -m 600 d")
+ test("cd d", setup="mkdir -m 700 d")
+
+ test("cd d", setup="mkdir -m 755 d")
+ test("cd d", setup="mkdir -m 644 d")
+ test("cd d", setup="mkdir -m 311 d")
+ test("cd d", setup="mkdir -m 111 d")
+ test("cd d", setup="mkdir -m 222 d")
+ test("cd d", setup="mkdir -m 333 d")
+
+ test("cd d", setup="mkdir -m 0777 d")
+ test("cd d", setup="mkdir -m 1000 d")
+ test("cd d", setup="mkdir -m 2000 d")
+ test("cd d", setup="mkdir -m 3000 d")
+ test("cd d", setup="mkdir -m 4000 d")
+ test("cd d", setup="mkdir -m 5000 d")
+ test("cd d", setup="mkdir -m 6000 d")
+ test("cd d", setup="mkdir -m 7000 d")
+ test("cd d", setup="mkdir -m 1777 d")
+ test("cd d", setup="mkdir -m 2777 d")
+ test("cd d", setup="mkdir -m 3777 d")
+ test("cd d", setup="mkdir -m 4777 d")
+ test("cd d", setup="mkdir -m 5777 d")
+ test("cd d", setup="mkdir -m 6777 d")
+ test("cd d", setup="mkdir -m 7777 d")
+ test("cd d", setup="mkdir -m 0000 d")
+
+@suite
+def suite_unset(test):
+ test("unset")
+ test("unset A; echo $A", setup="export A=a")
+ test("unset 'A '; echo $A", setup="export A=a")
+ test("unset 'A='; echo $A", setup="export A=a")
+ test("unset A B C; echo $A$B$C", setup="export A=a B=b C=c")
+ test("unset A 'asdf ' B ' asdf asdf asd f' ' asdf ' '' 'asdf ' C; echo $A$B$C",
+ setup="export A=a B=b C=c")
+ test("unset 'asdf ' B ' asdf asdf asd f' ' asdf ' '' 'asdf ' C; echo $A$B$C",
+ setup="export A=a B=b C=c")
+ test("unset A 'asdf ' B ' asdf asdf asd f' ' asdf ' '' 'asdf '; echo $A$B$C",
+ setup="export A=a B=b C=c")
+ test("unset A; echo $A$B$C", setup="export A=a B=b C=c")
+ test("unset C; echo $A$B$C", setup="export A=a B=b C=c")
+
+ test("unset A B C", setup="export A=a B=b C=c")
+ test("unset A 'asdf ' B ' asdf asdf asd f' ' asdf ' '' 'asdf ' C",
+ setup="export A=a B=b C=c")
+ test("unset 'asdf ' B ' asdf asdf asd f' ' asdf ' '' 'asdf ' C",
+ setup="export A=a B=b C=c")
+ test("unset A 'asdf ' B ' asdf asdf asd f' ' asdf ' '' 'asdf '",
+ setup="export A=a B=b C=c")
+ test("unset A", setup="export A=a B=b C=c")
+
+@suite
+def suite_pwd(test):
+ test("pwd")
+ test("pwd", setup="cd ..")
+ test("pwd", setup="cd ../..")
+ test("pwd", setup="cd ../../..")
+ test("pwd", setup="cd /")
+ test("pwd", setup="cd $HOME")
+ test("pwd | cat -e")
+ test("cd lnk; rmdir ../d; pwd", setup="mkdir d; ln -s d lnk")
+
+@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
+def suite_exit(test):
+ test("exit")
+ test("exit 1")
+ test("exit 2")
+ test("exit 3")
+ test("exit ' 3'")
+ test("exit '\t3'")
+ 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 0")
+ test("exit -0")
+ test("exit -1")
+ test("exit 255")
+ test("exit 256")
+ test("exit 2000000")
+ test("exit -2000000")
+ test("exit 2147483647")
+ test("exit -2147483648")
+ test("exit 2147483648")
+ test("exit -2147483649")
+ test("exit 3147483648")
+ test("exit -3147483649")
+ test("exit 4294967295")
+ test("exit 4294967296")
+ test("exit -9223372036854775808")
+ test("exit 9223372036854775807")
+ test("exit -9223372036854775809")
+ test("exit 9223372036854775808")
+ test("exit 18446744073709551615")
+ test("exit 18446744073709551616")
+
+ 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 --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 0123456789")
+ test("exit -0123456789")
+ test("exit 00000000000000000000000000000000000000000000001")
+ test("exit 00000000000000000000000000000000000000000000000" +
+ "00000000000000000000000000000000000000000000001")
+ test("exit 00000000000000000000000000000000000000000000000" +
+ "00000000000000000000000000000000000000000000000")
+ test("exit -00000000000000000000000000000000000000000000000" +
+ "00000000000000000000000000000000000000000000001")
+ test("exit -99999999999999999999999999999999999999999999" +
+ "99999999999999999999999999999999999999999999")
+ test("exit 99999999999999999999999999999999999999999999" +
+ "99999999999999999999999999999999999999999999")
+
+ test("exit 0 bonjour")
+ test("exit bonjour 0")
+ test("exit 0 1")
+ test("exit 0 1 2 3 4 5 6 7 8 9")
+
+ test("exit " + config.LOREM)
diff --git a/src/suites/cmd.py b/src/suites/cmd.py
new file mode 100644
index 0000000..1302ae3
--- /dev/null
+++ b/src/suites/cmd.py
@@ -0,0 +1,321 @@
+# ############################################################################ #
+# #
+# ::: :::::::: #
+# cmd.py :+: :+: :+: #
+# +:+ +:+ +:+ #
+# 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 #
+# #
+# ############################################################################ #
+
+import distutils
+
+import config
+from suite import suite
+
+
+@suite
+def suite_redirection(test):
+ test("echo bonjour > test", setup="", files=["test"])
+ test("echo > test bonjour", setup="", files=["test"])
+ test("> test echo bonjour", setup="", files=["test"])
+ test("echo bonjour >> test", setup="", files=["test"])
+ test("echo >> test bonjour", setup="", files=["test"])
+ test(">> test echo bonjour", setup="", files=["test"])
+ test("cat < test", setup="echo bonjour > test")
+ test("echo bonjour > test", setup="", files=["test"])
+
+ test("echo > test'sticked' bonjour", setup="", files=["teststicked"])
+ test("> test'sticked' echo bonjour", setup="", files=["teststicked"])
+ test("echo bonjour >> test'sticked'", setup="", files=["teststicked"])
+ test("echo >> test'sticked' bonjour", setup="", files=["teststicked"])
+ test(">> test'sticked' echo bonjour", setup="", files=["teststicked"])
+ test("cat < test'sticked'", setup="echo bonjour > test'sticked'")
+ test("< test'sticked' cat", setup="echo bonjour > test'sticked'")
+
+ test("echo > test\"sticked\" bonjour", setup="", files=["teststicked"])
+ test("> test\"sticked\" echo bonjour", setup="", files=["teststicked"])
+ test("echo bonjour >> test\"sticked\"", setup="", files=["teststicked"])
+ test("echo >> test\"sticked\" bonjour", setup="", files=["teststicked"])
+ test(">> test\"sticked\" echo bonjour", setup="", files=["teststicked"])
+ test("cat < test\"sticked\"", setup="echo bonjour > test\"sticked\"")
+ test("< test\"sticked\" cat", setup="echo bonjour > test\"sticked\"")
+
+ test("echo > test'yo'\"sticked\" bonjour", setup="", files=["testyosticked"])
+ test("> test'yo'\"sticked\" echo bonjour", setup="", files=["testyosticked"])
+ test("echo bonjour >> test'yo'\"sticked\"", setup="", files=["testyosticked"])
+ test("echo >> test'yo'\"sticked\" bonjour", setup="", files=["testyosticked"])
+ test(">> test'yo'\"sticked\" echo bonjour", setup="", files=["testyosticked"])
+ test("cat < test'yo'\"sticked\"", setup="echo bonjour > test'yo'\"sticked\"")
+ test("< test'yo'\"sticked\" cat", setup="echo bonjour > test'yo'\"sticked\"")
+
+ test("echo bonjour > test > je > suis", setup="", files=["test", "je", "suis"])
+ test("echo > test > je bonjour > suis", setup="", files=["test", "je", "suis"])
+ test("> test echo bonjour > je > suis", setup="", files=["test", "je", "suis"])
+ test("echo bonjour >> test > je >> suis", setup="", files=["test", "je", "suis"])
+ test("echo >> test bonjour > je > suis", setup="", files=["test", "je", "suis"])
+ test(">> test echo > je bonjour > suis", setup="", files=["test", "je", "suis"])
+ test("cat < test < je", setup="echo bonjour > test; echo salut > je")
+
+ test("echo bonjour>test>je>suis", setup="", files=["test", "je", "suis"])
+ test(">test echo bonjour>je>suis", setup="", files=["test", "je", "suis"])
+ test("echo bonjour>>test>je>>suis", setup="", files=["test", "je", "suis"])
+ test("cat<test<je", setup="echo bonjour > test; echo salut > je")
+
+ test("echo bonjour > 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'",
+ files=["abcdefghijklmnopqrstuvwxyz"])
+ test('echo bonjour > 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"',
+ files=["abcdefghijklmnopqrstuvwxyz"])
+ test('echo bonjour > 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\'',
+ files=["abcdefghijklmnopqrstuvwxyz"])
+
+ test("> file", files=["file"])
+ test("< file", setup="echo bonjour > file")
+
+ test(">")
+ test(">>")
+ test("<")
+ test("echo >")
+ test("echo >>")
+ test("echo <")
+
+ test("> test", files=["test"])
+ test(">> test", files=["test"])
+ test("< test", setup="touch test")
+
+ test("echo foo >>> bar")
+ test("echo foo >>>> bar")
+ test("echo foo >>>>> bar")
+
+ test("cat << < bar", setup="echo bonjour > bar")
+ test("cat <<<< bar", setup="echo bonjour > bar")
+ test("cat <<<<< bar", setup="echo bonjour > bar")
+
+ test("cat < doesnotexist")
+
+
+
+@suite
+def suite_edgecases(test):
+ 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"])
+ test("echo foo >bar", files=["bar"])
+ 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
+def suite_cmd_variable(test):
+ test("A=a sh -c 'echo $A'")
+ test("A=a B=b sh -c 'echo $A$B'")
+ test("A=a B=b C=c D=d E=e F=f G=g H=h sh -c 'echo $A$B$C$D$E$F$G$H'")
+ test("A=a A=bonjour sh -c 'echo $A'")
+ test("A=aA=bonjour sh -c 'echo $A'")
+ test("BONJOURJESUIS=a sh -c 'echo $BONJOURJESUIS'")
+ test("bonjourjesuis=a sh -c 'echo $bonjourjesuis'")
+ test("bonjour_je_suis=a sh -c 'echo $bonjour_je_suis'")
+ test("BONJOURJESUIS1=a sh -c 'echo $BONJOURJESUIS1'")
+ test("bO_nJq123o__1ju_je3234sui__a=a sh -c 'echo $bO_nJq123o__1ju_je3234sui__a'")
+ test("a0123456789=a sh -c 'echo $a0123456789'")
+ test("abcdefghijklmnopqrstuvwxyz=a sh -c 'echo $abcdefghijklmnopqrstuvwxyz'")
+ test("ABCDEFGHIJKLMNOPQRSTUVWXYZ=a sh -c 'echo $ABCDEFGHIJKLMNOPQRSTUVWXYZ'")
+ test("__________________________=a sh -c 'echo $__________________________'")
+ test("_bonjour_=a sh -c 'echo $_bonjour_'")
+ test("_=a sh -c 'echo $_a'")
+ test("1=a")
+ test("BONJOURJESUIS =a sh -c 'echo $BONJOURJESUIS '")
+ test("BONJOURJESUIS= a sh -c 'echo $BONJOURJESUIS'")
+ test(r"BONJOUR\\JESUIS=a sh -c 'echo $BONJOUR\\JESUIS'")
+ test(r'BONJOUR\'JESUIS=a sh -c "echo $BONJOUR\'JESUIS"')
+ test(r'BONJOUR\"JESUIS=a sh -c "echo $BONJOUR\"JESUIS"')
+ test(r"BONJOUR\$JESUIS=a sh -c 'echo $BONJOUR\$JESUIS'")
+ test(r"BONJOUR\&JESUIS=a sh -c 'echo $BONJOUR\&JESUIS'")
+ test(r"BONJOUR\|JESUIS=a sh -c 'echo $BONJOUR\|JESUIS'")
+ test(r"BONJOUR\;JESUIS=a sh -c 'echo $BONJOUR\;JESUIS'")
+ test(r"BONJOUR\_JESUIS=a sh -c 'echo $BONJOUR\_JESUIS'")
+ test(r"BONJOUR\0JESUIS=a sh -c 'echo $BONJOUR\0JESUIS'")
+ test(r"\B\O\N\ \ \ \ \ \ \ JOURJESUIS=a sh -c 'echo $\B\O\N\ \ \ \ \ \ \ JOURJESUIS'")
+ test(r"A=\B\O\N\ \ \ \ \ \ \ JOURJESUIS sh -c 'echo $A'")
+ test(r"A='bonjour je suis charles' sh -c 'echo $A'")
+ test(r'A="bonjour je suis charles" sh -c "echo $A"')
+ test(r"A==a sh -c 'echo $A'")
+ test(r"A===a sh -c 'echo $A'")
+ test(r"A====a sh -c 'echo $A'")
+ test(r"A=====a sh -c 'echo $A'")
+ test(r"A======a sh -c 'echo $A'")
+ test(r"A=a=a=a=a=a sh -c 'echo $A'")
+
+ test("A=a; echo $A")
+ test("A=a B=b; echo $A$B")
+ test("A=a B=b C=c D=d E=e F=f G=g H=h; echo $A$B$C$D$E$F$G$H")
+ test("A=a A=bonjour; echo $A")
+ test("A=aA=bonjour; echo $A")
+ test("BONJOURJESUIS=a; echo $BONJOURJESUIS")
+ test("bonjourjesuis=a; echo $bonjourjesuis")
+ test("bonjour_je_suis=a; echo $bonjour_je_suis")
+ test("BONJOURJESUIS1=a; echo $BONJOURJESUIS1")
+ test("bO_nJq123o__1ju_je3234sui__a=a; echo $bO_nJq123o__1ju_je3234sui__a")
+ test("a0123456789=a; echo $a0123456789")
+ test("abcdefghijklmnopqrstuvwxyz=a; echo $abcdefghijklmnopqrstuvwxyz")
+ test("ABCDEFGHIJKLMNOPQRSTUVWXYZ=a; echo $ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+ test("__________________________=a; echo $__________________________")
+ test("_bonjour_=a; echo $_bonjour_")
+ test("_=a; echo $_a")
+ test("BONJOURJESUIS =a; echo $BONJOURJESUIS ")
+ test("BONJOURJESUIS= a; echo $BONJOURJESUIS")
+ test(r"BONJOUR\\JESUIS=a; echo $BONJOUR\\JESUIS")
+ test(r"BONJOUR\'JESUIS=a; echo $BONJOUR\'JESUIS")
+ test(r'BONJOUR\"JESUIS=a; echo $BONJOUR\"JESUIS')
+ test(r"BONJOUR\$JESUIS=a; echo $BONJOUR\$JESUIS")
+ test(r"BONJOUR\&JESUIS=a; echo $BONJOUR\&JESUIS")
+ test(r"BONJOUR\|JESUIS=a; echo $BONJOUR\|JESUIS")
+ test(r"BONJOUR\;JESUIS=a; echo $BONJOUR\;JESUIS")
+ test(r"BONJOUR\_JESUIS=a; echo $BONJOUR\_JESUIS")
+ test(r"BONJOUR\0JESUIS=a; echo $BONJOUR\0JESUIS")
+ test(r"\B\O\N\ \ \ \ \ \ \ JOURJESUIS=a; echo $\B\O\N\ \ \ \ \ \ \ JOURJESUIS")
+ test(r"A=\B\O\N\ \ \ \ \ \ \ JOURJESUIS; echo $A")
+ test(r"A='bonjour je suis charles'; echo $A")
+ test(r'A="bonjour je suis charles"; echo $A')
+ test(r"A==a; echo $A")
+ test(r"A===a; echo $A")
+ test(r"A====a; echo $A")
+ test(r"A=====a; echo $A")
+ test(r"A======a; echo $A")
+ test(r"A=a=a=a=a=a; echo $A")
+
+ test("PATH=a ls")
+ test("PATH=a echo aa")
+ test("A=a echo $A")
+ test("A=a B=b echo $A$B")
+ test("A=a B=b C=c D=d E=e F=f G=g H=h echo $A$B$C$D$E$F$G$H")
+ test("A=$PATH sh -c 'echo $A'")
+ test("A=\"$PATH je suis\" sh -c 'echo $A'")
+ test("A='$PATH je suis' sh -c 'echo $A'")
+ test("$TEST sh -c 'echo $A'", setup="export TEST='A=a'")
+ test("'BONJOURJESUIS''=''a' sh -c 'echo $BONJOURJESUIS'")
+ test('"BONJOURJESUIS""=""a" sh -c "echo $BONJOURJESUIS"')
+
+@suite
+def suite_cmd_path(test):
+ ls_path = distutils.spawn.find_executable("ls")
+ cat_path = distutils.spawn.find_executable("cat")
+
+ test(ls_path, setup="touch a b c")
+ test(ls_path + " -l", setup="touch a b c")
+ test("./bonjour", setup="touch a b c; cp {} bonjour".format(ls_path))
+ test("./bonjour -l", setup="touch a b c; cp {} bonjour".format(ls_path))
+ test("./somedir/bonjour -l",
+ setup="mkdir somedir; touch a b c; touch somedir/d somedir/e;" +
+ "cp {} somedir/bonjour".format(ls_path))
+
+ test("./ls . a b c",
+ setup="touch a b c; echo bonjour > a; cp {} ls".format(cat_path))
+ test("ls . a b c",
+ setup="touch a b c; echo bonjour > a; cp {} ls".format(cat_path))
+
+ test("./somefile", setup="touch somefile; chmod 000 somefile")
+ test("./somefile", setup="touch somefile; chmod 001 somefile")
+ test("./somefile", setup="touch somefile; chmod 002 somefile")
+ test("./somefile", setup="touch somefile; chmod 003 somefile")
+ test("./somefile", setup="touch somefile; chmod 004 somefile")
+ test("./somefile", setup="touch somefile; chmod 005 somefile")
+ test("./somefile", setup="touch somefile; chmod 006 somefile")
+ test("./somefile", setup="touch somefile; chmod 007 somefile")
+ test("./somefile", setup="touch somefile; chmod 010 somefile")
+ test("./somefile", setup="touch somefile; chmod 020 somefile")
+ test("./somefile", setup="touch somefile; chmod 030 somefile")
+ test("./somefile", setup="touch somefile; chmod 040 somefile")
+ test("./somefile", setup="touch somefile; chmod 050 somefile")
+ test("./somefile", setup="touch somefile; chmod 060 somefile")
+ test("./somefile", setup="touch somefile; chmod 070 somefile")
+ test("./somefile", setup="touch somefile; chmod 100 somefile")
+ test("./somefile", setup="touch somefile; chmod 200 somefile")
+ test("./somefile", setup="touch somefile; chmod 300 somefile")
+ test("./somefile", setup="touch somefile; chmod 400 somefile")
+ test("./somefile", setup="touch somefile; chmod 500 somefile")
+ test("./somefile", setup="touch somefile; chmod 600 somefile")
+ test("./somefile", setup="touch somefile; chmod 700 somefile")
+
+ test("./somefile", setup="touch somefile; chmod 755 somefile")
+ test("./somefile", setup="touch somefile; chmod 644 somefile")
+ test("./somefile", setup="touch somefile; chmod 311 somefile")
+ test("./somefile", setup="touch somefile; chmod 111 somefile")
+ test("./somefile", setup="touch somefile; chmod 222 somefile")
+ test("./somefile", setup="touch somefile; chmod 333 somefile")
+
+ test("somedir/", setup="mkdir somedir")
+ test("./somedir/", setup="mkdir somedir")
+ test("somedir", setup="mkdir somedir")
+ test("./somedir", setup="mkdir somedir")
+ 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")
+ test("./somedirsoftlink", setup="mkdir somedir; ln -s somedir somedirsoftlink")
+ 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")
+ test("./somelink3", setup="touch somefile; ln -s somefile somelink1; ln -s somelink1 somelink2;" +
+ "ln -s somelink2 somelink3")
+ test("./somelink4", setup="touch somefile; ln -s somefile somelink1; ln -s somelink1 somelink2;" +
+ "ln -s somelink2 somelink3; ln -s somelink3 somelink4")
+
+ test("./somelink2ls", setup="cp " + ls_path + " somefile;" +
+ "ln -s somefile somelink1; ln -s somelink1 somelink2")
+ test("./somelink3ls", setup="cp " + ls_path + " somefile;" +
+ "ln -s somefile somelink1; ln -s somelink1 somelink2;" +
+ "ln -s somelink2 somelink3")
+ test("./somelink4ls", setup="cp " + ls_path + " somefile;" +
+ "ln -s somefile somelink1; ln -s somelink1 somelink2;" +
+ "ln -s somelink2 somelink3; ln -s somelink3 somelink4")
+
+ test("_", setup="touch _")
+ test("'-'", setup="touch -")
+ test("./_", setup="touch _")
+ test("./-", setup="touch -")
+ test("./.", setup="touch .")
+ test("./..", setup="touch ..")
+
+ test("./somefile", setup='touch somefile && chmod 0777 somefile')
+ test("./somefile", setup='touch somefile && chmod 1000 somefile')
+ test("./somefile", setup='touch somefile && chmod 2000 somefile')
+ test("./somefile", setup='touch somefile && chmod 3000 somefile')
+ test("./somefile", setup='touch somefile && chmod 4000 somefile')
+ test("./somefile", setup='touch somefile && chmod 5000 somefile')
+ test("./somefile", setup='touch somefile && chmod 6000 somefile')
+ test("./somefile", setup='touch somefile && chmod 7000 somefile')
+ test("./somefile", setup='touch somefile && chmod 1777 somefile')
+ test("./somefile", setup='touch somefile && chmod 2777 somefile')
+ test("./somefile", setup='touch somefile && chmod 3777 somefile')
+ test("./somefile", setup='touch somefile && chmod 4777 somefile')
+ test("./somefile", setup='touch somefile && chmod 5777 somefile')
+ test("./somefile", setup='touch somefile && chmod 6777 somefile')
+ test("./somefile", setup='touch somefile && chmod 7777 somefile')
+ test("./somefile", setup='touch somefile && chmod 0000 somefile')
+
+ test("./somedir", setup='mkdir somedir && chmod 0777 somedir')
+ test("./somedir", setup='mkdir somedir && chmod 1000 somedir')
+ test("./somedir", setup='mkdir somedir && chmod 2000 somedir')
+ test("./somedir", setup='mkdir somedir && chmod 3000 somedir')
+ test("./somedir", setup='mkdir somedir && chmod 4000 somedir')
+ test("./somedir", setup='mkdir somedir && chmod 5000 somedir')
+ test("./somedir", setup='mkdir somedir && chmod 6000 somedir')
+ test("./somedir", setup='mkdir somedir && chmod 7000 somedir')
+ test("./somedir", setup='mkdir somedir && chmod 1777 somedir')
+ test("./somedir", setup='mkdir somedir && chmod 2777 somedir')
+ test("./somedir", setup='mkdir somedir && chmod 3777 somedir')
+ test("./somedir", setup='mkdir somedir && chmod 4777 somedir')
+ test("./somedir", setup='mkdir somedir && chmod 5777 somedir')
+ test("./somedir", setup='mkdir somedir && chmod 6777 somedir')
+ test("./somedir", setup='mkdir somedir && chmod 0000 somedir')
+ test("./somedir", setup='mkdir somedir && chmod 0000 somedir')
diff --git a/src/suites/operation.py b/src/suites/operation.py
new file mode 100644
index 0000000..3c89589
--- /dev/null
+++ b/src/suites/operation.py
@@ -0,0 +1,105 @@
+# ############################################################################ #
+# #
+# ::: :::::::: #
+# operation.py :+: :+: :+: #
+# +:+ +:+ +:+ #
+# 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 #
+# #
+# ############################################################################ #
+
+from suite import suite
+
+@suite
+def suite_end(test):
+ test("echo bonjour; echo je")
+ test("echo bonjour ;echo je")
+ test("echo bonjour ; echo je")
+ test("echo bonjour;")
+ test("echo; ")
+ test("echo ; ")
+ test("echo ;")
+ test("; echo")
+ test(" ;echo")
+ test(" ; echo")
+ 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")
+ 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")
+
+ test("ls doesnotexists ; echo bonjour")
+ test("ls doesnotexists; echo bonjour")
+ test("echo bonjour; ls doesnotexists")
+
+@suite
+def suite_and(test):
+ test("echo bonjour&& echo je")
+ test("echo bonjour &&echo je")
+ test("echo bonjour && echo je")
+ test("echo bonjour&&")
+ # test("echo&& ")
+ # test("echo && ")
+ # test("echo &&")
+ test("&&echo")
+ test("&& echo")
+ test(" && echo")
+ 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")
+ 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")
+
+ test("ls doesnotexists && echo bonjour")
+ test("ls doesnotexists&& echo bonjour")
+ test("echo bonjour&& ls doesnotexists")
+
+@suite
+def suite_or(test):
+ test("echo bonjour|| echo je")
+ test("echo bonjour ||echo je")
+ test("echo bonjour || echo je")
+ test("echo bonjour||")
+ # test("echo|| ")
+ # test("echo || ")
+ # test("echo ||")
+ test("||echo")
+ test("|| echo")
+ test(" || echo")
+ 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")
+ 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")
+
+ 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
new file mode 100644
index 0000000..a06fdda
--- /dev/null
+++ b/src/suites/parenthesis.py
@@ -0,0 +1,57 @@
+# ############################################################################ #
+# #
+# ::: :::::::: #
+# parenthesis.py :+: :+: :+: #
+#