diff options
Diffstat (limited to 'src/suites')
| -rw-r--r-- | src/suites/__init__.py | 17 | ||||
| -rw-r--r-- | src/suites/builtin.py | 403 | ||||
| -rw-r--r-- | src/suites/cmd.py | 331 | ||||
| -rw-r--r-- | src/suites/flow.py | 290 | ||||
| -rw-r--r-- | src/suites/misc.py | 100 | ||||
| -rw-r--r-- | src/suites/path.py | 137 | ||||
| -rw-r--r-- | src/suites/preprocess.py | 463 |
7 files changed, 0 insertions, 1741 deletions
diff --git a/src/suites/__init__.py b/src/suites/__init__.py deleted file mode 100644 index b6b3b68..0000000 --- a/src/suites/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -# ############################################################################ # -# # -# ::: :::::::: # -# __init__.py :+: :+: :+: # -# +:+ +:+ +:+ # -# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # -# +#+#+#+#+#+ +#+ # -# Created: 2020/07/15 18:24:48 by charles #+# #+# # -# Updated: 2020/09/11 13:25:26 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")] diff --git a/src/suites/builtin.py b/src/suites/builtin.py deleted file mode 100644 index 9ab2af8..0000000 --- a/src/suites/builtin.py +++ /dev/null @@ -1,403 +0,0 @@ -# **************************************************************************** # -# # -# ::: :::::::: # -# builtin.py :+: :+: :+: # -# +:+ +:+ +:+ # -# By: juligonz <juligonz@student.42.fr> +#+ +:+ +#+ # -# +#+#+#+#+#+ +#+ # -# Created: 2020/07/15 18:24:43 by charles #+# #+# # -# Updated: 2020/11/28 06:17:19 by charles ### ########.fr # -# Updated: 2020/09/11 18:01:27 by juligonz ### ########.fr # -# # -# **************************************************************************** # - -import os - -import config -import hooks -from suite import suite -from hooks import linux_discard - - -@suite() -def suite_echo(test): - """ echo builtin tests """ - 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 '' '' ''") - test("Echo bonjour") - test("eCho bonjour") - test("ecHo bonjour") - test("echO bonjour") - test("EchO bonjour") - test("eCHo bonjour") - test("EcHo bonjour") - test("eChO bonjour") - test("Echo bonjour", exports={"PATH": "/bin:/usr/bin"}) - test("eCho bonjour", exports={"PATH": "/bin:/usr/bin"}) - test("ecHo bonjour", exports={"PATH": "/bin:/usr/bin"}) - test("echO bonjour", exports={"PATH": "/bin:/usr/bin"}) - test("EchO bonjour", exports={"PATH": "/bin:/usr/bin"}) - test("eCHo bonjour", exports={"PATH": "/bin:/usr/bin"}) - test("EcHo bonjour", exports={"PATH": "/bin:/usr/bin"}) - test("eChO bonjour", exports={"PATH": "/bin:/usr/bin"}) - test("eChO -e 'bonjo\\nur'", exports={"PATH": "/bin:/usr/bin"}) - test("echo -n -n -n -n bonjour") - test("echo -nnnnnnnnnnnnnnnnnnnnn bonjour") - test("echo -nnnnnnnnnnnnnnnnnnnnn -n -n -n bonjour -n -n") - - -@suite() -def suite_export(test): - """ export builtin tests """ - 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": "\\"}, 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" - "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 A B C; env", hook=hooks.sort_lines) - test("export 'AH@'=nop") - test("export \"AH'\"=nop") - test("export 'AH\"'=nop") - test("export 'AH$'=nop") - test("export 'AH!'=nop") - test("export 'AH|'=nop") - test("export 'AH;'=nop") - test("export 'AH&'=nop") - test("export 'AH\\'=nop") - 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") - test("Export B=bonjour") - test("exporT B=bonjour") - test("Export B=bonjour", exports={"PATH": "/bin:/usr/bin"}) - test("exporT B=bonjour", exports={"PATH": "/bin:/usr/bin"}) - - -@suite() -def suite_cd(test): - """ cd builtin tests """ - test("echo $PWD; echo $OLDPWD; cd .; pwd; echo $PWD; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd ..; pwd; echo $PWD; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd ../..; pwd; echo $PWD; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd ../../..; pwd; echo $PWD; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd ../../../..; pwd; echo $PWD; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd ../../../../..; pwd; echo $PWD; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd ../../../../../..; pwd; echo $PWD; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd /; pwd; echo $PWD; echo $OLDPWD") - # /etc is a link to /etc/private - # hard and weird to implement with pwd - # test("cd /etc; pwd; echo $PWD") - test("echo $PWD; echo $OLDPWD; cd ''; pwd; echo $PWD; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd '' ''; pwd; echo $PWD; echo $OLDPWD", hook=linux_discard) - test("echo $PWD; echo $OLDPWD; cd '' '' ''; pwd; echo $PWD; echo $OLDPWD", hook=linux_discard) - test("echo $PWD; echo $OLDPWD; cd ' '; pwd; echo $PWD; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd d ''; pwd; echo $PWD; echo $OLDPWD", setup="mkdir d", hook=linux_discard) - test("echo $PWD; echo $OLDPWD; cd d d; pwd; echo $PWD; echo $OLDPWD", setup="mkdir d", hook=linux_discard) - test("echo $PWD; echo $OLDPWD; cd d ' '; pwd; echo $PWD; echo $OLDPWD", setup="mkdir d", hook=linux_discard) - test("echo $PWD; echo $OLDPWD; cd $HOME; pwd; echo $PWD; echo $OLDPWD", exports={"HOME": os.getenv("HOME")}) - test("echo $PWD; echo $OLDPWD; cd /; pwd; echo $PWD; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd /.; pwd; echo $PWD; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd /./; pwd; echo $PWD; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd /././././; pwd; echo $PWD; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd //; pwd; echo $PWD; echo $OLDPWD", hook=hooks.replace_double_slash) - test("echo $PWD; echo $OLDPWD; cd ///; pwd; echo $PWD; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd ////; pwd; echo $PWD; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd //////////////////////////////////////////////////////; pwd; echo $PWD; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd; echo $PWD; echo $OLDPWD", exports={"HOME": os.getenv("HOME")}) - test("echo $PWD; echo $OLDPWD; cd ' /'; pwd; echo $PWD; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd ' / '; pwd; echo $PWD; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd ' /'; pwd; echo $PWD; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd ' / '; pwd; echo $PWD; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd ' // '; pwd; echo $PWD; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd //home; pwd; echo $PWD; echo $OLDPWD", hook=hooks.replace_double_slash) - test("echo $PWD; echo $OLDPWD; cd ' //home'; pwd; echo $PWD; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd ' //home '; pwd; echo $PWD; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 000 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 001 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 002 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 003 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 004 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 005 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 006 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 007 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 010 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 020 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 030 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 040 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 050 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 060 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 070 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 100 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 200 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 300 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 400 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 500 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 600 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 700 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 755 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 644 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 311 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 111 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 222 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 333 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 0777 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 1000 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 2000 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 3000 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 4000 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 5000 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 6000 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 7000 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 1777 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 2777 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 3777 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 4777 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 5777 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 6777 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 7777 d") - test("echo $PWD; echo $OLDPWD; cd d; echo $OLDPWD", setup="mkdir -m 0000 d") - test("echo $PWD; echo $OLDPWD; cd /; echo $PWD; echo $OLDPWD; unset PWD; cd /dev; echo $OLDPWD") - test("echo $PWD; echo $OLDPWD; cd /; echo $PWD; echo $OLDPWD; export PWD=bonjour; cd /dev; echo $OLDPWD") - # 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"); - # test("cd $HOME; pwd; echo $PWD") - test("Cd .") - test("cD .") - test("Cd .", exports={"PATH": "/bin:/usr/bin"}) - test("cD .", exports={"PATH": "/bin:/usr/bin"}) - - -@suite() -def suite_unset(test): - """ unset builtin tests """ - test("unset") - 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", - exports={"A": "a", "B": "b", "C": "c"}) - test("unset 'asdf ' B ' asdf asdf asd f' ' asdf ' '' 'asdf ' C; echo $A$B$C", - exports={"A": "a", "B": "b", "C": "c"}) - test("unset A 'asdf ' B ' asdf asdf asd f' ' asdf ' '' 'asdf '; echo $A$B$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", - exports={"A": "a", "B": "b", "C": "c"}) - test("unset 'asdf ' B ' asdf asdf asd f' ' asdf ' '' 'asdf ' C", - exports={"A": "a", "B": "b", "C": "c"}) - test("unset A 'asdf ' B ' asdf asdf asd f' ' asdf ' '' 'asdf '", - exports={"A": "a", "B": "b", "C": "c"}) - test("unset A", exports={"A": "a", "B": "b", "C": "c"}) - test("unset 'AH@'=nop") - test("unset \"AH'\"=nop") - test("unset 'AH\"'=nop") - test("unset 'AH$'=nop") - test("unset 'AH!'=nop") - test("unset 'AH|'=nop") - test("unset 'AH;'=nop") - test("unset 'AH&'=nop") - test("unset 'AH\\'=nop") - test("Unset TERM") - test("unseT TERM") - test("Unset TERM", exports={"PATH": "/bin:/usr/bin"}) - test("unseT TERM", exports={"PATH": "/bin:/usr/bin"}) - - -@suite() -def suite_pwd(test): - """ pwd builtin tests """ - 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("pwd", exports={"PWD": "/etc"}) - test("unset PWD; pwd; echo $PWD") - test("export PWD=foo; pwd; echo $PWD") - # test("cd lnk; rmdir ../d; pwd", setup="mkdir d; ln -s d lnk") - test("Pwd") - test("pwD") - test("Pwd", exports={"PATH": "/bin:/usr/bin"}) - test("pwD", exports={"PATH": "/bin:/usr/bin"}) - - -@suite() -def suite_env(test): - """ env builtin tests """ - test("env", hook=[hooks.sort_lines, hooks.shlvl_0_to_1]) - test("env", setup="export A=a", hook=[hooks.sort_lines, hooks.shlvl_0_to_1]) - test("env", setup="export A=a B=b C=c", hook=[hooks.sort_lines, hooks.shlvl_0_to_1]) - test("env | cat -e", setup="export A=a B=b C=c", hook=[hooks.sort_lines, hooks.shlvl_0_to_1]) - test("Env") - test("enV") - test("Env", exports={"PATH": "/bin:/usr/bin"}) - test("enV", exports={"PATH": "/bin:/usr/bin"}) - - -@suite() -def suite_exit(test): - """ exit builtin tests """ - 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'", hook_status=hooks.platform_status(255, 2)) - test("exit '3\t\f\r '", hook_status=hooks.platform_status(255, 2)) - test("exit '3 a'", hook_status=hooks.platform_status(255, 2)) - test("exit '3\t\t\ta'", hook_status=hooks.platform_status(255, 2)) - 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", hook_status=hooks.platform_status(255, 2)) - test("exit 9223372036854775808", hook_status=hooks.platform_status(255, 2)) - test("exit 18446744073709551615", hook_status=hooks.platform_status(255, 2)) - test("exit 18446744073709551616", hook_status=hooks.platform_status(255, 2)) - 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", hook_status=hooks.platform_status(255, 2)) - test("exit ++2", hook_status=hooks.platform_status(255, 2)) - test("exit ++3", hook_status=hooks.platform_status(255, 2)) - test("exit ++0", hook_status=hooks.platform_status(255, 2)) - test("exit ++255", hook_status=hooks.platform_status(255, 2)) - test("exit ++256", hook_status=hooks.platform_status(255, 2)) - test("exit ++2000000", hook_status=hooks.platform_status(255, 2)) - test("exit ++2147483647", hook_status=hooks.platform_status(255, 2)) - test("exit --1", hook_status=hooks.platform_status(255, 2)) - test("exit --2", hook_status=hooks.platform_status(255, 2)) - test("exit --3", hook_status=hooks.platform_status(255, 2)) - test("exit --0", hook_status=hooks.platform_status(255, 2)) - test("exit --255", hook_status=hooks.platform_status(255, 2)) - test("exit --256", hook_status=hooks.platform_status(255, 2)) - test("exit --2000000", hook_status=hooks.platform_status(255, 2)) - test("exit --2147483647", hook_status=hooks.platform_status(255, 2)) - test("exit bonjour", hook_status=hooks.platform_status(255, 2)) - test("exit 0_", hook_status=hooks.platform_status(255, 2)) - test("exit _0", hook_status=hooks.platform_status(255, 2)) - 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", hook_status=hooks.platform_status(255, 2)) - test("exit 99999999999999999999999999999999999999999999" - "99999999999999999999999999999999999999999999", hook_status=hooks.platform_status(255, 2)) - test("exit 0 bonjour") - test("exit bonjour 0", hook_status=hooks.platform_status(255, 2)) - test("exit 0 1") - test("exit 0 1 2 3 4 5 6 7 8 9") - test("exit " + config.LOREM, hook_status=hooks.platform_status(255, 2)) - test("exit bonjoru; echo should have exited", hook_status=hooks.platform_status(255, 2)) - test("exit 99999999999999999999999999999999999999999999999999999; echo should have exited", hook_status=hooks.platform_status(255, 2)) - test("exit 9999; echo should have exited") - test("Exit; echo a") - test("exiT; echo a") - test("Exit; echo a", exports={"PATH": "/bin:/usr/bin"}) - test("exiT; echo a", exports={"PATH": "/bin:/usr/bin"}) diff --git a/src/suites/cmd.py b/src/suites/cmd.py deleted file mode 100644 index 53b1f97..0000000 --- a/src/suites/cmd.py +++ /dev/null @@ -1,331 +0,0 @@ -# ############################################################################ # -# # -# ::: :::::::: # -# cmd.py :+: :+: :+: # -# +:+ +:+ +:+ # -# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # -# +#+#+#+#+#+ +#+ # -# Created: 2020/07/15 15:11:46 by charles #+# #+# # -# Updated: 2021/02/04 16:14:54 by charles ### ########.fr # -# # -# ############################################################################ # - -import distutils - -import hooks -import config -from suite import suite - - -@suite() -def suite_redirection(test): - """ append/write/read redirections """ - 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(">", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) - test(">>", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) - test("<", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) - test("echo >", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) - test("echo >>", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) - test("echo <", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) - test("> test", files=["test"]) - test(">> test", files=["test"]) - test("< test", setup="touch test") - test("echo foo >>> bar", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) - test("echo foo >>>> bar", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) - test("echo foo >>>>> bar", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) - test("cat << < bar", setup="echo bonjour > bar", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) - test("cat << << bar", setup="echo bonjour > bar", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) - test("cat <<<<< bar", setup="echo bonjour > bar", hook=hooks.error_line0, hook_status=hooks.platform_status(1, 2)) - test("cat < doesnotexist") - test("echo bonjour >> a", setup="echo a > a", files=["a"]) - test("echo bonjour >> a >> a", setup="echo a > a", files=["a"]) - test("echo bonjour > a", setup="echo a > a", files=["a"]) - test("echo bonjour > a >> a", setup="echo a > a", files=["a"]) - - -@suite() -def suite_cmd(test): - """ long cmd, cmd not found tests """ - 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"]) - test("echo foo >bar", files=["bar"]) - test("echo foo> bar", files=["bar"]) - test("echo foo > bar", files=["bar"]) - test("echo a as df sad f as df qw e qwe as df asd f as df as d fas d f" - "asd f asd f asdf asdf asdf asd f asd f asd f asd f as df as df a" - "asd f asd f asdf asdf asdf asd f asd f asd f asd f as df as df a" - "asd f asd f asdf asdf asdf asd f asd f asd f asd f as df as df a") - test("echo " + config.LOREM * 10) - test("echo " + config.LOREM * 20) - - -@suite() -def suite_status(test): - """ $? tests """ - test("echo $?") - test("echo; echo $?") - 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") - test("cat < noperm", setup="echo bonjour > noperm; chmod 000 noperm") - - -@suite() -def suite_cmd_path(test): - """ cmd is a relative path, permissions on executable """ - ls_path = distutils.spawn.find_executable("ls") - if ls_path is None: - print("Couldn't find `ls` in your PATH: Skipping suite") - return - cat_path = distutils.spawn.find_executable("cat") - if cat_path is None: - print("Couldn't find `cat` in your PATH: Skipping suite") - return - 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="echo > somefile; chmod 000 somefile") - test("./somefile", setup="echo > somefile; chmod 001 somefile") - test("./somefile", setup="echo > somefile; chmod 002 somefile") - test("./somefile", setup="echo > somefile; chmod 003 somefile") - test("./somefile", setup="echo > somefile; chmod 004 somefile") - test("./somefile", setup="echo > somefile; chmod 005 somefile") - test("./somefile", setup="echo > somefile; chmod 006 somefile") - test("./somefile", setup="echo > somefile; chmod 007 somefile") - test("./somefile", setup="echo > somefile; chmod 010 somefile") - test("./somefile", setup="echo > somefile; chmod 020 somefile") - test("./somefile", setup="echo > somefile; chmod 030 somefile") - test("./somefile", setup="echo > somefile; chmod 040 somefile") - test("./somefile", setup="echo > somefile; chmod 050 somefile") - test("./somefile", setup="echo > somefile; chmod 060 somefile") - test("./somefile", setup="echo > somefile; chmod 070 somefile") - test("./somefile", setup="echo > somefile; chmod 100 somefile") - test("./somefile", setup="echo > somefile; chmod 200 somefile") - test("./somefile", setup="echo > somefile; chmod 300 somefile") - test("./somefile", setup="echo > somefile; chmod 400 somefile") - test("./somefile", setup="echo > somefile; chmod 500 somefile") - test("./somefile", setup="echo > somefile; chmod 600 somefile") - test("./somefile", setup="echo > somefile; chmod 700 somefile") - test("./somefile", setup="echo > somefile; chmod 755 somefile") - test("./somefile", setup="echo > somefile; chmod 644 somefile") - test("./somefile", setup="echo > somefile; chmod 311 somefile") - test("./somefile", setup="echo > somefile; chmod 111 somefile") - test("./somefile", setup="echo > somefile; chmod 222 somefile") - test("./somefile", setup="echo > somefile; chmod 333 somefile") - test("somedir/", setup="mkdir somedir", hook=hooks.is_directory) - test("./somedir/", setup="mkdir somedir", hook=hooks.is_directory) - test("somedir", setup="mkdir somedir") - test("./somedir", setup="mkdir somedir", hook=hooks.is_directory) - test("somedir", setup="mkdir somedir") - test("somedirsoftlink/", setup="mkdir somedir; ln -s somedir somedirsoftlink", hook=hooks.is_directory) - test("./somedirsoftlink/", setup="mkdir somedir; ln -s somedir somedirsoftlink", hook=hooks.is_directory) - test("somedirsoftlink", setup="mkdir somedir; ln -s somedir somedirsoftlink") - test("./somedirsoftlink", setup="mkdir somedir; ln -s somedir somedirsoftlink", hook=hooks.is_directory) - 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 a; mv a ./-") - test("./.", setup="touch .", hook=hooks.is_directory) - test("./..", setup="touch ..", hook=hooks.is_directory) - test("./somefile", setup='echo > somefile && chmod 0777 somefile') - test("./somefile", setup='echo > somefile && chmod 1000 somefile') - test("./somefile", setup='echo > somefile && chmod 2000 somefile') - test("./somefile", setup='echo > somefile && chmod 3000 somefile') - test("./somefile", setup='echo > somefile && chmod 4000 somefile') - test("./somefile", setup='echo > somefile && chmod 5000 somefile') - test("./somefile", setup='echo > somefile && chmod 6000 somefile') - test("./somefile", setup='echo > somefile && chmod 7000 somefile') - test("./somefile", setup='echo > somefile && chmod 1777 somefile') - test("./somefile", setup='echo > somefile && chmod 2777 somefile') - test("./somefile", setup='echo > somefile && chmod 3777 somefile') - test("./somefile", setup='echo > somefile && chmod 4777 somefile') - test("./somefile", setup='echo > somefile && chmod 5777 somefile') - test("./somefile", setup='echo > somefile && chmod 6777 somefile') - test("./somefile", setup='echo > somefile && chmod 7777 somefile') - test("./somefile", setup='echo > somefile && chmod 0000 somefile') - test("./somedir", setup='mkdir -m 0777 somedir', hook=hooks.is_directory) - test("./somedir", setup='mkdir -m 1000 somedir', hook=hooks.is_directory) - test("./somedir", setup='mkdir -m 2000 somedir', hook=hooks.is_directory) - test("./somedir", setup='mkdir -m 3000 somedir', hook=hooks.is_directory) - test("./somedir", setup='mkdir -m 4000 somedir', hook=hooks.is_directory) - test("./somedir", setup='mkdir -m 5000 somedir', hook=hooks.is_directory) - test("./somedir", setup='mkdir -m 6000 somedir', hook=hooks.is_directory) - test("./somedir", setup='mkdir -m 7000 somedir', hook=hooks.is_directory) - test("./somedir", setup='mkdir -m 1777 somedir', hook=hooks.is_directory) - test("./somedir", setup='mkdir -m 2777 somedir', hook=hooks.is_directory) - test("./somedir", setup='mkdir -m 3777 somedir', hook=hooks.is_directory) - test("./somedir", setup='mkdir -m 4777 somedir', hook=hooks.is_directory) - test("./somedir", setup='mkdir -m 5777 somedir', hook=hooks.is_directory) - test("./somedir", setup='mkdir -m 6777 somedir', hook=hooks.is_directory) - test("./somedir", setup='mkdir -m 0000 somedir', hook=hooks.is_directory) - test("./Somefile", setup='echo > somefile && chmod 000 somefile') - test("./someFILE", setup='echo > somefile && chmod 000 somefile') - - -# @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'") -# 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"') -# test("./somedir", setup='mkdir somedir && chmod 0000 somedir') diff --git a/src/suites/flow.py b/src/suites/flow.py deleted file mode 100644 index 2c00b2f..0000000 --- a/src/suites/flow.py +++ /dev/null @@ -1,290 +0,0 @@ -# ############################################################################ # -# # -# ::: :::::::: # -# flow.py :+: :+: :+: # -# +:+ +:+ +:+ # -# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # -# +#+#+#+#+#+ +#+ # -# Created: 2020/07/15 18:24:52 by charles #+# #+# # -# Updated: 2020/11/10 13:16:28 by cacharle ### ########.fr # -# # -# ############################################################################ # - -import config -from suite import suite -from hooks import error_line0, platform_status, discard, replace_double_semi_colon, error_eof_to_expected_token - - -@suite() -def suite_end(test): - """ `;` tests """ - 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", hook=error_line0, hook_status=platform_status(2, 1)) - test(" ;echo", hook=error_line0, hook_status=platform_status(2, 1)) - test(" ; echo", hook=error_line0, hook_status=platform_status(2, 1)) - 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") - test("echo a ; ;", hook=error_line0, hook_status=platform_status(2, 1)) - test("echo a ; ;", hook=error_line0, hook_status=platform_status(2, 1)) - test(";", hook=error_line0, hook_status=platform_status(2, 1)) - test("; ;", hook=error_line0, hook_status=platform_status(2, 1)) - test("; ; ;", hook=error_line0, hook_status=platform_status(2, 1)) - test("echo a ; ; echo b", hook=error_line0, hook_status=platform_status(2, 1)) - test(";;", hook=[error_line0, replace_double_semi_colon], hook_status=platform_status(2, 1)) - test(";;;", hook=[error_line0, replace_double_semi_colon], hook_status=platform_status(2, 1)) - test(";;;;;", hook=[error_line0, replace_double_semi_colon], hook_status=platform_status(2, 1)) - test("echo a ;; echo b", hook=[error_line0, replace_double_semi_colon], hook_status=platform_status(2, 1)) - test("echo a ;;;;; echo b", hook=[error_line0, replace_double_semi_colon], hook_status=platform_status(2, 1)) - test("ls " + 40 * " ; ls", setup="touch a b c") - test("ls " + 80 * " ; ls", setup="touch a b c") - test("ls " + 40 * " ; ls" + ";", setup="touch a b c") - test("ls " + 80 * " ; ls" + ";", setup="touch a b c") - - -@suite() -def suite_pipe(test): - """ `|` tests """ - test("cat /etc/shells | head -c 10") - test("cat -e /etc/shells | head -c 10") - test("cat -e /etc/shells | cat -e | head -c 10") - test("cat -e /etc/shells | cat -e | cat -e | head -c 10") - test("cat -e /dev/random | head -c 10", hook=discard) - test("cat -e /dev/random | cat -e | head -c 10", hook=discard) - test("cat -e /dev/random | cat -e | cat -e | head -c 10", hook=discard) - test("echo bonjour | cat") - test("echo bonjour | cat -e") - test("echo bonjour | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | 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") - test("echo|", hook=discard, hook_status=platform_status(2, 1)) - test("echo |", hook=discard, hook_status=platform_status(2, 1)) - test("echo | ", hook=discard, hook_status=platform_status(2, 1)) - test("|cat", hook=error_line0, hook_status=platform_status(2, 1)) - test("| cat", hook=error_line0, hook_status=platform_status(2, 1)) - test(" | cat", hook=error_line0, hook_status=platform_status(2, 1)) - test("echo a | export A=a; echo $A") - test("export A=a | cat; echo $A") - test("echo bonjour | | cat -e", hook=error_line0, hook_status=platform_status(2, 1)) - test("echo bonjour | asdf") - test("asdf | echo bonjour") - test("echo a ||| echo b", hook=error_line0, hook_status=platform_status(2, 1)) - test("ls " + 40 * " | ls", setup="touch a b c") - test("ls " + 80 * " | ls", setup="touch a b c") - test("echo bonjour " + 40 * " | cat -e") - test("echo bonjour " + 80 * " | cat -e") - test("ls asdfasdf | echo a") - test("echo a | ls asdfasdf") - test("ls asdfasdf | echo a; echo b") - test("echo a | ls asdfasdf; echo b") - test("echo a > foo | cat -e", files=["foo"]) - test("echo a >> foo | cat -e", files=["foo"]) - test("echo a | cat -e < foo", setup="echo b > foo") - test("echo a > bar | cat -e < foo", setup="echo b > foo", files=["bar"]) - - -@suite(bonus=True) -def suite_and(test): - """ `&&` tests """ - test("echo bonjour&& echo je") - test("echo bonjour &&echo je") - test("echo bonjour && echo je") - test("echo bonjour&&", hook=discard, hook_status=platform_status(2, 1)) - test("echo&& ", hook=discard, hook_status=platform_status(2, 1)) - test("echo && ", hook=discard, hook_status=platform_status(2, 1)) - test("echo &&", hook=discard, hook_status=platform_status(2, 1)) - test("&&echo", hook=error_line0, hook_status=platform_status(2, 1)) - test("&& echo", hook=error_line0, hook_status=platform_status(2, 1)) - test(" && echo", hook=error_line0, hook_status=platform_status(2, 1)) - 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") - test("ls " + 40 * " && ls", setup="touch a b c") - test("ls " + 80 * " && ls", setup="touch a b c") - - -@suite(bonus=True) -def suite_or(test): - """ `||` tests """ - test("echo bonjour|| echo je") - test("echo bonjour ||echo je") - test("echo bonjour || echo je") - test("echo bonjour||", hook=discard, hook_status=platform_status(2, 1)) - test("echo|| ", hook=discard, hook_status=platform_status(2, 1)) - test("echo || ", hook=discard, hook_status=platform_status(2, 1)) - test("echo ||", hook=discard, hook_status=platform_status(2, 1)) - test("||echo", hook=error_line0, hook_status=platform_status(2, 1)) - test("|| echo", hook=error_line0, hook_status=platform_status(2, 1)) - test(" || echo", hook=error_line0, hook_status=platform_status(2, 1)) - 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") - test("ls asdf" + 40 * " || ls asdf", setup="touch a b c") - test("ls asdf" + 80 * " || ls asdf", setup="touch a b c") - - -@suite(bonus=True) -def suite_parenthesis(test): - """ `(`, `)` tests """ - 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)") - test("(ls && ls) && echo $?") - test("(echo a; echo b) | cat -e") - test("echo bonjour | (cat -e; echo a)") - test("echo bonjour | (echo a; cat -e)") - test("(echo a) | (cat -e)") - test("(echo a; echo b) | (cat -e)") - test("(echo a) | (cat -e | cat -e)") - test("(echo a; echo b) | (cat -e | cat -e)") - test("(echo a; echo b) | cat -e | cat -e") - test("(echo a); (echo b) | (cat -e) | (cat -e)") - test("echo a | (cat -e | cat -e | cat -e)") - test("echo a | (cat -e | cat -e | cat -e) | cat -e") - test("(echo a) | (cat -e | cat -e | cat -e) | cat -e") - test("(echo a) | (cat -e | cat -e | cat -e) | (cat -e)") - test("(echo bonjour ; echo aurevoir) | (cat -e | cat -e) | cat -e") - test("( echo salut && echo bonjours ) ; echo comment ca va") - test("(cd /; echo $PWD; pwd); echo $PWD; pwd") - test("(export A=a; echo $A); echo $A") - test("(cat /etc/shells) | (cat -e) | (cat -e) | (cat -e)") - test("(cat /etc/shells) | (cat -e) | (cat -e) | (cat -e) | (cat -e) | (cat -e) | (cat -e) | (cat -e) | (cat -e)") - test("(cat /etc/shells | (cat -e) | (cat -e) | (cat -e)", - hook=[error_line0, error_eof_to_expected_token], hook_status=platform_status(2, 1)) - test("(cat /etc/shells) | (cat -e) | (cat -e | (cat -e)", - hook=[error_line0, error_eof_to_expected_token], hook_status=platform_status(2, 1)) - - -@suite() -def suite_syntax_error(test): - """ separator syntax error test """ - test("< | a", hook=error_line0, hook_status=platform_status(2, 1)) - test("> | a", hook=error_line0, hook_status=platform_status(2, 1)) - test(">> | a", hook=error_line0, hook_status=platform_status(2, 1)) - test("< ; a", hook=error_line0, hook_status=platform_status(2, 1)) - test("> ; a", hook=error_line0, hook_status=platform_status(2, 1)) - test(">> ; a", hook=error_line0, hook_status=platform_status(2, 1)) - test("; | a", hook=error_line0, hook_status=platform_status(2, 1)) - test("; < a", hook=error_line0, hook_status=platform_status(2, 1)) - test("; > a", hook=error_line0, hook_status=platform_status(2, 1)) - test("; >> a", hook=error_line0, hook_status=platform_status(2, 1)) - test("| ; a", hook=error_line0, hook_status=platform_status(2, 1)) - test("| < a", hook=error_line0, hook_status=platform_status(2, 1)) - test("| > a", hook=error_line0, hook_status=platform_status(2, 1)) - test("| >> a", hook=error_line0, hook_status=platform_status(2, 1)) - test("> a ; a", hook=error_line0) - test("< a ; a", hook=error_line0) - test(">> a ; a", hook=error_line0) - test(config.LOREM + " > >" + config.LOREM, hook=error_line0, hook_status=platform_status(2, 1)) - test(config.LOREM + " < <" + config.LOREM, hook=error_line0, hook_status=platform_status(2, 1)) - test(config.LOREM + " ; |" + config.LOREM, hook=error_line0, hook_status=platform_status(2, 1)) - test(config.LOREM + " | ;" + config.LOREM, hook=error_line0, hook_status=platform_status(2, 1)) - - -@suite(bonus=True) -def suite_syntax_error_bonus(test): - """ separator syntax error bonus test """ - test("< && a", hook=error_line0, hook_status=platform_status(2, 1)) - test("> && a", hook=error_line0, hook_status=platform_status(2, 1)) - test(">> && a", hook=error_line0, hook_status=platform_status(2, 1)) - test("< || a", hook=error_line0, hook_status=platform_status(2, 1)) - test("> || a", hook=error_line0, hook_status=platform_status(2, 1)) - test(">> || a", hook=error_line0, hook_status=platform_status(2, 1)) - test("< ( a", hook=error_line0, hook_status=platform_status(2, 1)) - test("> ( a", hook=error_line0, hook_status=platform_status(2, 1)) - test(">> ( a", hook=error_line0, hook_status=platform_status(2, 1)) - test("< ) a", hook=error_line0, hook_status=platform_status(2, 1)) - test("> ) a", hook=error_line0, hook_status=platform_status(2, 1)) - test(">> ) a", hook=error_line0, hook_status=platform_status(2, 1)) - test("&& < a", hook=error_line0, hook_status=platform_status(2, 1)) - test("&& > a", hook=error_line0, hook_status=platform_status(2, 1)) - test("&& >> a", hook=error_line0, hook_status=platform_status(2, 1)) - test("&& || a", hook=error_line0, hook_status=platform_status(2, 1)) - test("&& ( a", hook=error_line0, hook_status=platform_status(2, 1)) - test("&& ) a", hook=error_line0, hook_status=platform_status(2, 1)) - test("|| < a", hook=error_line0, hook_status=platform_status(2, 1)) - test("|| > a", hook=error_line0, hook_status=platform_status(2, 1)) - test("|| >> a", hook=error_line0, hook_status=platform_status(2, 1)) - test("|| && a", hook=error_line0, hook_status=platform_status(2, 1)) - test("|| ( a", hook=error_line0, hook_status=platform_status(2, 1)) - test("|| ) a", hook=error_line0, hook_status=platform_status(2, 1)) - test("( < a", hook=[error_line0, error_eof_to_expected_token], hook_status=platform_status(2, 1)) - test("( > a", hook=[error_line0, error_eof_to_expected_token], hook_status=platform_status(2, 1)) - test("( >> a", hook=[error_line0, error_eof_to_expected_token], hook_status=platform_status(2, 1)) - test(") < a", hook=error_line0, hook_status=platform_status(2, 1)) - test(") > a", hook=error_line0, hook_status=platform_status(2, 1)) - test(") >> a", hook=error_line0, hook_status=platform_status(2, 1)) - test("( && a", hook=error_line0, hook_status=platform_status(2, 1)) - test("( || a", hook=error_line0, hook_status=platform_status(2, 1)) - test("( ) a", hook=error_line0, hook_status=platform_status(2, 1)) - test(") && a", hook=error_line0, hook_status=platform_status(2, 1)) - test(") || a", hook=error_line0, hook_status=platform_status(2, 1)) - test(") ( a", hook=error_line0, hook_status=platform_status(2, 1)) - test("() a", hook=error_line0, hook_status=platform_status(2, 1)) - test("( a", hook=[error_line0, error_eof_to_expected_token], hook_status=platform_status(2, 1)) - test(") a", hook=error_line0, hook_status=platform_status(2, 1)) - test(config.LOREM + " && &&" + config.LOREM, hook=error_line0, hook_status=platform_status(2, 1)) - test(config.LOREM + " || ||" + config.LOREM, hook=error_line0, hook_status=platform_status(2, 1)) - test(config.LOREM + " ( (" + config.LOREM, hook=error_line0, hook_status=platform_status(2, 1)) - test(config.LOREM + " ) )" + config.LOREM, hook=error_line0, hook_status=platform_status(2, 1)) - test("(); () ;() ;() ;() ;() ;() ;() ;() ;() ;a", hook=error_line0, hook_status=platform_status(2, 1)) diff --git a/src/suites/misc.py b/src/suites/misc.py deleted file mode 100644 index a6b9bf2..0000000 --- a/src/suites/misc.py +++ /dev/null @@ -1,100 +0,0 @@ -# ############################################################################ # -# # -# ::: :::::::: # -# misc.py :+: :+: :+: # -# +:+ +:+ +:+ # -# By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ # -# +#+#+#+#+#+ +#+ # -# Created: 2020/10/10 13:06:19 by cacharle #+# #+# # -# Updated: 2020/11/28 06:10:12 by charles ### ########.fr # -# # -# ############################################################################ # - -from suite import suite - - -@suite() -def suite_shlvl(test): - """ test for the SHLVL variable """ - test("echo $SHLVL") - test("echo $SHLVL", exports={"SHLVL": ""}) - test("echo $SHLVL", exports={"SHLVL": " 1"}) - test("echo $SHLVL", exports={"SHLVL": " 2"}) - test("echo $SHLVL", exports={"SHLVL": " 3"}) - test("echo $SHLVL", exports={"SHLVL": " ' 3'"}) - test("echo $SHLVL", exports={"SHLVL": " '\t3'"}) - test("echo $SHLVL", exports={"SHLVL": " '\t\f\r 3'"}) - test("echo $SHLVL", exports={"SHLVL": " '3 '"}) - test("echo $SHLVL", exports={"SHLVL": " '3\t'"}) - test("echo $SHLVL", exports={"SHLVL": " '3\r'"}) - test("echo $SHLVL", exports={"SHLVL": " '3\t\f\r '"}) - test("echo $SHLVL", exports={"SHLVL": " '3 a'"}) - test("echo $SHLVL", exports={"SHLVL": " '3\t\t\ta'"}) - test("echo $SHLVL", exports={"SHLVL": " 0"}) - test("echo $SHLVL", exports={"SHLVL": " -0"}) - test("echo $SHLVL", exports={"SHLVL": " -1"}) - test("echo $SHLVL", exports={"SHLVL": " 255"}) - test("echo $SHLVL", exports={"SHLVL": " 256"}) - test("echo $SHLVL", exports={"SHLVL": " 2000000"}) - test("echo $SHLVL", exports={"SHLVL": " -2000000"}) - test("echo $SHLVL", exports={"SHLVL": " 2147483647"}) - test("echo $SHLVL", exports={"SHLVL": " -2147483648"}) - test("echo $SHLVL", exports={"SHLVL": " 2147483648"}) - test("echo $SHLVL", exports={"SHLVL": " -2147483649"}) - test("echo $SHLVL", exports={"SHLVL": " 3147483648"}) - test("echo $SHLVL", exports={"SHLVL": " -3147483649"}) - test("echo $SHLVL", exports={"SHLVL": " 4294967295"}) - test("echo $SHLVL", exports={"SHLVL": " 4294967296"}) - test("echo $SHLVL", exports={"SHLVL": " -9223372036854775808"}) - test("echo $SHLVL", exports={"SHLVL": " 9223372036854775807"}) - test("echo $SHLVL", exports={"SHLVL": " -9223372036854775809"}) - test("echo $SHLVL", exports={"SHLVL": " 9223372036854775808"}) - test("echo $SHLVL", exports={"SHLVL": " 18446744073709551615"}) - test("echo $SHLVL", exports={"SHLVL": " 18446744073709551616"}) - test("echo $SHLVL", exports={"SHLVL": " +1"}) - test("echo $SHLVL", exports={"SHLVL": " +2"}) - test("echo $SHLVL", exports={"SHLVL": " +3"}) - test("echo $SHLVL", exports={"SHLVL": " +0"}) - test("echo $SHLVL", exports={"SHLVL": " +255"}) - test("echo $SHLVL", exports={"SHLVL": " +256"}) - test("echo $SHLVL", exports={"SHLVL": " +2000000"}) - test("echo $SHLVL", exports={"SHLVL": " +2147483647"}) - test("echo $SHLVL", exports={"SHLVL": " ++1"}) - test("echo $SHLVL", exports={"SHLVL": " ++2"}) - test("echo $SHLVL", exports={"SHLVL": " ++3"}) - test("echo $SHLVL", exports={"SHLVL": " ++0"}) - test("echo $SHLVL", exports={"SHLVL": " ++255"}) - test("echo $SHLVL", exports={"SHLVL": " ++256"}) - test("echo $SHLVL", exports={"SHLVL": " ++2000000"}) - test("echo $SHLVL", exports={"SHLVL": " ++2147483647"}) - test("echo $SHLVL", exports={"SHLVL": " --1"}) - test("echo $SHLVL", exports={"SHLVL": " --2"}) - test("echo $SHLVL", exports={"SHLVL": " --3"}) - test("echo $SHLVL", exports={"SHLVL": " --0"}) - test("echo $SHLVL", exports={"SHLVL": " --255"}) - test("echo $SHLVL", exports={"SHLVL": " --256"}) - test("echo $SHLVL", exports={"SHLVL": " --2000000"}) - test("echo $SHLVL", exports={"SHLVL": " --2147483647"}) - test("echo $SHLVL", exports={"SHLVL": " bonjour"}) - test("echo $SHLVL", exports={"SHLVL": " 0_"}) - test("echo $SHLVL", exports={"SHLVL": " _0"}) - test("echo $SHLVL", exports={"SHLVL": " 0123456789"}) - test("echo $SHLVL", exports={"SHLVL": " -0123456789"}) - test("echo $SHLVL", exports={"SHLVL": " 00000000000000000000000000000000000000000000001"}) - test("echo $SHLVL", exports={"SHLVL": " 00000000000000000000000000000000000000000000000" - "00000000000000000000000000000000000000000000001"}) - - -@suite() -def suite_lastcmd(test): - """ test for $_, the last executed command """ - test("echo $_") - test("echo; echo $_") - test("env; echo $_") - test("export A=a; echo $_") - test("unset A; echo $_") - test("echo a b c d; echo $_") - test("cat -e /etc/shells; echo $_") - test("echo a; echo \"$_\"") - test("echo a; echo '$_'") - test("echo a; echo \"@$_@\"") diff --git a/src/suites/path.py b/src/suites/path.py deleted file mode 100644 index 93d4232..0000000 --- a/src/suites/path.py +++ /dev/null @@ -1,137 +0,0 @@ -# ############################################################################ # -# # -# ::: :::::::: # -# path.py :+: :+: :+: # -# +:+ +:+ +:+ # -# By: charles <me@cacharle.xyz> +#+ +:+ +#+ # -# +#+#+#+#+#+ +#+ # -# Created: 2020/09/09 15:12:58 by charles #+# #+# # -# Updated: 2021/02/04 16:14:20 by charles ### ########.fr # -# # -# ############################################################################ # - -import distutils.spawn - -from suite import suite - - -@suite() -def suite_path(test): - """ searching a command in the path tests """ - whoami_path = distutils.spawn.find_executable("which") - if whoami_path is None: - print("Couldn't find `whoami` in your PATH: Skipping suite") - return - mode_fmt = ("mkdir path && cp " - + whoami_path - + " ./path/a && chmod {} ./path/a") - test("a", setup=mode_fmt.format("000"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("001"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("002"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("003"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("004"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("005"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("006"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("007"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("010"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("020"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("030"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("040"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("050"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("060"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("070"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("100"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("200"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("300"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("400"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("500"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("600"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("700"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("755"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("644"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("311"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("111"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("222"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("333"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("0777"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("1000"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("2000"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("3000"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("4000"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("5000"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("6000"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("7000"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("1777"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("2777"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("3777"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("4777"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("5777"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("6777"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("7777"), exports={"PATH": "path"}) - test("a", setup=mode_fmt.format("0000"), exports={"PATH": "path"}) - test("A", setup=mode_fmt.format("000"), exports={"PATH": "path"}) - # test("b", setup="mkdir path && cp " + whoami_path + " ./path/a && ln -s ./path/a ./path/b", - # exports={"PATH": "path"}) - test("b", setup="mkdir path && ln -s " + whoami_path + " ./path/b", exports={"PATH": "path"}) - test("a", setup="mkdir path && mkfifo path/a") - test("a", setup="mkdir path && mkfifo path/a && chmod 777 path/a") - # test("a", setup="mkdir path1 path2 && cp " + whoami_path + " path1/a" - # "&& cp " + whoami_path + " path2/a && chmod 000 path1/a", exports={"PATH": "path1:path2"}) - test("a", setup="mkdir path1 path2 && cp " + whoami_path + " path1/a" - "&& cp " + whoami_path + " path2/a && chmod 000 path1/a", exports={"PATH": "path2:path1"}) - test("a/b", setup="mkdir -p path/a; cp " + whoami_path + " path/a/b", exports={"PATH": "path"}) - - -@suite() -def suite_path_variable(test): - """ $PATH environment variable tests """ - test("echo $PATH", exports={"PATH": "doesnotexits"}) - test("echo $PATH", exports={"PATH": "doesnotexits:asdfasdfas"}) - test("echo $PATH", 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"}) - test("echo $PATH", exports={"PATH": "________"}) - test("echo $PATH", exports={"PATH": " "}) - test("echo $PATH", exports={"PATH": " : "}) - test("echo $PATH", exports={"PATH": " /bin "}) - test("echo $PATH", exports={"PATH": " /sbin "}) - test("echo $PATH", exports={"PATH": "/bin:/bin:/bin:/bin"}) - test("echo $PATH", exports={"PATH": "/sbin:/sbin:/sbin:/sbin"}) - test("echo $PATH", exports={"PATH": ""}) - test("echo $PATH", exports={"PATH": ":"}) - test("echo $PATH", exports={"PATH": ":::::::::::::::::::"}) - test("echo $PATH", exports={"PATH": "/asdfasdf"}) - test("echo $PATH", exports={"PATH": "/usr/asdf:/usr/lib/asdfasdf"}) - test("whoami", exports={"PATH": "doesnotexits"}) - test("whoami", exports={"PATH": "doesnotexits:asdfasdfas"}) - test("whoami", 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"}) - test("whoami", exports={"PATH": "________"}) - test("whoami", exports={"PATH": " "}) - test("whoami", exports={"PATH": " : "}) - test("whoami", exports={"PATH": " /usr/bin "}) - test("whoami", exports={"PATH": "/usr/bin:/usr/bin:/usr/bin:/usr/bin"}) - test("whoami", exports={"PATH": " /sbin "}) - test("whoami", exports={"PATH": "/sbin:/sbin:/sbin:/sbin"}) - test("whoami", exports={"PATH": ""}) # error message explicit enough - test("unset PATH; whoami") # error message explicit enough - test("whoami", exports={"PATH": ":"}) - test("whoami", exports={"PATH": ":::::::::::::::::::"}) - test("whoami", exports={"PATH": "/asdfasdf"}) - test("whoami", exports={"PATH": "/usr/asdf:/usr/lib/asdfasdf"}) - test("whoami", setup="unset PATH") - create_cmd_setup = "echo '#!/bin/sh\necho bonjour' > somecmd; chmod +x somecmd" - test("somecmd", setup=create_cmd_setup, exports={"PATH": ""}) - test("somecmd", setup=create_cmd_setup, exports={"PATH": ":"}) - test("somecmd", setup=create_cmd_setup, exports={"PATH": "::::::::"}) - test("somecmd", setup=create_cmd_setup, exports={"PATH": "/asdfasdf"}) - test("somecmd", setup=create_cmd_setup, exports={"PATH": "/usr/asdf:/usr/lib/asdfasdf"}) - test("somecmd", setup=create_cmd_setup + "; unset PATH") - test("somecmd", setup=create_cmd_setup, exports={"PATH": "/bin:"}) - test("somecmd", setup=create_cmd_setup, exports={"PATH": ":/bin"}) - test("somecmd", setup=create_cmd_setup, exports={"PATH": ":/bin:"}) - test("Whoami", exports={"PATH": "/usr/bin"}) - test("wHoAMi", exports={"PATH": "/usr/bin"}) - test("whoami", exports={"PATH": "/usr/bIn"}) - test("whoami", exports={"PATH": "/Usr/bin"}) - test("Whoami", exports={"PATH": "/usr/bIn"}) - test("wHoami", exports={"PATH": "/Usr/bin"}) - test("Whoami", exports={"PATH": ""}) - test("wHoami", exports={"PATH": ""}) diff --git a/src/suites/preprocess.py b/src/suites/preprocess.py deleted file mode 100644 index 0176399..0000000 --- a/src/suites/preprocess.py +++ /dev/null @@ -1,463 +0,0 @@ -# **************************************************************************** # -# # -# ::: :::::::: # -# preprocess.py :+: :+: :+: # -# +:+ +:+ +:+ # -# By: juligonz <juligonz@student.42.fr> +#+ +:+ +#+ # -# +#+#+#+#+#+ +#+ # -# Created: 2020/07/15 18:25:00 by charles #+# #+# # -# Updated: 2021/01/21 13:06:55 by charles ### ########.fr # -# # -# **************************************************************************** # - -import config -import hooks -from suite import suite - - -@suite() -def suite_quote(test): - """ double and single quote test, escape in quotes, quote missmatch """ - 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('echo "\\a"') - test('echo "\\A"') - 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") - test('""""""""""""""""""""""""""""""""""""""""""""""""""""""""""echo bonjour') - test("echo'' bonjour") - test('echo"" bonjour') - test("echo'''''''''''''''''''''''''''''''''''''''''''''''''''''''''' bonjour") - test('echo"""""""""""""""""""""""""""""""""""""""""""""""""""""""""" bonjour') - test("ec''ho bonjour") - 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 '\"'") - test("echo '\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"'") - test('echo "\'"') - test('echo "\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'"') - test("echo '", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) - test('echo "', hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) - test("echo '''", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) - test('echo """', hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) - test("echo '''''''''''''''''''''''''''''''''''''''''''", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) - test('echo """""""""""""""""""""""""""""""""""""""""""', hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) - test("echo 'AH\\'") - test('echo "AH\\"', hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) - test('echo "AH\\""') - test("echo '\\''", hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) - test('echo "\\""') - test('echo "\\\\""', hook=hooks.error_line0, hook_status=hooks.platform_status(2, 1)) - test('echo bonjour > "fi le"', files=['fi le']) - test("echo bonjour > 'fi le'", files=['fi le']) - - -@suite() -def suite_interpolation(test): - """environment variable interpolation tests, valid name, escape in variable""" - 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\\\\"}) - test("echo [$A]", exports={"A": r"\b\\o\\\nj\\\\\\\our\\je\\\\ "}) - test("echo [$A]", exports={"A": r" \b\\o\\\nj\\\\\\\our\\je\\\\ "}) - test("echo [$A]", exports={"A": r"a \b\\o\\\nj\\\\\\\our\\je\\\\ b"}) - test("echo [$A]", exports={"A": r" a \b\\o\\\nj\\\\\\\our\\je\\\\ b "}) - test("echo [$A]", exports={"A": r" "}) - 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 "}) - 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 "}) - 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 "}) - 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 "}) - 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 "}) - test('echo $A$A$A', exports={"A": " bonjour je suis splited "}) - 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": " "}) - test("echo $A", exports={"A": " "}) - 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": " "}) - 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": " "}) - 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": " "}) - 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$B$C', exports={"A": "", "B": "", "C": ""}) - test('echo bonjour > $A', exports={"A": 'file'}, files=['file']) - test('echo bonjour > $A', exports={"A": 'fi le'}, files=['fi le'], hook=hooks.error_line0) - test('echo bonjour > "$A"', exports={"A": 'fi le'}, files=['fi le']) - test("echo bonjour > '$A'", exports={"A": 'fi le'}, files=['fi le']) - - -@suite() -def suite_escape(test): - """ escape test, in command, with space, before quote """ - test(r"echo \a") - test(r"\e\c\h\o bonjour") - test(r"echo charles\ ") - test(r"echo \ \ jesuis\ \ charles") - test(r"echo \ \ jesuis\; \ charles") - test(r"echo \ \ jesuis\&\& \ charles") - test(r"echo \ \ jesuis\|\| \ charles") - test(r"echo \ \ jesuis \|\| \ 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") - test(r"\ echo bonjour") - test(r" \ echo bonjour") - test(r" \ echo bonjour") - test(r" \ echo bonjour") - test(r" \ echo bonjour") - test(r'/bin/echo " \ "') - test(r'/bin/echo " \" "') - test(r'/bin/echo " \' "') - test(r'/bin/echo " \a "') - test(r'/bin/echo " \b "') - test(r'/bin/echo " \| "') - test(r'/bin/echo " \! "') - test(r'/bin/echo " \@ "') - test(r'/bin/echo " \$ "') - test(r'/bin/echo " \$LESS "') - test(r'/bin/echo " \$? "') - test(r'/bin/echo " \\ "') - test(r'/bin/echo " \\\ "') - test(r'/bin/echo " \\\\ "') - test(r'/bin/echo " \\\\\ "') - test(r'/bin/echo " \\\\\\ "') - test(r'/bin/echo " \\\\\\\ "') - test(r'/bin/echo " \\\\\\\\ "') - test(r"/bin/echo ' \ '") - test(r"/bin/echo ' \" '") - test(r"/bin/echo ' \a '") - test(r"/bin/echo ' \b '") - test(r"/bin/echo ' \| '") - test(r"/bin/echo ' \! '") - test(r"/bin/echo ' \@ '") - test(r"/bin/echo ' \$ '") - test(r"/bin/echo ' $LESS '") - test(r"/bin/echo ' \$? '") - test(r"/bin/echo ' \\ '") - test(r"/bin/echo ' \\\ '") - test("echo \\", hook=hooks.delete_escape) - test("echo \"\\\"\"'bonjour'") - - -@suite() -def suite_spaces(test): - """ field splitting with spaces and tabs """ - 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") - test("\fecho\ffoo", hook=hooks.should_not_be("foo\n")) - test("\necho\nfoo", hook=hooks.should_not_be("foo\n")) - test("\recho\rfoo", hook=hooks.should_not_be("foo\n")) - test("\vecho\vfoo", hook=hooks.should_not_be("foo\n")) - test("\t\r\v\fecho\v\t\r\vfoo", hook=hooks.should_not_be("foo\n")) - test("") - test(" ") - test("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t") - test(" \t\t\t \t\t\t ") - - -# @suite(bonus=True) -# 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 /*") -# test("echo /etc/*") -# test("echo /usr/include/*.h") -# # test("echo /*/*", timeout=10) -# # test("echo /usr/*/*", timeout=10) -# test("echo /usr/*") -# test("echo /dev/*") -# test("echo /etc/*") -# test("echo /root/*") -# test("echo /usr*") -# test("echo /dev*") -# test("echo /etc*") -# test("echo /root*") -# -# test("echo *nothing") -# test("echo nothing*") -# test("echo *nothing*") -# -# test("echo a*b", setup="touch ab aab aaaaab aaaaaaaab acccccb acb abbbb") -# test("echo a**b", setup="touch ab aab aaaaab aaaaaaaab acccccb acb abbbb") -# test("echo a***b", setup="touch ab aab aaaaab aaaaaaaab acccccb acb abbbb") -# test("echo a****b", setup="touch ab aab aaaaab aaaaaaaab acccccb acb abbbb") -# -# 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") -# -# test("*") -# test("*", setup="touch a b c") -# test("*.c", setup="touch a b c foo.c bar.c") -# test("src/*.c", setup="mkdir src; touch src/a src/b src/c src/foo.c src/bar.c") -# test("*/*.c", setup="mkdir src; touch src/a src/b src/c src/foo.c src/bar.c") -# test("*/*.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("export A=*; echo $A") -# test("A=*; echo $A") -# -# test("echo *", setup="mkdir d1; touch d1/a d1/b d1/c; ln -s d1 d1link") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; ln -s d1 d1link") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; ln -s d1 .d1link") -# test("echo */*", setup="mkdir .d1; touch .d1/a .d1/b .d1/c; ln -s .d1 d1link") -# test("echo .*/*", setup="mkdir d1; touch d1/a d1/b d1/c; ln -s d1 .d1link") -# test("echo .*/*", setup="mkdir .d1; touch .d1/a .d1/b .d1/c; ln -s .d1 d1link") -# -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 000 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 001 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 002 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 003 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 004 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 005 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 006 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 007 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 010 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 020 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 030 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 040 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 050 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 060 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 070 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 100 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 200 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 300 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 400 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 500 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 600 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 700 d1/a") -# -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 755 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 644 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 311 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 111 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 222 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 333 d1/a") -# -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 000 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 001 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 002 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 003 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 004 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 005 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 006 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 007 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 010 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 020 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 030 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 040 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 050 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 060 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 070 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 100 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 200 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 300 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 400 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 500 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 600 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 700 d1") -# -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 755 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 644 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 311 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 111 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 222 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 333 d1") -# -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 0777 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 1000 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 2000 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 3000 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 4000 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 5000 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 6000 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 7000 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 1777 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 2777 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 3777 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 4777 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 5777 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 6777 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 7777 d1/a") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 0000 d1/a") -# -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 0777 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 1000 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 2000 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 3000 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 4000 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 5000 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 6000 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 7000 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 1777 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 2777 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 3777 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 4777 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 5777 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 6777 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 7777 d1") -# test("echo */*", setup="mkdir d1; touch d1/a d1/b d1/c; chmod 0000 d1") -# -# test("echo *", setup="touch a; ln -s a b") -# test("echo *", setup="touch a; ln -s a b; ln -s b c") -# 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"}) |
