diff options
Diffstat (limited to 'suites')
| -rw-r--r-- | suites/builtin.py | 71 | ||||
| -rw-r--r-- | suites/operation.py | 71 | ||||
| -rw-r--r-- | suites/suites.py | 4 |
3 files changed, 111 insertions, 35 deletions
diff --git a/suites/builtin.py b/suites/builtin.py index 1211363..93e9db7 100644 --- a/suites/builtin.py +++ b/suites/builtin.py @@ -15,21 +15,22 @@ def suite_echo(test): @suite def suite_export(test): - test("export A=a") - test("export A=a B=b C=c") + 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") - test("export BONJOURJESUIS=a") - test("export bonjourjesuis=a") - test("export bonjour_je_suis=a") - test("export BONJOURJESUIS1=a") - test("export bO_nJq123o__1ju_je3234sui__a=a") - test("export a0123456789=a") - test("export abcdefghijklmnopqrstuvwxyz=a") - test("export ABCDEFGHIJKLMNOPQRSTUVWXYZ=a") - test("export __________________________=a") - test("export _bonjour_=a") - test("export _=a") + "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") @@ -43,33 +44,33 @@ def suite_export(test): 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") - test(r"export A='bonjour je suis charles'") - test(r'export A="bonjour je suis charles"') - test(r"export A==a") - test(r"export A===a") - test(r"export A====a") - test(r"export A=====a") - test(r"export A======a") - test(r"export A=a=a=a=a=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") @suite def suite_cd(test): - test("cd ."); - test("cd .."); - test("cd ../.."); - test("cd ../../.."); - test("cd ../../../.."); - test("cd ../../../../.."); - test("cd ../../../../../.."); - test("cd /"); - test("cd /etc"); - test("cd $HOME"); - test("cd ~"); + test("cd .; pwd"); + test("cd ..; pwd"); + test("cd ../..; pwd"); + test("cd ../../..; pwd"); + test("cd ../../../..; pwd"); + test("cd ../../../../..; pwd"); + test("cd ../../../../../..; pwd"); + test("cd /; pwd"); + test("cd /etc; pwd"); + test("cd $HOME; pwd"); + test("cd ~; pwd"); @suite def suite_unset(test): - test("unset A", setup="export A=a") + test("unset A; echo $A", setup="export A=a") @suite def suite_pwd(test): diff --git a/suites/operation.py b/suites/operation.py new file mode 100644 index 0000000..7bed096 --- /dev/null +++ b/suites/operation.py @@ -0,0 +1,71 @@ +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 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 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 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") diff --git a/suites/suites.py b/suites/suites.py index f56875e..9f6ce86 100644 --- a/suites/suites.py +++ b/suites/suites.py @@ -76,6 +76,10 @@ def suite_redirection(test): 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_error(test): |
