diff options
Diffstat (limited to 'tests/test/script/builtin')
-rw-r--r-- | tests/test/script/builtin/cat.test | 40 | ||||
-rw-r--r-- | tests/test/script/builtin/mkdir.test | 30 | ||||
-rw-r--r-- | tests/test/script/builtin/rm.test | 41 | ||||
-rw-r--r-- | tests/test/script/builtin/touch.test | 27 |
4 files changed, 111 insertions, 27 deletions
diff --git a/tests/test/script/builtin/cat.test b/tests/test/script/builtin/cat.test index 5049ca9..20cdb86 100644 --- a/tests/test/script/builtin/cat.test +++ b/tests/test/script/builtin/cat.test @@ -2,66 +2,82 @@ # copyright : Copyright (c) 2014-2016 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -# @@ I think these should be run indirectly (via cat & build) -# for cross-testing to work (we want to run the via the build -# system we built, not the one we used to acomplish this. +.include ../common.test : in : -cat <<EOI >>EOO +$c <<EOI; +cat <<EOF >>EOO foo bar -EOI +EOF foo bar EOO +EOI +$b : dash : -cat - <<EOI >>EOO +$c <<EOI; +cat - <<EOF >>EOO foo bar -EOI +EOF foo bar EOO +EOI +$b : file : -cat <<EOI >>>out; +$c <<EOI; +cat <<EOF >>>out; foo bar -EOI +EOF cat out >>EOO foo bar EOO +EOI +$b : in-repeat : -cat - <<EOI >>EOO +$c <<EOI; +cat - <<EOF >>EOO foo bar -EOI +EOF foo bar EOO +EOI +$b : non-existent : : Note that there is an optional trailing blank line in the regex that matches : the newline added by msvcrt as a part of the error description. : +$c <<EOI; cat in 2>>~%EOE% != 0 -%cat: unable to print '.+[/\\]test[/\\]cat[/\\]non-existent[/\\]in': .+% +%cat: unable to print '.+[/\\]test[/\\]cat[/\\]non-existent[/\\]test[/\\]1[/\\]in': .+% %%? EOE +EOI +$b : empty-path : : Cat an empty path. : +$c <<EOI; cat '' 2>"cat: invalid path ''" == 1 +EOI +$b # @@ When piping is ready test cat on a big file to test it is asynchronous. # diff --git a/tests/test/script/builtin/mkdir.test b/tests/test/script/builtin/mkdir.test index dafcd35..07b6090 100644 --- a/tests/test/script/builtin/mkdir.test +++ b/tests/test/script/builtin/mkdir.test @@ -2,38 +2,54 @@ # copyright : Copyright (c) 2014-2016 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file +.include ../common.test + : dirs : +$c <<EOI; mkdir a b; touch a/a b/b +EOI +$b : parent : +$c <<EOI; mkdir -p a/b; touch a/a a/b/b +EOI +$b : exists : -mkdir -p a a a/b a/b +$c <'mkdir -p a a a/b a/b'; +$b : double-dash : : Make sure '-p' directory is created. : +$c <<EOI; mkdir -p -- -p; touch -p/a +EOI +$b : no-args : : Test passing no arguments. : -mkdir 2>"mkdir: missing directory" == 1 +$c <'mkdir 2>"mkdir: missing directory" == 1'; +$b : empty-path : : Test creation of empty directory path. : +$c <<EOI; mkdir '' 2>"mkdir: invalid path ''" == 1 +EOI +$b : already-exists : @@ -42,10 +58,13 @@ mkdir '' 2>"mkdir: invalid path ''" == 1 : Note that there is an optional trailing blank line in the regex that matches : the newline added by msvcrt as a part of the error description. : +$c <<EOI; mkdir a a 2>>~%EOE% == 1 -%mkdir: unable to create directory '.+[/\\]test[/\\]mkdir[/\\]already-exists[/\\]a': .+% +%mkdir: unable to create directory '.+[/\\]test[/\\]mkdir[/\\]already-exists[/\\]test[/\\]1[/\\]a': .+% %%? EOE +EOI +$b : not-exists : @@ -54,7 +73,10 @@ EOE : Note that there is an optional trailing blank line in the regex that matches : the newline added by msvcrt as a part of the error description. : +$c <<EOI; mkdir a/b 2>>~%EOE% == 1 -%mkdir: unable to create directory '.+[/\\]test[/\\]mkdir[/\\]not-exists[/\\]a[/\\]b': .+% +%mkdir: unable to create directory '.+[/\\]test[/\\]mkdir[/\\]not-exists[/\\]test[/\\]1[/\\]a[/\\]b': .+% %%? EOE +EOI +$b diff --git a/tests/test/script/builtin/rm.test b/tests/test/script/builtin/rm.test index 20b2b24..9a18de1 100644 --- a/tests/test/script/builtin/rm.test +++ b/tests/test/script/builtin/rm.test @@ -2,32 +2,40 @@ # copyright : Copyright (c) 2014-2016 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -td = $~ +.include ../common.test : no-args : : Removing with no arguments fails. : -rm 2>"rm: missing file" == 1 +$c <'rm 2>"rm: missing file" == 1'; +$b : no-args-force : : Removing with no arguments succeeds with -f option. : -rm -f +$c <'rm -f'; +$b : empty-path : : Removing an empty path fails. : +$c <<EOI; rm '' 2>"rm: invalid path ''" == 1 +EOI +$b : file : : Removing existing file succeeds. : +$c <<EOI; touch a &!a; rm a +EOI +$b : file-not-exists : @@ -36,36 +44,49 @@ rm a : Note that there is an optional trailing blank line in the regex that matches : the newline added by msvcrt as a part of the error description. : +$c <<EOI; rm a 2>>~%EOE% == 1 -%rm: unable to remove '.+[/\\]test[/\\]rm[/\\]file-not-exists[/\\]a': .+% +%rm: unable to remove '.+[/\\]test[/\\]rm[/\\]file-not-exists[/\\]test[/\\]1[/\\]a': .+% %%? EOE +EOI +$b : file-not-exists-force : : Removing non-existing file succeeds with -f option. : -rm -f a +$c <'rm -f a'; +$b : dir : : Removing directory fails by default. : +$c <<EOI; mkdir a; rm a 2>"rm: '$normalize([path] $~/a)' is a directory" == 1 +EOI +$b : dir-recursive : : Removing directory succeeds with -r option. : +$c <<EOI; mkdir -p a/b &!a &!a/b; rm -r a +EOI +$b : scope-dir : : Removing scope directory fails. : +$c <<EOI; rm -r ./ 2>"rm: '([string] $~)' contains test working directory '$~'" == 1 +EOI +$b : outside-scope : @@ -73,7 +94,12 @@ rm -r ./ 2>"rm: '([string] $~)' contains test working directory '$~'" == 1 : path that unlikely exists (not to remove something useful). : : -rm ../../a/b/c 2>"rm: '$normalize([path] $~/../../a/b/c)' is out of working directory '$td'" == 1 +$c <<EOI; +rm ../../a/b/c 2>>~%EOE% == 1 +%rm: '.+[/\\]outside-scope[/\\]a[/\\]b[/\\]c' is out of working directory '.+[/\\]outside-scope[/\\]test'% +EOE +EOI +$b : outside-scope-force : @@ -81,4 +107,5 @@ rm ../../a/b/c 2>"rm: '$normalize([path] $~/../../a/b/c)' is out of working dire : option. Need to use a path that unlikely exists (not to remove something : useful). : -rm -f ../../a/b/c +$c <'rm -f ../../a/b/c'; +$b diff --git a/tests/test/script/builtin/touch.test b/tests/test/script/builtin/touch.test index da9ed91..3aa0271 100644 --- a/tests/test/script/builtin/touch.test +++ b/tests/test/script/builtin/touch.test @@ -2,54 +2,73 @@ # copyright : Copyright (c) 2014-2016 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file +.include ../common.test + : file : -touch a +$c <'touch a'; +$b : file-create : : Test that file is created. If it didn't then 'rm' would fail. : +$c <<EOI; touch a &!a; rm a +EOI +$b : file-update : : Test that existing file touch doesn't fail. : +$c <<EOI; cat <"" >>>a; touch a +EOI +$b : no-cleanup : -: Test that touching an existing file doesn't register cleanup. If it does then +: Test that touches an existing file doesn't register cleanup. If it does then : the file would be removed while leaving the embedded scope, and so the : cleanup registered by the first touch would fail. : +$c <<EOI; { +touch a { touch ../a } } +EOI +$b : no-args : : Test passing no arguments. : -touch 2>"touch: missing file" == 1 +$c <'touch 2>"touch: missing file" == 1'; +$b : empty-path : : Test touching an empty path. : +$c <<EOI; touch '' 2>"touch: invalid path ''" == 1 +EOI +$b : dir-update : : Test touching an existing directory. : +$c <<EOI; a = $~; a += "a"; mkdir a; -touch 2>"touch: '$a' exists and is not a file" a == 1 +touch a 2>"touch: '$a' exists and is not a file" == 1 +EOI +$b |