aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-09-11 18:32:57 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-09-11 18:32:57 +0200
commit1ad72842b3dcf10cc89cd682a044f4780ac97e41 (patch)
tree80c7ecbff4c3e20e3f6da86a96a3c7542c92500b /src
parent1739695001889d53d29976943fda593d64afcefb (diff)
downloadminishell_test-1ad72842b3dcf10cc89cd682a044f4780ac97e41.tar.gz
minishell_test-1ad72842b3dcf10cc89cd682a044f4780ac97e41.tar.bz2
minishell_test-1ad72842b3dcf10cc89cd682a044f4780ac97e41.zip
Added export alone, quote missing and tab in cmd test
Diffstat (limited to 'src')
-rw-r--r--src/hooks.py13
-rw-r--r--src/suite/suite.py6
-rw-r--r--src/suites/builtin.py78
-rw-r--r--src/suites/cmd.py53
-rw-r--r--src/suites/operation.py11
-rw-r--r--src/suites/parenthesis.py12
-rw-r--r--src/suites/path.py4
-rw-r--r--src/suites/preprocess.py50
8 files changed, 99 insertions, 128 deletions
diff --git a/src/hooks.py b/src/hooks.py
index b723b99..7ee1334 100644
--- a/src/hooks.py
+++ b/src/hooks.py
@@ -6,16 +6,19 @@
# By: charles <me@cacharle.xyz> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/09/11 16:10:20 by charles #+# #+# #
-# Updated: 2020/09/11 17:06:03 by charles ### ########.fr #
+# Updated: 2020/09/11 18:26:58 by charles ### ########.fr #
# #
# ############################################################################ #
+import regex
+
import config
def sort_lines(output):
return '\n'.join(sorted(output.split('\n')))
+
def error_line0(output):
lines = output.split('\n')
if len(lines) != 3:
@@ -25,5 +28,13 @@ def error_line0(output):
return output
return lines[0].replace(prefix, "minishell: ") + "\n"
+
def discard(output):
return "DISCARDED BY TEST"
+
+
+def export_singleton(output):
+ return sort_lines(
+ '\n'.join([l for l in output.split('\n')
+ if regex.match("^declare -x .+=\".*\"$", l) is not None])
+ )
diff --git a/src/suite/suite.py b/src/suite/suite.py
index d796cf7..7f78d33 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/09/11 14:18:01 by charles ### ########.fr #
+# Updated: 2020/09/11 17:48:25 by charles ### ########.fr #
# #
# ############################################################################ #
@@ -84,9 +84,9 @@ class Suite:
continue
pass_sum += pass_total
fail_sum += fail_total
- print("{:<15} \033[32m{:3} [PASS]\033[0m \033[31m{:3} [FAIL]\033[0m"
+ print("{:<30} \033[32m{:3} [PASS]\033[0m \033[31m{:3} [FAIL]\033[0m"
.format(s.name, pass_total, fail_total))
- print("{:<15} \033[32m{:3} [PASS]\033[0m \033[31m{:3} [FAIL]\033[0m"
+ print("{:<30} \033[32m{:3} [PASS]\033[0m \033[31m{:3} [FAIL]\033[0m"
.format("TOTAL", pass_sum, fail_sum))
@classmethod
diff --git a/src/suites/builtin.py b/src/suites/builtin.py
index c782f4d..3b342e7 100644
--- a/src/suites/builtin.py
+++ b/src/suites/builtin.py
@@ -6,7 +6,7 @@
# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/07/15 18:24:43 by charles #+# #+# #
-# Updated: 2020/09/11 16:13:26 by charles ### ########.fr #
+# Updated: 2020/09/11 18:26:11 by charles ### ########.fr #
# #
# ############################################################################ #
@@ -23,18 +23,15 @@ def suite_echo(test):
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")
@@ -43,9 +40,12 @@ def suite_echo(test):
@suite()
def suite_export(test):
- test("export", hook=hooks.sort_lines)
- # test("export A=; env | grep A=; echo $A")
- # test("export A; env | grep A; echo $A")
+ test("export", hook=hooks.export_singleton)
+ test("export", exports={"A": ""}, hook=hooks.export_singleton)
+ test("export", exports={"A": "\""}, hook=hooks.export_singleton)
+ test("export", exports={"A": "\t"}, hook=hooks.export_singleton)
+ test("export", exports={"A": "'"}, hook=hooks.export_singleton)
+ test("export", exports={"A": "a"}, hook=hooks.export_singleton)
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" +
@@ -88,8 +88,17 @@ def suite_export(test):
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"})
+ test(r"export BONJOUR\\JESUIS")
+ test(r"export BONJOUR\'JESUIS")
+ test(r'export BONJOUR\"JESUIS')
+ test(r"export BONJOUR\$JESUIS")
+ test(r"export BONJOUR\&JESUIS")
+ test(r"export BONJOUR\|JESUIS")
+ test(r"export BONJOUR\;JESUIS")
+ test(r"export BONJOUR\_JESUIS")
+ test(r"export BONJOUR\0JESUIS")
+
@suite()
def suite_cd(test):
@@ -106,16 +115,11 @@ def suite_cd(test):
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");
@@ -125,17 +129,14 @@ def suite_cd(test):
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")
@@ -158,14 +159,12 @@ def suite_cd(test):
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")
@@ -182,31 +181,36 @@ def suite_cd(test):
test("cd d", setup="mkdir -m 6777 d")
test("cd d", setup="mkdir -m 7777 d")
test("cd d", setup="mkdir -m 0000 d")
+ # test("cd '\t'; pwd; echo $PWD");
+ # test("cd '\t \t\t\t '; pwd; echo $PWD");
+ # test("cd ~; pwd; echo $PWD"); # do we have to handle ~ ?
+ # test("cd ~/..; pwd; echo $PWD");
+ # test("cd ~/../..; pwd; echo $PWD");
+
@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; echo $A", exports={"A": "a"})
+ test("unset 'A '; echo $A", exports={"A": "a"})
+ test("unset 'A='; echo $A", exports={"A": "a"})
+ test("unset A B C; echo $A$B$C", exports={"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")
+ exports={"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")
+ exports={"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")
+ exports={"A": "a", "B": "b", "C": "c"})
+ test("unset A; echo $A$B$C", exports={"A": "a", "B": "b", "C": "c"})
+ test("unset C; echo $A$B$C", exports={"A": "a", "B": "b", "C": "c"})
+ test("unset A B C", exports={"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")
+ exports={"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")
+ exports={"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")
+ exports={"A": "a", "B": "b", "C": "c"})
+ test("unset A", exports={"A": "a", "B": "b", "C": "c"})
@suite()
def suite_pwd(test):
@@ -217,7 +221,7 @@ def suite_pwd(test):
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")
+ # test("cd lnk; rmdir ../d; pwd", setup="mkdir d; ln -s d lnk")
@suite()
def suite_env(test):
@@ -262,7 +266,6 @@ def suite_exit(test):
test("exit 9223372036854775808")
test("exit 18446744073709551615")
test("exit 18446744073709551616")
-
test("exit +1")
test("exit +2")
test("exit +3")
@@ -271,7 +274,6 @@ def suite_exit(test):
test("exit +256")
test("exit +2000000")
test("exit +2147483647")
-
test("exit ++1")
test("exit ++2")
test("exit ++3")
@@ -280,7 +282,6 @@ def suite_exit(test):
test("exit ++256")
test("exit ++2000000")
test("exit ++2147483647")
-
test("exit --1")
test("exit --2")
test("exit --3")
@@ -289,7 +290,6 @@ def suite_exit(test):
test("exit --256")
test("exit --2000000")
test("exit --2147483647")
-
test("exit bonjour")
test("exit 0_")
test("exit _0")
@@ -306,10 +306,8 @@ def suite_exit(test):
"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
index db67f33..7294f3a 100644
--- a/src/suites/cmd.py
+++ b/src/suites/cmd.py
@@ -6,13 +6,14 @@
# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/07/15 15:11:46 by charles #+# #+# #
-# Updated: 2020/09/11 16:34:19 by charles ### ########.fr #
+# Updated: 2020/09/11 18:29:06 by charles ### ########.fr #
# #
# ############################################################################ #
import distutils
import config
+import hooks
from suite import suite
@@ -26,7 +27,6 @@ def suite_redirection(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"])
@@ -34,7 +34,6 @@ def suite_redirection(test):
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"])
@@ -42,7 +41,6 @@ def suite_redirection(test):
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"])
@@ -50,7 +48,6 @@ def suite_redirection(test):
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"])
@@ -58,41 +55,33 @@ def suite_redirection(test):
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(">", 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("> 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("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("cat < doesnotexist")
@@ -115,7 +104,6 @@ def suite_status(test):
test("notfound; echo $?")
test("cat < doesntexist; echo $?")
test("cat < noperm; echo $?", setup="echo bonjour > noperm; chmod 000 noperm")
-
test("echo")
test("notfound")
test("cat < doesntexist")
@@ -126,7 +114,6 @@ def suite_status(test):
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))
@@ -134,12 +121,10 @@ def suite_cmd_path(test):
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")
@@ -162,34 +147,28 @@ def suite_cmd_path(test):
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;" +
@@ -198,14 +177,12 @@ def suite_cmd_path(test):
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')
@@ -222,7 +199,6 @@ def suite_cmd_path(test):
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')
@@ -239,6 +215,7 @@ def suite_cmd_path(test):
test("./somedir", setup='mkdir somedir && chmod 6777 somedir')
test("./somedir", setup='mkdir somedir && chmod 0000 somedir')
+
# @suite(bonus=True)
# def suite_cmd_variable(test):
# test("A=a sh -c 'echo $A'")
diff --git a/src/suites/operation.py b/src/suites/operation.py
index dc8642a..9d9c6d8 100644
--- a/src/suites/operation.py
+++ b/src/suites/operation.py
@@ -6,13 +6,14 @@
# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/07/15 18:24:52 by charles #+# #+# #
-# Updated: 2020/09/11 17:05:35 by charles ### ########.fr #
+# Updated: 2020/09/11 17:43:58 by charles ### ########.fr #
# #
# ############################################################################ #
from suite import suite
import hooks
+
@suite()
def suite_end(test):
test("echo bonjour; echo je")
@@ -31,11 +32,11 @@ def suite_end(test):
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")
@@ -45,19 +46,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 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")
@@ -76,11 +76,11 @@ def suite_and(test):
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(bonus=True)
def suite_or(test):
test("echo bonjour|| echo je")
@@ -99,7 +99,6 @@ def suite_or(test):
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")
diff --git a/src/suites/parenthesis.py b/src/suites/parenthesis.py
index d3ec5bf..d2007cb 100644
--- a/src/suites/parenthesis.py
+++ b/src/suites/parenthesis.py
@@ -6,56 +6,48 @@
# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/07/15 18:24:57 by charles #+# #+# #
-# Updated: 2020/09/11 16:13:54 by charles ### ########.fr #
+# Updated: 2020/09/11 17:43:34 by charles ### ########.fr #
# #
# ############################################################################ #
from suite import suite
+
@suite(bonus=True)
def suite_parenthesis(test):
test("(echo bonjour)")
test("(echo bonjour )")
test("( echo bonjour )")
-
test("(echo a && echo b) && echo c")
test("(echo a || echo b) || echo c")
test("(ls doesnotexist || echo b) || echo c")
test("(echo a || ls doesnotexist) || echo c")
test("echo aa && (echo b && echo c)")
test("ls doesnotexist || (echo b && echo c)")
-
test("(echo bonjour > f1)", files=["f1"])
test("(echo bonjour > f1 > f2 > f3)", files=["f1", "f2", "f3"])
test("(echo bonjour > f1 > f2 > f3 > f4 > f5 > f6 > f7 > f8 > f9)",
files=["f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9"])
-
test("(echo bonjour) > f1", files=["f1"])
test("(echo bonjour) > f1 > f2 > f3", files=["f1", "f2", "f3"])
test("(echo bonjour) > f1 > f2 > f3 > f4 > f5 > f6 > f7 > f8 > f9",
files=["f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9"])
-
test("(cat -e < f1)", setup="echo bonjour > f1")
test("(cat -e < f1 < f2 < f3)", setup="touch f1 f2 f3 f4; echo bonjour > f3")
test("(cat -e < f1 < f2 < f3 < f4 < f5 < f6 < f7 < f8 < f9)",
setup="touch f1 f2 f3 f4 f5 f6 f7 f8 f9; echo bonjour > f9")
-
test("(cat -e) < f1", setup="echo bonjour > f1")
test("(cat -e) < f1 < f2 < f3", setup="touch f1 f2 f3 f4; echo bonjour > f3")
test("(cat -e) < f1 < f2 < f3 < f4 < f5 < f6 < f7 < f8 < f9",
setup="touch f1 f2 f3 f4 f5 f6 f7 f8 f9; echo bonjour > f9")
-
test("(echo bonjour > f1 > f2 > f3 > f4) > f5 > f6 > f7 > f8 > f9",
files=["f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9"])
test("(cat -e < f1 < f2 < f3 < f4) < f5 < f6 < f7 < f8 < f9",
setup="touch f1 f2 f3 f4 f5 f6 f7 f8 f9; echo bonjour > f4")
-
test("(echo bonjour > f1) > f2", files=["f1", "f2"])
test("(cat -e > f1) < f2", setup="ls -l / > f2", files=["f1"])
-
test("(exit); echo bonjour")
test("(echo bonjour; exit; echo aurevoir)")
-
test("(ls && ls)")
test("(ls doesntexist || ls)")
test("(ls doesntexist && ls)")
diff --git a/src/suites/path.py b/src/suites/path.py
index e4a650b..bcac98e 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/09 15:39:17 by charles ### ########.fr #
+# Updated: 2020/09/11 17:43:14 by charles ### ########.fr #
# #
# ############################################################################ #
@@ -59,9 +59,7 @@ def suite_path(test):
test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 6777 ./path/a", exports={"PATH": "path"})
test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 7777 ./path/a", exports={"PATH": "path"})
test("a", setup="mkdir path && cp /bin/ls ./path/a && chmod 0000 ./path/a", exports={"PATH": "path"})
-
test("b", setup="mkdir path && cp /bin/ls ./path/a && ln -s ./path/a ./path/b", exports={"PATH": "path"})
-
test("ls", exports={"PATH": "doesnotexits"})
test("ls", exports={"PATH": "doesnotexits:asdfasdfas"})
test("ls", 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"})
diff --git a/src/suites/preprocess.py b/src/suites/preprocess.py
index 2f36e64..429b5ac 100644
--- a/src/suites/preprocess.py
+++ b/src/suites/preprocess.py
@@ -6,40 +6,35 @@
# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/07/15 18:25:00 by charles #+# #+# #
-# Updated: 2020/09/11 14:24:47 by charles ### ########.fr #
+# Updated: 2020/09/11 18:30:34 by charles ### ########.fr #
# #
# ############################################################################ #
import config
+import hooks
from suite import suite
+
@suite()
def suite_quote(test):
test("'echo' 'bonjour'")
test("'echo' 'je' 'suis' 'charles'")
-
test('"echo" "bonjour"')
test('"echo" "je" "suis" "charles"')
-
test('echo je\'suis\'"charles"')
test('echo "je"suis\'charles\'')
test('echo \'je\'"suis"charles')
-
test('echo "\\""')
test('echo "\\$"')
test('echo "\\\\"')
-
test('ls ""')
test("ls ''")
-
test('ls "" "" "" \'\' """"')
test("ls '' '' '''' ''")
-
test("' echo' bonjour")
test("'echo ' bonjour")
test('" echo" bonjour')
test('"echo " bonjour')
-
test("''echo bonjour")
test('""echo bonjour')
test("''''''''''''''''''''''''''''''''''''''''''''''''''''''''''echo bonjour")
@@ -52,43 +47,41 @@ def suite_quote(test):
test('ec""ho bonjour')
test("ec''''''''''''''''''''''''''''''''''''''''''''''''''''''''''ho bonjour")
test('ec""""""""""""""""""""""""""""""""""""""""""""""""""""""""""ho bonjour')
-
test("'''''''e''''''''''c''''''''''''h''''''''o''''''''''''''''''''' bonjour")
test('"""""""e""""""""""c""""""""""""h""""""""o""""""""""""""""""""" bonjour')
+ 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)
+
@suite()
def suite_interpolation(test):
test("echo $TEST", exports={"TEST": "bonjour"})
test("echo $TES", exports={"TEST": "bonjour"})
test("echo $TEST_", exports={"TEST": "bonjour"})
-
test('echo "|$TEST|"', exports={"TEST": "bonjour"})
test('echo "|$TES|"', exports={"TEST": "bonjour"})
test('echo "|$TEST_|"', exports={"TEST": "bonjour"})
-
test("echo '|$TEST|'", exports={"TEST": "bonjour"})
test("echo '|$TES|'", exports={"TEST": "bonjour"})
test("echo '|$TEST_|'", exports={"TEST": "bonjour"})
-
test("echo $A$B$C", exports={"A": "foo", "B": "bar", "C": "baz"})
test('echo "$A$B$C"', exports={"A": "foo", "B": "bar", "C": "baz"})
test("echo '$A$B$C'", exports={"A": "foo", "B": "bar", "C": "baz"})
-
test("echo $A,$B,$C", exports={"A": "foo", "B": "bar", "C": "baz"})
test('echo "$A,$B,$C"', exports={"A": "foo", "B": "bar", "C": "baz"})
test("echo '$A,$B,$C'", exports={"A": "foo", "B": "bar", "C": "baz"})
-
test('echo $A"$B"$C"A"$B"$C"', exports={"A": "foo", "B": "bar", "C": "baz"})
test("echo $A'$B'$C'A'$B'$C'", exports={"A": "foo", "B": "bar", "C": "baz"})
-
test('echo $A"$B"$C"A"$B"$C"', exports={"A": "foo ", "B": " bar ", "C": "baz "})
test("echo $A'$B'$C'A'$B'$C'", exports={"A": "foo ", "B": " bar ", "C": "baz "})
-
test("echo $A")
test("echo $A$B")
test("echo $A$B$C")
test("echo $A$B$C$D")
-
test("echo [$A]", exports={"A": r"bonjour\je"})
test("echo [$A]", exports={"A": r"\b\\o\\\nj\\\\\\\our\\je\\\\"})
test("echo [$A]", exports={"A": r" \b\\o\\\nj\\\\\\\our\\je\\\\"})
@@ -100,11 +93,9 @@ def suite_interpolation(test):
test("echo [$A]", exports={"A": r" "})
test("echo [$A]", exports={"A": r"\ "})
test("echo [$A]", exports={"A": r" \ "})
-
test(r"echo \ \ \ \ \ \ \ $A\ \ \ \ \ \ ", exports={"A": "bonjour"})
test(r"echo \ \ \ \ \ \ \ $A\ \ \ \ \ \ ", exports={"A": "bonjour je suis"})
test(r"echo \ \ \ \ \ \ \ $A\ \ \ \ \ \ ", exports={"A": " bonjour je suis "})
-
test('echo $A', exports={"A": "bonjour je suis splited"})
test('echo $A', exports={"A": "bonjour je suis splited"})
test('echo $A', exports={"A": " bonjour je suis splited "})
@@ -124,20 +115,15 @@ def suite_interpolation(test):
test("echo $A", exports={"A": "'" + config.LOREM + "'"})
test('echo "$A"', exports={"A": "'" + config.LOREM + "'"})
test("echo '$A'", exports={"A": "'" + config.LOREM + "'"})
-
test("$ECHO $ECHO", exports={"ECHO": "echo"})
test("$A$B bonjour", exports={"A": "ec", "B": "ho"})
-
test("$LS", exports={"LS": "ls -l"}, setup="touch a b c")
-
test("echo $")
test("echo \$")
test("echo \$\$\$\$")
test("echo \$$\$$")
-
test("echo $\A $\B", exports={"A": "a", "B": "b"})
test("echo $\A$\B", exports={"A": "a", "B": "b"})
-
test("echo $A", exports={"A": " "})
test("echo $A", exports={"A": " "})
test("echo $A", exports={"A": " "})
@@ -145,7 +131,6 @@ def suite_interpolation(test):
test("echo $A", exports={"A": " a "})
test("echo $A", exports={"A": " "})
test("echo $A", exports={"A": " a "})
-
test("echo @$A@", exports={"A": " "})
test("echo @ $A@", exports={"A": " "})
test("echo @$A @", exports={"A": " "})
@@ -156,7 +141,6 @@ def suite_interpolation(test):
test('echo "@"$A"@"', exports={"A": " "})
test('echo "@" $A"@"', exports={"A": " "})
test('echo "@"$A "@"', exports={"A": " "})
-
test('echo @"$A"@', exports={"A": " "})
test('echo @ "$A"@', exports={"A": " "})
test('echo @"$A" @', exports={"A": " "})
@@ -167,7 +151,6 @@ def suite_interpolation(test):
test('echo "@""$A""@"', exports={"A": " "})
test('echo "@" "$A""@"', exports={"A": " "})
test('echo "@""$A" "@"', exports={"A": " "})
-
test('echo $A$B$C', exports={"A": "", "B": "", "C": ""})
@@ -194,6 +177,19 @@ def suite_escape(test):
test(r" \ echo bonjour")
+@suite()
+def suite_spaces(test):
+ test("echo foo")
+ test("echo foo")
+ test(" echo foo")
+ test("echo foo ")
+ test(" echo foo ")
+ test("echo\t\t\t\t\t\t\t\t\t\tfoo")
+ test("\t\t\t\t\t\techo\tfoo")
+ test("echo\tfoo\t\t\t\t\t\t")
+ test("\t\t\t\techo\t\t\t\tfoo\t\t\t\t")
+
+
# @suite(bonus=True)
# def suite_glob(test):
# test("echo *")