aboutsummaryrefslogtreecommitdiff
path: root/suites.py
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-06-17 14:04:56 +0200
committerCharles <sircharlesaze@gmail.com>2020-06-17 14:04:56 +0200
commita5a7a2ae5132b2cc682fe8c2496680bf748bf9b3 (patch)
treef8f546fb3b73886af07a631d20e45e7d767e6095 /suites.py
parentf36a8ccb91cb71c1e4f15dc12cdecf3167eb1420 (diff)
downloadminishell_test-a5a7a2ae5132b2cc682fe8c2496680bf748bf9b3.tar.gz
minishell_test-a5a7a2ae5132b2cc682fe8c2496680bf748bf9b3.tar.bz2
minishell_test-a5a7a2ae5132b2cc682fe8c2496680bf748bf9b3.zip
Added builtin test (false positive until separator are implemented
Diffstat (limited to 'suites.py')
-rw-r--r--suites.py235
1 files changed, 0 insertions, 235 deletions
diff --git a/suites.py b/suites.py
deleted file mode 100644
index b49dd28..0000000
--- a/suites.py
+++ /dev/null
@@ -1,235 +0,0 @@
-import config
-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 "\\\\"')
-
-@suite
-def suite_echo(test):
- test("echo bonjour")
- test("echo lalalala lalalalal alalalalal alalalala")
- test("echo lalalala lalalalal alalalalal alalalala")
- test("echo " + config.LOREM)
-
- test("echo -n bonjour")
- test("echo -n lalalala lalalalal alalalalal alalalala")
- test("echo -n lalalala lalalalal alalalalal alalalala")
- test("echo -n " + config.LOREM)
-
-@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"])
-
-@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`"\'()|&><']))
-
-@suite
-def suite_cmd_error(test):
- 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")
-
-@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", 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("echo $")
-
-@suite
-def suite_glob(test):
- test("echo *")
- test("echo *", setup="touch a b c")
- test("echo *.c", setup="touch a b c foo.c bar.c")
- test("echo src/*.c", setup="mkdir src; touch src/a src/b src/c src/foo.c src/bar.c")
- test("echo */*.c", setup="mkdir src; touch src/a src/b src/c src/foo.c src/bar.c")
- test("echo */*.c",
- 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")
- test("echo */*.h",
- 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.h inc/bar.h")
- test("echo l1/*/l3/*/*",
- setup="mkdir -p l1/l2_1/l3; mkdir -p l1/l2_2; cd l1/l2_1/l3;\
- 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.h inc/bar.h;\
- cd ../../..; cd l1/l2_2; touch bonjour je suis")
-
- test("echo */*/*/*/*.c",
- setup="mkdir -p l1/l2/l3; cd l1/l2/l3;\
- 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.h inc/bar.h")
- test("echo */*/*/*/*.h",
- setup="mkdir -p l1/l2/l3; cd l1/l2/l3;\
- 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.h inc/bar.h")
-
- test("echo */*/*/*.c",
- setup="mkdir -p l1/l2/l3; cd l1/l2/l3;\
- 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.h inc/bar.h")
- test("echo */*/*/*.h",
- setup="mkdir -p l1/l2/l3; cd l1/l2/l3;\
- 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.h inc/bar.h")
-
- test("echo */*/*/*/*/*.c",
- setup="mkdir -p l1/l2/l3; cd l1/l2/l3;\
- 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.h inc/bar.h")
- test("echo */*/*/*/*/*.h",
- setup="mkdir -p l1/l2/l3; cd l1/l2/l3;\
- 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.h inc/bar.h")
-
- test("echo /etc/*")
- test("echo /usr/include/*.h")
- test("echo /*/*")
-
- test("echo *nothing")
- test("echo nothing*")
- test("echo *nothing*")
-
- test("echo **")
- test("echo **", setup="touch a b c")
- test("echo **", setup="mkdir d; touch d/a d/b d/c")
- test("echo */*", setup="mkdir d; touch d/a d/b d/c")
- test("echo */a", setup="mkdir d; touch d/a d/b d/c")
- test("echo d/*", setup="mkdir d; touch d/a d/b d/c")
-
-@suite
-def suite_escape(test):
- test(r"echo \a")
- test(r"\e\c\h\o bonjour")
- test(r"echo charles\ ")
- test(r"echo \ \ jesuis\ \ charles")
- test(r"echo \ \ \ \ \ \ \ \ ")
- test(r"echo \ \ \ \ \ \ \ \ \ \ \ \ \ \ ")
- test(r"echo \$PATH")
- test(r"echo \$\P\A\T\H")
- 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"})