From 5007870b52aa549971824959a55ad3bb886f09e0 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 3 Sep 2018 16:37:32 +0200 Subject: Rename .test/test{} to .testscript/testscript{} --- tests/test/script/builtin/buildfile | 2 +- tests/test/script/builtin/cat.test | 84 ------- tests/test/script/builtin/cat.testscript | 84 +++++++ tests/test/script/builtin/cp.test | 376 ----------------------------- tests/test/script/builtin/cp.testscript | 376 +++++++++++++++++++++++++++++ tests/test/script/builtin/echo.test | 27 --- tests/test/script/builtin/echo.testscript | 27 +++ tests/test/script/builtin/ln.test | 184 -------------- tests/test/script/builtin/ln.testscript | 184 ++++++++++++++ tests/test/script/builtin/mkdir.test | 66 ----- tests/test/script/builtin/mkdir.testscript | 66 +++++ tests/test/script/builtin/mv.test | 252 ------------------- tests/test/script/builtin/mv.testscript | 252 +++++++++++++++++++ tests/test/script/builtin/rm.test | 119 --------- tests/test/script/builtin/rm.testscript | 119 +++++++++ tests/test/script/builtin/rmdir.test | 114 --------- tests/test/script/builtin/rmdir.testscript | 114 +++++++++ tests/test/script/builtin/sed.test | 333 ------------------------- tests/test/script/builtin/sed.testscript | 333 +++++++++++++++++++++++++ tests/test/script/builtin/test.test | 69 ------ tests/test/script/builtin/test.testscript | 69 ++++++ tests/test/script/builtin/touch.test | 88 ------- tests/test/script/builtin/touch.testscript | 88 +++++++ 23 files changed, 1713 insertions(+), 1713 deletions(-) delete mode 100644 tests/test/script/builtin/cat.test create mode 100644 tests/test/script/builtin/cat.testscript delete mode 100644 tests/test/script/builtin/cp.test create mode 100644 tests/test/script/builtin/cp.testscript delete mode 100644 tests/test/script/builtin/echo.test create mode 100644 tests/test/script/builtin/echo.testscript delete mode 100644 tests/test/script/builtin/ln.test create mode 100644 tests/test/script/builtin/ln.testscript delete mode 100644 tests/test/script/builtin/mkdir.test create mode 100644 tests/test/script/builtin/mkdir.testscript delete mode 100644 tests/test/script/builtin/mv.test create mode 100644 tests/test/script/builtin/mv.testscript delete mode 100644 tests/test/script/builtin/rm.test create mode 100644 tests/test/script/builtin/rm.testscript delete mode 100644 tests/test/script/builtin/rmdir.test create mode 100644 tests/test/script/builtin/rmdir.testscript delete mode 100644 tests/test/script/builtin/sed.test create mode 100644 tests/test/script/builtin/sed.testscript delete mode 100644 tests/test/script/builtin/test.test create mode 100644 tests/test/script/builtin/test.testscript delete mode 100644 tests/test/script/builtin/touch.test create mode 100644 tests/test/script/builtin/touch.testscript (limited to 'tests/test/script/builtin') diff --git a/tests/test/script/builtin/buildfile b/tests/test/script/builtin/buildfile index 7338d4c..83ecfd2 100644 --- a/tests/test/script/builtin/buildfile +++ b/tests/test/script/builtin/buildfile @@ -2,4 +2,4 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -./: test{*} file{cp-dir/cp-file} $b +./: testscript{*} file{cp-dir/cp-file} $b diff --git a/tests/test/script/builtin/cat.test b/tests/test/script/builtin/cat.test deleted file mode 100644 index 69ff578..0000000 --- a/tests/test/script/builtin/cat.test +++ /dev/null @@ -1,84 +0,0 @@ -# file : tests/test/script/builtin/cat.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: in -: -$c <>EOO -foo -bar -EOF -foo -bar -EOO -EOI - -: dash -: -$c <>EOO -foo -bar -EOF -foo -bar -EOO -EOI - -: file -: -$c <=out; -foo -bar -EOF -cat out >>EOO -foo -bar -EOO -EOI - -: in-repeat -: -$c <>EOO -foo -bar -EOF -foo -bar -EOO -EOI - -: non-existent -: -$c <>/~%EOE% != 0 -%cat: unable to print '.+/test/cat/non-existent/test/1/in': .+% -EOE -EOI - -: empty-path -: -: Cat an empty path. -: -$c <"cat: invalid path ''" == 1 -EOI - -: big -: -: Cat a big file (about 100K) to test that the builtin is asynchronous. -: -{ - $c <"$s" - EOI -} diff --git a/tests/test/script/builtin/cat.testscript b/tests/test/script/builtin/cat.testscript new file mode 100644 index 0000000..b72edb4 --- /dev/null +++ b/tests/test/script/builtin/cat.testscript @@ -0,0 +1,84 @@ +# file : tests/test/script/builtin/cat.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: in +: +$c <>EOO +foo +bar +EOF +foo +bar +EOO +EOI + +: dash +: +$c <>EOO +foo +bar +EOF +foo +bar +EOO +EOI + +: file +: +$c <=out; +foo +bar +EOF +cat out >>EOO +foo +bar +EOO +EOI + +: in-repeat +: +$c <>EOO +foo +bar +EOF +foo +bar +EOO +EOI + +: non-existent +: +$c <>/~%EOE% != 0 +%cat: unable to print '.+/test/cat/non-existent/test/1/in': .+% +EOE +EOI + +: empty-path +: +: Cat an empty path. +: +$c <"cat: invalid path ''" == 1 +EOI + +: big +: +: Cat a big file (about 100K) to test that the builtin is asynchronous. +: +{ + $c <"$s" + EOI +} diff --git a/tests/test/script/builtin/cp.test b/tests/test/script/builtin/cp.test deleted file mode 100644 index e81b395..0000000 --- a/tests/test/script/builtin/cp.test +++ /dev/null @@ -1,376 +0,0 @@ -# file : tests/test/script/builtin/cp.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: args -: -{ - : none - : - $c <'cp 2>"cp: missing arguments" == 1' && $b - - : no-source - : - $c <'cp -R a 2>"cp: missing source path" == 1' && $b - - : no-trailing-sep - : - $c <"cp: multiple source paths without trailing separator for destination directory" == 1 - EOI - - : empty - : - { - : dest - : - $c <"cp: invalid path ''" == 1 - EOI - - : src1 - : - $c <"cp: invalid path ''" == 1 - EOI - - : src2 - : - $c <"cp: invalid path ''" == 1 - EOI - } -} - -: file -: -: Test synopsis 1: make a file copy at the specified path. -: -{ - : existing - : - { - : to-non-existing - : - $c <>/~%EOE% != 0 - %cp: unable to copy file '.+/a' to '.+/b': .+% - EOE - EOI - } - - : non-existing - : - { - $c <>/~%EOE% != 0 - %cp: unable to copy file '.+/a' to '.+/b': .+% - EOE - EOI - } - - : non-file - : - { - $c <>/~%EOE% != 0 - %cp: unable to copy file '.+/a' to '.+/b': .+% - EOE - EOI - } - - : cleanup - : - { - : existing - : - : Test that copy over an existing file does not register cleanup. If it - : does then the file would be removed while leaving the embedded scope, - : and so the cleanup registered by the outer touch would fail. - : - $c <>/~%EOE% != 0 - %cp: unable to copy directory '.+/a' to '.+/b': .+% - EOE - EOI - - : to-file - : - $c <>/~%EOE% != 0 - %cp: unable to copy directory '.+/a' to '.+/b': .+% - EOE - EOI - - : recursively - : - { - $c <>/~%EOE% != 0 - %cp: unable to copy directory '.+/a' to '.+/b': .+% - EOE - EOI - } - - : non-dir - : - { - $c <>/~%EOE% != 0 - %cp: unable to copy directory '.+/a' to '.+/b': .+% - EOE - EOI - } -} - -: files -: -: Test synopsis 3: copy files into the specified directory. -: -{ - : existing - : - { - : into-dir - : - { - : over-non-existing - : - $c <>/~%EOE% != 0 - %cp: unable to copy file '.+/a' to '.+/b/a': .+% - EOE - EOI - - : multiple - : - $c <>/~%EOE% != 0 - %cp: unable to copy file '.+/a' to '.+/b/a': .+% - EOE - EOI - } - - : into-non-dir - : - { - $c <>/~%EOE% != 0 - %cp: unable to copy file '.+/a' to '.+/b/a': .+% - EOE - EOI - } - } - - : non-existing - : - { - $c <>/~%EOE% != 0 - %cp: unable to copy file '.+/a' to '.+/b/a': .+% - EOE - EOI - } - - : non-file - : - { - $c <>/~%EOE% != 0 - %cp: unable to copy file '.+/a' to '.+/b/a': .+% - EOE - EOI - } -} - -: filesystem-entries -: -: Test synopsis 4: copy filesystem entries into the specified directory. -: -{ - : file - : - { - $c <>/~%EOE% != 0 - %cp: unable to copy directory '.+/a' to '.+/b/a': .+% - EOE - EOI - } -} - -: attrs -: -if ($cxx.target.class != 'windows') -{ - fs = 's/.+ (\S+\s+\S+\s+\S+)\s+cp-file/\1/p' - ds = 's/.+ (\S+\s+\S+\s+\S+)\s+cp-dir/\1/p' - - : copy - : - { - : file - : - { - $c <<"EOI" && $b - ls -l $src_base/cp-dir | sed -n -e '$fs' | \ - set t; - - cp -p $src_base/cp-dir/cp-file ./; - ls -l | sed -n -e '$fs' >"\$t" - EOI - } - - : dir - : - { - $c <<"EOI" && $b - ls -l $src_base | sed -n -e '$ds' | \ - set t; - - cp -p -r $src_base/cp-dir ./; - ls -l | sed -n -e '$ds' >"\$t" - EOI - } - } - - : no-copy - : - { - : file - : - { - $c <<"EOI" && $b 2>>~%EOE% != 0 - ls -l $src_base/cp-dir | sed -n -e '$fs' | \ - set t; - - cp $src_base/cp-dir/cp-file ./; - ls -l | sed -n -e '$fs' >"\$t" - EOI - %.+ error: sed stdout doesn't match expected% - %.+ - EOE - } - - : dir - : - { - $c <<"EOI" && $b 2>>~%EOE% != 0 - ls -l $src_base | sed -n -e '$ds' | \ - set t; - - cp -r $src_base/cp-dir ./; - ls -l | sed -n -e '$ds' >"\$t" - EOI - %.+ error: sed stdout doesn't match expected% - %.+ - EOE - } - } -} diff --git a/tests/test/script/builtin/cp.testscript b/tests/test/script/builtin/cp.testscript new file mode 100644 index 0000000..e1b654f --- /dev/null +++ b/tests/test/script/builtin/cp.testscript @@ -0,0 +1,376 @@ +# file : tests/test/script/builtin/cp.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: args +: +{ + : none + : + $c <'cp 2>"cp: missing arguments" == 1' && $b + + : no-source + : + $c <'cp -R a 2>"cp: missing source path" == 1' && $b + + : no-trailing-sep + : + $c <"cp: multiple source paths without trailing separator for destination directory" == 1 + EOI + + : empty + : + { + : dest + : + $c <"cp: invalid path ''" == 1 + EOI + + : src1 + : + $c <"cp: invalid path ''" == 1 + EOI + + : src2 + : + $c <"cp: invalid path ''" == 1 + EOI + } +} + +: file +: +: Test synopsis 1: make a file copy at the specified path. +: +{ + : existing + : + { + : to-non-existing + : + $c <>/~%EOE% != 0 + %cp: unable to copy file '.+/a' to '.+/b': .+% + EOE + EOI + } + + : non-existing + : + { + $c <>/~%EOE% != 0 + %cp: unable to copy file '.+/a' to '.+/b': .+% + EOE + EOI + } + + : non-file + : + { + $c <>/~%EOE% != 0 + %cp: unable to copy file '.+/a' to '.+/b': .+% + EOE + EOI + } + + : cleanup + : + { + : existing + : + : Test that copy over an existing file does not register cleanup. If it + : does then the file would be removed while leaving the embedded scope, + : and so the cleanup registered by the outer touch would fail. + : + $c <>/~%EOE% != 0 + %cp: unable to copy directory '.+/a' to '.+/b': .+% + EOE + EOI + + : to-file + : + $c <>/~%EOE% != 0 + %cp: unable to copy directory '.+/a' to '.+/b': .+% + EOE + EOI + + : recursively + : + { + $c <>/~%EOE% != 0 + %cp: unable to copy directory '.+/a' to '.+/b': .+% + EOE + EOI + } + + : non-dir + : + { + $c <>/~%EOE% != 0 + %cp: unable to copy directory '.+/a' to '.+/b': .+% + EOE + EOI + } +} + +: files +: +: Test synopsis 3: copy files into the specified directory. +: +{ + : existing + : + { + : into-dir + : + { + : over-non-existing + : + $c <>/~%EOE% != 0 + %cp: unable to copy file '.+/a' to '.+/b/a': .+% + EOE + EOI + + : multiple + : + $c <>/~%EOE% != 0 + %cp: unable to copy file '.+/a' to '.+/b/a': .+% + EOE + EOI + } + + : into-non-dir + : + { + $c <>/~%EOE% != 0 + %cp: unable to copy file '.+/a' to '.+/b/a': .+% + EOE + EOI + } + } + + : non-existing + : + { + $c <>/~%EOE% != 0 + %cp: unable to copy file '.+/a' to '.+/b/a': .+% + EOE + EOI + } + + : non-file + : + { + $c <>/~%EOE% != 0 + %cp: unable to copy file '.+/a' to '.+/b/a': .+% + EOE + EOI + } +} + +: filesystem-entries +: +: Test synopsis 4: copy filesystem entries into the specified directory. +: +{ + : file + : + { + $c <>/~%EOE% != 0 + %cp: unable to copy directory '.+/a' to '.+/b/a': .+% + EOE + EOI + } +} + +: attrs +: +if ($cxx.target.class != 'windows') +{ + fs = 's/.+ (\S+\s+\S+\s+\S+)\s+cp-file/\1/p' + ds = 's/.+ (\S+\s+\S+\s+\S+)\s+cp-dir/\1/p' + + : copy + : + { + : file + : + { + $c <<"EOI" && $b + ls -l $src_base/cp-dir | sed -n -e '$fs' | \ + set t; + + cp -p $src_base/cp-dir/cp-file ./; + ls -l | sed -n -e '$fs' >"\$t" + EOI + } + + : dir + : + { + $c <<"EOI" && $b + ls -l $src_base | sed -n -e '$ds' | \ + set t; + + cp -p -r $src_base/cp-dir ./; + ls -l | sed -n -e '$ds' >"\$t" + EOI + } + } + + : no-copy + : + { + : file + : + { + $c <<"EOI" && $b 2>>~%EOE% != 0 + ls -l $src_base/cp-dir | sed -n -e '$fs' | \ + set t; + + cp $src_base/cp-dir/cp-file ./; + ls -l | sed -n -e '$fs' >"\$t" + EOI + %.+ error: sed stdout doesn't match expected% + %.+ + EOE + } + + : dir + : + { + $c <<"EOI" && $b 2>>~%EOE% != 0 + ls -l $src_base | sed -n -e '$ds' | \ + set t; + + cp -r $src_base/cp-dir ./; + ls -l | sed -n -e '$ds' >"\$t" + EOI + %.+ error: sed stdout doesn't match expected% + %.+ + EOE + } + } +} diff --git a/tests/test/script/builtin/echo.test b/tests/test/script/builtin/echo.test deleted file mode 100644 index 28647f4..0000000 --- a/tests/test/script/builtin/echo.test +++ /dev/null @@ -1,27 +0,0 @@ -# file : tests/test/script/builtin/echo.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: string -: -$c <'echo foo >foo' && $b - -: strings -: -$c <'echo foo bar >"foo bar"' && $b - -: big -: -: Echo a big string (about 100K) to test that the builtin is asynchronous. -: -{ - $c <"$s" - EOI -} diff --git a/tests/test/script/builtin/echo.testscript b/tests/test/script/builtin/echo.testscript new file mode 100644 index 0000000..235a9f7 --- /dev/null +++ b/tests/test/script/builtin/echo.testscript @@ -0,0 +1,27 @@ +# file : tests/test/script/builtin/echo.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: string +: +$c <'echo foo >foo' && $b + +: strings +: +$c <'echo foo bar >"foo bar"' && $b + +: big +: +: Echo a big string (about 100K) to test that the builtin is asynchronous. +: +{ + $c <"$s" + EOI +} diff --git a/tests/test/script/builtin/ln.test b/tests/test/script/builtin/ln.test deleted file mode 100644 index 8b4c30e..0000000 --- a/tests/test/script/builtin/ln.test +++ /dev/null @@ -1,184 +0,0 @@ -# file : tests/test/script/builtin/ln.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: args -: -{ - : -s-option - : - $c <'ln 2>"ln: missing -s option" == 1' && $b - - : none - : - $c <'ln -s 2>"ln: missing arguments" == 1' && $b - - : no-target - : - $c <'ln -s a 2>"ln: missing target path" == 1' && $b - - : no-trailing-sep - : - $c <"ln: multiple target paths with non-directory link path" == 1 - EOI - - : empty - : - { - : link - : - $c <"ln: invalid path ''" == 1 - EOI - - : target1 - : - $c <"ln: invalid path ''" == 1 - EOI - - : target2 - : - $c <"ln: invalid path ''" == 1 - EOI - } -} - -: file -: -: Test creating a file symlink. -: -{ - : non-existing-link-path - : - $c <>/~%EOE% != 0 - %( - %ln: unable to create .+link '.+/b' to '.+/a': .+%| - %ln: unable to copy file '.+/a' to '.+/b': .+% - %) - EOE - EOI - - : dir - : - $c <>/~%EOE% != 0 - %( - %ln: unable to create .+link '.+/b' to '.+/a': .+%| - %ln: unable to copy file '.+/a' to '.+/b': .+% - %) - EOE - EOI - } - - : non-existing - { - : target - : - $c <>/~%EOE% != 0 - %ln: unable to create symlink to '.+/a': no such file or directory% - EOE - EOI - - : link-dir - : - $c <>/~%EOE% != 0 - %( - %ln: unable to create .+link '.+/b/c' to '.+/a': .+%| - %ln: unable to copy file '.+/a' to '.+/b/c': .+% - %) - EOE - EOI - } -} - -: dir -: -: Test creating a directory symlink. -: -{ - : non-existing-link-path - : - $c <>/~%EOE% != 0 - %( - %ln: unable to create .+link '.+/b' to '.+/a': .+%| - %ln: unable to copy directory '.+/a' to '.+/b': .+% - %) - EOE - EOI - - : file - : - $c <>/~%EOE% != 0 - %( - %ln: unable to create .+link '.+/b' to '.+/a': .+%| - %ln: unable to copy directory '.+/a' to '.+/b': .+% - %) - EOE - EOI - } - - : non-existing - { - : link-dir - : - $c <>/~%EOE% != 0 - %( - %ln: unable to create .+link '.+/b/c' to '.+/a': .+%| - %ln: unable to copy directory '.+/a' to '.+/b/c': .+% - %) - EOE - EOI - } -} - -: multiple-targets -: -: Test creating links for multiple targets in the specified directory. -: -{ - $c <"ln: missing -s option" == 1' && $b + + : none + : + $c <'ln -s 2>"ln: missing arguments" == 1' && $b + + : no-target + : + $c <'ln -s a 2>"ln: missing target path" == 1' && $b + + : no-trailing-sep + : + $c <"ln: multiple target paths with non-directory link path" == 1 + EOI + + : empty + : + { + : link + : + $c <"ln: invalid path ''" == 1 + EOI + + : target1 + : + $c <"ln: invalid path ''" == 1 + EOI + + : target2 + : + $c <"ln: invalid path ''" == 1 + EOI + } +} + +: file +: +: Test creating a file symlink. +: +{ + : non-existing-link-path + : + $c <>/~%EOE% != 0 + %( + %ln: unable to create .+link '.+/b' to '.+/a': .+%| + %ln: unable to copy file '.+/a' to '.+/b': .+% + %) + EOE + EOI + + : dir + : + $c <>/~%EOE% != 0 + %( + %ln: unable to create .+link '.+/b' to '.+/a': .+%| + %ln: unable to copy file '.+/a' to '.+/b': .+% + %) + EOE + EOI + } + + : non-existing + { + : target + : + $c <>/~%EOE% != 0 + %ln: unable to create symlink to '.+/a': no such file or directory% + EOE + EOI + + : link-dir + : + $c <>/~%EOE% != 0 + %( + %ln: unable to create .+link '.+/b/c' to '.+/a': .+%| + %ln: unable to copy file '.+/a' to '.+/b/c': .+% + %) + EOE + EOI + } +} + +: dir +: +: Test creating a directory symlink. +: +{ + : non-existing-link-path + : + $c <>/~%EOE% != 0 + %( + %ln: unable to create .+link '.+/b' to '.+/a': .+%| + %ln: unable to copy directory '.+/a' to '.+/b': .+% + %) + EOE + EOI + + : file + : + $c <>/~%EOE% != 0 + %( + %ln: unable to create .+link '.+/b' to '.+/a': .+%| + %ln: unable to copy directory '.+/a' to '.+/b': .+% + %) + EOE + EOI + } + + : non-existing + { + : link-dir + : + $c <>/~%EOE% != 0 + %( + %ln: unable to create .+link '.+/b/c' to '.+/a': .+%| + %ln: unable to copy directory '.+/a' to '.+/b/c': .+% + %) + EOE + EOI + } +} + +: multiple-targets +: +: Test creating links for multiple targets in the specified directory. +: +{ + $c <"mkdir: missing directory" == 1' && $b - -: empty-path -: -: Test creation of empty directory path. -: -$c <"mkdir: invalid path ''" == 1 -EOI - -: already-exists -: -: Test creation of an existing directory. -: -$c <>/~%EOE% == 1 -%mkdir: unable to create directory '.+/test/mkdir/already-exists/test/1/a': .+% -EOE -EOI - -: not-exists -: -: Test creation of a directory with non-existent parent. -: -$c <>/~%EOE% == 1 -%mkdir: unable to create directory '.+/test/mkdir/not-exists/test/1/a/b': .+% -EOE -EOI diff --git a/tests/test/script/builtin/mkdir.testscript b/tests/test/script/builtin/mkdir.testscript new file mode 100644 index 0000000..6b082bd --- /dev/null +++ b/tests/test/script/builtin/mkdir.testscript @@ -0,0 +1,66 @@ +# file : tests/test/script/builtin/mkdir.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: dirs +: +$c <"mkdir: missing directory" == 1' && $b + +: empty-path +: +: Test creation of empty directory path. +: +$c <"mkdir: invalid path ''" == 1 +EOI + +: already-exists +: +: Test creation of an existing directory. +: +$c <>/~%EOE% == 1 +%mkdir: unable to create directory '.+/test/mkdir/already-exists/test/1/a': .+% +EOE +EOI + +: not-exists +: +: Test creation of a directory with non-existent parent. +: +$c <>/~%EOE% == 1 +%mkdir: unable to create directory '.+/test/mkdir/not-exists/test/1/a/b': .+% +EOE +EOI diff --git a/tests/test/script/builtin/mv.test b/tests/test/script/builtin/mv.test deleted file mode 100644 index 291832e..0000000 --- a/tests/test/script/builtin/mv.test +++ /dev/null @@ -1,252 +0,0 @@ -# file : tests/test/script/builtin/mv.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: args -: -{ - : none - : - $c <'mv 2>"mv: missing arguments" == 1' && $b - - : no-source - : - $c <'mv a 2>"mv: missing source path" == 1' && $b - - : no-trailing-sep - : - $c <"mv: multiple source paths without trailing separator for destination directory" == 1 - EOI - - : empty - : - { - : dest - : - $c <"mv: invalid path ''" == 1 - EOI - - : src1 - : - $c <"mv: invalid path ''" == 1 - EOI - - : src2 - : - $c <"mv: invalid path ''" == 1 - EOI - } -} - -: synopsis-1 -: -: Move an entity to the specified path. -: -{ - : file - : - { - : existing - : - { - : to-non-existing - : - $c <>/~%EOE% != 0 - %mv: unable to move entity '.+/a' to itself% - EOE - EOI - - : to-dir - : - $c <>/~%EOE% != 0 - %mv: unable to move entity '.+/a' to '.+/b': .+% - EOE - EOI - } - - : outside-scope - : - : Need to use a path that unlikely exists (not to remove something useful). - : - { - : fail - : - : Moving path outside the testscript working directory fails. - : - $c <>/~%EOE% == 1 - %mv: '.+/fail/a/b/c' is out of working directory '.+/fail/test'% - EOE - EOI - - : force - : - : Moving path outside the testscript working directory is allowed with -f - : option. We fail after this check succeeds as the source path does not - : exist. - : - $c <>/~%EOE% == 1 - %mv: unable to move entity '.+/force/a/b/c' to '.+/c': .+% - EOE - EOI - } - - : cleanup - : - { - : existing - : - : Test that moving over an existing file does not move the cleanup. If - : it does, then the file would be removed while leaving the embedded - : scope, and so the cleanup registered by the outer touch would fail. We - : also test that the source path cleanup is removed, otherwise it would - : fail. - : - $c <>/~%EOE% != 0 - %mv: unable to move entity '.+/a' to '.+/b': .+% - EOE - EOI - - : to-non-dir - : - $c <>/~%EOE% != 0 - %mv: unable to move entity '.+/a' to '.+/b': .+% - EOE - EOI - } - - : working-dir - : - { - : src - : - { - $c <"mv: '([string] $~)' contains test working directory '$~'" != 0 - EOI - } - - : dst - : - { - $c <"mv: '$~' contains test working directory '$~'" != 0 - EOI - } - } - - : overlap - : - $c <>/~%EOE% != 0 - %mv: unable to move entity '.+/a' to '.+/a/b': .+% - EOE - EOI - - : cleanup - : - { - : sub-entry - : - { - mkdir a; - touch a/b; - mv a c - } - - : reorder - : - : Test that a/, that is created before b/ and so should be removed after - : it, get removed before b/ after being renamed to b/c. - : - $c <>/~%EOE% != 0 - %mv: unable to move entity '.+/a' to '.+/b': .+% - EOE - EOI - } -} - -: synopsis-2 -: -: Move entities into the specified directory. -: -{ - $c <"mv: missing arguments" == 1' && $b + + : no-source + : + $c <'mv a 2>"mv: missing source path" == 1' && $b + + : no-trailing-sep + : + $c <"mv: multiple source paths without trailing separator for destination directory" == 1 + EOI + + : empty + : + { + : dest + : + $c <"mv: invalid path ''" == 1 + EOI + + : src1 + : + $c <"mv: invalid path ''" == 1 + EOI + + : src2 + : + $c <"mv: invalid path ''" == 1 + EOI + } +} + +: synopsis-1 +: +: Move an entity to the specified path. +: +{ + : file + : + { + : existing + : + { + : to-non-existing + : + $c <>/~%EOE% != 0 + %mv: unable to move entity '.+/a' to itself% + EOE + EOI + + : to-dir + : + $c <>/~%EOE% != 0 + %mv: unable to move entity '.+/a' to '.+/b': .+% + EOE + EOI + } + + : outside-scope + : + : Need to use a path that unlikely exists (not to remove something useful). + : + { + : fail + : + : Moving path outside the testscript working directory fails. + : + $c <>/~%EOE% == 1 + %mv: '.+/fail/a/b/c' is out of working directory '.+/fail/test'% + EOE + EOI + + : force + : + : Moving path outside the testscript working directory is allowed with -f + : option. We fail after this check succeeds as the source path does not + : exist. + : + $c <>/~%EOE% == 1 + %mv: unable to move entity '.+/force/a/b/c' to '.+/c': .+% + EOE + EOI + } + + : cleanup + : + { + : existing + : + : Test that moving over an existing file does not move the cleanup. If + : it does, then the file would be removed while leaving the embedded + : scope, and so the cleanup registered by the outer touch would fail. We + : also test that the source path cleanup is removed, otherwise it would + : fail. + : + $c <>/~%EOE% != 0 + %mv: unable to move entity '.+/a' to '.+/b': .+% + EOE + EOI + + : to-non-dir + : + $c <>/~%EOE% != 0 + %mv: unable to move entity '.+/a' to '.+/b': .+% + EOE + EOI + } + + : working-dir + : + { + : src + : + { + $c <"mv: '([string] $~)' contains test working directory '$~'" != 0 + EOI + } + + : dst + : + { + $c <"mv: '$~' contains test working directory '$~'" != 0 + EOI + } + } + + : overlap + : + $c <>/~%EOE% != 0 + %mv: unable to move entity '.+/a' to '.+/a/b': .+% + EOE + EOI + + : cleanup + : + { + : sub-entry + : + { + mkdir a; + touch a/b; + mv a c + } + + : reorder + : + : Test that a/, that is created before b/ and so should be removed after + : it, get removed before b/ after being renamed to b/c. + : + $c <>/~%EOE% != 0 + %mv: unable to move entity '.+/a' to '.+/b': .+% + EOE + EOI + } +} + +: synopsis-2 +: +: Move entities into the specified directory. +: +{ + $c <"rm: missing file" == 1' && $b - - : force - : - : Removing with no arguments succeeds with -f option. - : - $c <'rm -f' && $b -} - -: file -: -{ - : exists - : - : Removing existing file succeeds. - : - $c <>/~%EOE% == 1 - %rm: unable to remove '.+/file/not-exists/fail/test/1/a': .+% - EOE - EOI - - : force - : - : Removing non-existing file succeeds with -f option. - : - $c <'rm -f a' && $b - } -} - -: dir -: -{ - : default - : - : Removing directory fails by default. - : - $c <"rm: '$normalize([path] $~/a)' is a directory" == 1 - EOI - - : recursive - : - : Removing directory succeeds with -r option. - : - $c <"rm: '([string] $~)' contains test working directory '$~'" == 1 - EOI -} - -: path -: -{ - : empty - : - : Removing an empty path fails. - : - $c <"rm: invalid path ''" == 1 - EOI - - : outside-scope - : - : Need to use a path that unlikely exists (not to remove something useful). - : - { - : fail - : - : Removing path outside the testscript working directory fails. - : - $c <>/~%EOE% == 1 - %rm: '.+/path/outside-scope/fail/a/b/c' is out of working directory '.+/path/outside-scope/fail/test'% - EOE - EOI - - : force - : - : Removing path outside the testscript working directory succeeds with -f - : option. - : - $c <'rm -f ../../a/b/c' && $b - } -} diff --git a/tests/test/script/builtin/rm.testscript b/tests/test/script/builtin/rm.testscript new file mode 100644 index 0000000..3dd2674 --- /dev/null +++ b/tests/test/script/builtin/rm.testscript @@ -0,0 +1,119 @@ +# file : tests/test/script/builtin/rm.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: no-args +: +{ + : fail + : + : Removing with no arguments fails. + : + $c <'rm 2>"rm: missing file" == 1' && $b + + : force + : + : Removing with no arguments succeeds with -f option. + : + $c <'rm -f' && $b +} + +: file +: +{ + : exists + : + : Removing existing file succeeds. + : + $c <>/~%EOE% == 1 + %rm: unable to remove '.+/file/not-exists/fail/test/1/a': .+% + EOE + EOI + + : force + : + : Removing non-existing file succeeds with -f option. + : + $c <'rm -f a' && $b + } +} + +: dir +: +{ + : default + : + : Removing directory fails by default. + : + $c <"rm: '$normalize([path] $~/a)' is a directory" == 1 + EOI + + : recursive + : + : Removing directory succeeds with -r option. + : + $c <"rm: '([string] $~)' contains test working directory '$~'" == 1 + EOI +} + +: path +: +{ + : empty + : + : Removing an empty path fails. + : + $c <"rm: invalid path ''" == 1 + EOI + + : outside-scope + : + : Need to use a path that unlikely exists (not to remove something useful). + : + { + : fail + : + : Removing path outside the testscript working directory fails. + : + $c <>/~%EOE% == 1 + %rm: '.+/path/outside-scope/fail/a/b/c' is out of working directory '.+/path/outside-scope/fail/test'% + EOE + EOI + + : force + : + : Removing path outside the testscript working directory succeeds with -f + : option. + : + $c <'rm -f ../../a/b/c' && $b + } +} diff --git a/tests/test/script/builtin/rmdir.test b/tests/test/script/builtin/rmdir.test deleted file mode 100644 index 0e53bde..0000000 --- a/tests/test/script/builtin/rmdir.test +++ /dev/null @@ -1,114 +0,0 @@ -# file : tests/test/script/builtin/rmdir.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: no-args -: -{ - : fail - : - : Removing with no arguments fails. - : - $c <'rmdir 2>"rmdir: missing directory" == 1' && $b - - : force - : - : Removing with no arguments succeeds with -f option. - : - $c <'rmdir -f' && $b -} - -: dir -: -{ - : empty-path - : - : Removing an empty path fails. - : - $c <"rmdir: invalid path ''" == 1 - EOI - - : test-scope - : - : Removing scope directory fails. - : - $c <"rmdir: '$~' contains test working directory '$~'" == 1 - EOI - - : outside-scope - : - : Need to use a path that unlikely exists (not to remove something useful). - : - { - : fail - : - : Removing directory outside the testscript working directory fails. - : - $c <>/~%EOE% == 1 - %rmdir: '.+/dir/outside-scope/fail/a/b/c' is out of working directory '.+/dir/outside-scope/fail/test'% - EOE - EOI - - : force - : - : Removing path outside the testscript working directory succeeds with -f - : option. - : - $c <'rmdir -f ../../a/b/c' && $b - } - - : exists - : - : Removing existing directory succeeds. - : - $c <>/~%EOE% == 1 - %rmdir: unable to remove '.+/dir/not-exists/fail/test/1/a': .+% - EOE - EOI - - : force - : - : Removing non-existing directory succeeds with -f option. - : - $c <'rmdir -f a' && $b - } - - : not-empty - : - : Removing non-empty directory fails. - : - $c <>/~%EOE% == 1 - %rmdir: unable to remove '.+/dir/not-empty/test/1/a': .+% - EOE - EOI - - : not-dir - : - : Removing not a directory path fails. - : - $c <>/~%EOE% == 1 - %rmdir: unable to remove '.+/dir/not-dir/test/1/a': .+% - EOE - EOI -} diff --git a/tests/test/script/builtin/rmdir.testscript b/tests/test/script/builtin/rmdir.testscript new file mode 100644 index 0000000..99dcaf1 --- /dev/null +++ b/tests/test/script/builtin/rmdir.testscript @@ -0,0 +1,114 @@ +# file : tests/test/script/builtin/rmdir.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: no-args +: +{ + : fail + : + : Removing with no arguments fails. + : + $c <'rmdir 2>"rmdir: missing directory" == 1' && $b + + : force + : + : Removing with no arguments succeeds with -f option. + : + $c <'rmdir -f' && $b +} + +: dir +: +{ + : empty-path + : + : Removing an empty path fails. + : + $c <"rmdir: invalid path ''" == 1 + EOI + + : test-scope + : + : Removing scope directory fails. + : + $c <"rmdir: '$~' contains test working directory '$~'" == 1 + EOI + + : outside-scope + : + : Need to use a path that unlikely exists (not to remove something useful). + : + { + : fail + : + : Removing directory outside the testscript working directory fails. + : + $c <>/~%EOE% == 1 + %rmdir: '.+/dir/outside-scope/fail/a/b/c' is out of working directory '.+/dir/outside-scope/fail/test'% + EOE + EOI + + : force + : + : Removing path outside the testscript working directory succeeds with -f + : option. + : + $c <'rmdir -f ../../a/b/c' && $b + } + + : exists + : + : Removing existing directory succeeds. + : + $c <>/~%EOE% == 1 + %rmdir: unable to remove '.+/dir/not-exists/fail/test/1/a': .+% + EOE + EOI + + : force + : + : Removing non-existing directory succeeds with -f option. + : + $c <'rmdir -f a' && $b + } + + : not-empty + : + : Removing non-empty directory fails. + : + $c <>/~%EOE% == 1 + %rmdir: unable to remove '.+/dir/not-empty/test/1/a': .+% + EOE + EOI + + : not-dir + : + : Removing not a directory path fails. + : + $c <>/~%EOE% == 1 + %rmdir: unable to remove '.+/dir/not-dir/test/1/a': .+% + EOE + EOI +} diff --git a/tests/test/script/builtin/sed.test b/tests/test/script/builtin/sed.test deleted file mode 100644 index 71824a1..0000000 --- a/tests/test/script/builtin/sed.test +++ /dev/null @@ -1,333 +0,0 @@ -# file : tests/test/script/builtin/sed.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: arg -: -{ - : auto-prn - : - { - $c <"sed -n -e 's/fox/bar/' <'foo' " && $b : on - $c <"sed -e 's/fox/bar/' <'foo' >'foo'" && $b : off - } - - : script - : - { - : missed - : - $c <'sed' && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: missing script - EOE - - : missed-val - : - $c <'sed -e' && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: missing script - EOE - - : empty - : - $c <"sed -e ''" && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: empty script - EOE - - : multiple - : - $c <"sed -e 's/a//' -e 's/a//'" && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: multiple scripts - EOE - - : invalid - : - $c <"sed -e 'z'" && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: only 's' command supported - EOE - } - - : file - : - { - : exist - : - $c <=f; - sed -e 's/foo/bar/' f >'bar' - EOI - - : none - : - $c <'bar' - EOI - - : dash - : - $c <'bar' - EOI - - : not-exist - : - $c <"sed -e 's/foo/bar/' f" && $b 2>>/~%EOE% != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - %sed: unable to edit '.+/1/f': .+% - EOE - - : empty - : - $c <"sed -e 's/foo/bar/' ''" && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: invalid path '' - EOE - } - - : unexpected - : - $c <"sed -e 's/a//' a b" && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: unexpected argument - EOE -} - -: command -: -{ - : subst - : - { - : parsing - : - { - : delim - : - { - : none - : - $c <"sed -e 's'" && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: no delimiter for 's' command - EOE - - : invalid - : - $c <"sed -e 's\\'" && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: invalid delimiter for 's' command - EOE - } - - : regex - : - { - : unterminated - : - $c <"sed -e 's/foo'" && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: unterminated 's' command regex - EOE - - : empty - : - $c <"sed -e 's///'" && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: empty regex in 's' command - EOE - - : invalid - : - : Note that old versions of libc++ (for example 1.1) do not detect some - : regex errors. For example '*' is parsed successfully. - : - $c <"sed -e 's/foo[/bar/'" && $b 2>>/~%EOE% != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - %sed: invalid regex.*% - EOE - } - - : unterminated-replacement - : - $c <"sed -e 's/foo/bar'" && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: unterminated 's' command replacement - EOE - - : invalid-flags - : - $c <"sed -e 's/foo/bar/a'" && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: invalid 's' command flag 'a' - EOE - } - - : exec - : - { - : flags - : - { - : global - : - { - $c <"sed -e 's/o/a/g' <'foo' >'faa'" && $b : on - $c <"sed -e 's/o/a/' <'foo' >'fao'" && $b : off - } - - : icase - : - { - $c <"sed -e 's/O/a/i' <'foo' >'fao'" && $b : on - $c <"sed -e 's/O/a/' <'foo' >'foo'" && $b : off - } - - : print - : - { - $c <"sed -n -e 's/o/a/p' <'foo' >'fao'" && $b : on-match - $c <"sed -n -e 's/o/a/' <'foo' " && $b : off-match - $c <"sed -n -e 's/u/a/p' <'foo' " && $b : on-no-match - } - } - - : search - { - : anchor - : - { - $c <"sed -n -e 's/^o/a/gp' <'oof' >'aof'" && $b : begin - $c <"sed -n -e 's/o\$/a/gp' <'foo' >'foa'" && $b : end - } - - : match - : Match corner cases - : - { - $c <"sed -n -e 's/a/b/p' <'a' >'b' " && $b : full - $c <"sed -n -e 's/a/b/p' <'ac' >'bc' " && $b : left - $c <"sed -n -e 's/a/b/p' <'ca' >'cb' " && $b : right - $c <"sed -n -e 's/a/b/pg' <'xaax' >'xbbx'" && $b : adjacent - } - } - - : replacement - : - { - : ecma-escape - : - { - $c <"sed <'xay' -e 's/a/\$b/' >'x\$by'" && $b : none - $c <"sed <'xay' -e 's/a/\$/' >'x\$y' " && $b : none-term - $c <"sed <'xay' -e 's/a/\$\$/' >'x\$y' " && $b : self - $c <"sed <'xay' -e 's/a/b\$&c/' >'xbacy'" && $b : match - $c <"sed <'xay' -e 's/a/b\$`c/' >'xbxcy'" && $b : match-precede - $c <"sed <'xay' -e \"s/a/b\\\$'c/\" >'xbycy'" && $b : match-follow - - : capture - : - $c <'aj' - EOI - } - - : perl-escape - : - { - $c <"sed <'xay' -e 's/a/\\b/' >'xby' " && $b : none - $c <"sed <'xay' -e 's/a/\\/' >'xy' " && $b : none-term - $c <"sed <'xay' -e 's/a/\\\\/' >'x\\y'" && $b : self - - : capture - : - $c <'aa0' - EOI - - : upper - : - { - $c <"sed <'xay' -e 's/a/\\U/' >'xy' " && $b : none - $c <"sed <'xay' -e 's/a/\\Uvz/' >'xVZy'" && $b : repl - $c <"sed <'xay' -e 's/a/\\Uv\\Ez/' >'xVzy'" && $b : end - $c <"sed <'aa' -e 's/a/v\\Uz/g' >'vZvZ'" && $b : locality - $c <"sed <'xay' -e 's/\(a\)/\\U\\1/' >'xAy' " && $b : capt - $c <"sed <'x-y' -e 's/\(a?\)-/\\U\\1z/' >'xZy' " && $b : capt-empty - $c <"sed <'xay' -e 's/a/\\uvz/' >'xVzy'" && $b : once - } - - : lower - : - { - $c <"sed <'xay' -e 's/a/\\lVZ/' >'xvZy'" && $b : once - } - } - } - - $c <"sed -e 's/a//' <:'b' >'b'" && $b : no-newline - $c <"sed -e 's/a//' <:'' " && $b : empty-stdin - - : empty-file - : - $c <>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: -i option specified while reading from stdin - EOE - - : edit - : - $c <=f; - sed -i -e 's/foo/bar/' f; - cat f >'bar' - EOI -} - -: big -: -: Sed a big file (about 100K) to test that the builtin is asynchronous. -: -{ - $c <"$s" - EOI -} diff --git a/tests/test/script/builtin/sed.testscript b/tests/test/script/builtin/sed.testscript new file mode 100644 index 0000000..9db7cb4 --- /dev/null +++ b/tests/test/script/builtin/sed.testscript @@ -0,0 +1,333 @@ +# file : tests/test/script/builtin/sed.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: arg +: +{ + : auto-prn + : + { + $c <"sed -n -e 's/fox/bar/' <'foo' " && $b : on + $c <"sed -e 's/fox/bar/' <'foo' >'foo'" && $b : off + } + + : script + : + { + : missed + : + $c <'sed' && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: missing script + EOE + + : missed-val + : + $c <'sed -e' && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: missing script + EOE + + : empty + : + $c <"sed -e ''" && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: empty script + EOE + + : multiple + : + $c <"sed -e 's/a//' -e 's/a//'" && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: multiple scripts + EOE + + : invalid + : + $c <"sed -e 'z'" && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: only 's' command supported + EOE + } + + : file + : + { + : exist + : + $c <=f; + sed -e 's/foo/bar/' f >'bar' + EOI + + : none + : + $c <'bar' + EOI + + : dash + : + $c <'bar' + EOI + + : not-exist + : + $c <"sed -e 's/foo/bar/' f" && $b 2>>/~%EOE% != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + %sed: unable to edit '.+/1/f': .+% + EOE + + : empty + : + $c <"sed -e 's/foo/bar/' ''" && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: invalid path '' + EOE + } + + : unexpected + : + $c <"sed -e 's/a//' a b" && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: unexpected argument + EOE +} + +: command +: +{ + : subst + : + { + : parsing + : + { + : delim + : + { + : none + : + $c <"sed -e 's'" && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: no delimiter for 's' command + EOE + + : invalid + : + $c <"sed -e 's\\'" && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: invalid delimiter for 's' command + EOE + } + + : regex + : + { + : unterminated + : + $c <"sed -e 's/foo'" && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: unterminated 's' command regex + EOE + + : empty + : + $c <"sed -e 's///'" && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: empty regex in 's' command + EOE + + : invalid + : + : Note that old versions of libc++ (for example 1.1) do not detect some + : regex errors. For example '*' is parsed successfully. + : + $c <"sed -e 's/foo[/bar/'" && $b 2>>/~%EOE% != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + %sed: invalid regex.*% + EOE + } + + : unterminated-replacement + : + $c <"sed -e 's/foo/bar'" && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: unterminated 's' command replacement + EOE + + : invalid-flags + : + $c <"sed -e 's/foo/bar/a'" && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: invalid 's' command flag 'a' + EOE + } + + : exec + : + { + : flags + : + { + : global + : + { + $c <"sed -e 's/o/a/g' <'foo' >'faa'" && $b : on + $c <"sed -e 's/o/a/' <'foo' >'fao'" && $b : off + } + + : icase + : + { + $c <"sed -e 's/O/a/i' <'foo' >'fao'" && $b : on + $c <"sed -e 's/O/a/' <'foo' >'foo'" && $b : off + } + + : print + : + { + $c <"sed -n -e 's/o/a/p' <'foo' >'fao'" && $b : on-match + $c <"sed -n -e 's/o/a/' <'foo' " && $b : off-match + $c <"sed -n -e 's/u/a/p' <'foo' " && $b : on-no-match + } + } + + : search + { + : anchor + : + { + $c <"sed -n -e 's/^o/a/gp' <'oof' >'aof'" && $b : begin + $c <"sed -n -e 's/o\$/a/gp' <'foo' >'foa'" && $b : end + } + + : match + : Match corner cases + : + { + $c <"sed -n -e 's/a/b/p' <'a' >'b' " && $b : full + $c <"sed -n -e 's/a/b/p' <'ac' >'bc' " && $b : left + $c <"sed -n -e 's/a/b/p' <'ca' >'cb' " && $b : right + $c <"sed -n -e 's/a/b/pg' <'xaax' >'xbbx'" && $b : adjacent + } + } + + : replacement + : + { + : ecma-escape + : + { + $c <"sed <'xay' -e 's/a/\$b/' >'x\$by'" && $b : none + $c <"sed <'xay' -e 's/a/\$/' >'x\$y' " && $b : none-term + $c <"sed <'xay' -e 's/a/\$\$/' >'x\$y' " && $b : self + $c <"sed <'xay' -e 's/a/b\$&c/' >'xbacy'" && $b : match + $c <"sed <'xay' -e 's/a/b\$`c/' >'xbxcy'" && $b : match-precede + $c <"sed <'xay' -e \"s/a/b\\\$'c/\" >'xbycy'" && $b : match-follow + + : capture + : + $c <'aj' + EOI + } + + : perl-escape + : + { + $c <"sed <'xay' -e 's/a/\\b/' >'xby' " && $b : none + $c <"sed <'xay' -e 's/a/\\/' >'xy' " && $b : none-term + $c <"sed <'xay' -e 's/a/\\\\/' >'x\\y'" && $b : self + + : capture + : + $c <'aa0' + EOI + + : upper + : + { + $c <"sed <'xay' -e 's/a/\\U/' >'xy' " && $b : none + $c <"sed <'xay' -e 's/a/\\Uvz/' >'xVZy'" && $b : repl + $c <"sed <'xay' -e 's/a/\\Uv\\Ez/' >'xVzy'" && $b : end + $c <"sed <'aa' -e 's/a/v\\Uz/g' >'vZvZ'" && $b : locality + $c <"sed <'xay' -e 's/\(a\)/\\U\\1/' >'xAy' " && $b : capt + $c <"sed <'x-y' -e 's/\(a?\)-/\\U\\1z/' >'xZy' " && $b : capt-empty + $c <"sed <'xay' -e 's/a/\\uvz/' >'xVzy'" && $b : once + } + + : lower + : + { + $c <"sed <'xay' -e 's/a/\\lVZ/' >'xvZy'" && $b : once + } + } + } + + $c <"sed -e 's/a//' <:'b' >'b'" && $b : no-newline + $c <"sed -e 's/a//' <:'' " && $b : empty-stdin + + : empty-file + : + $c <>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: -i option specified while reading from stdin + EOE + + : edit + : + $c <=f; + sed -i -e 's/foo/bar/' f; + cat f >'bar' + EOI +} + +: big +: +: Sed a big file (about 100K) to test that the builtin is asynchronous. +: +{ + $c <"$s" + EOI +} diff --git a/tests/test/script/builtin/test.test b/tests/test/script/builtin/test.test deleted file mode 100644 index 73d89bc..0000000 --- a/tests/test/script/builtin/test.test +++ /dev/null @@ -1,69 +0,0 @@ -# file : tests/test/script/builtin/test.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: file -: -{ - : exists - : - $c <"test: missing path" == 2' && $b - -: invalid-option -: -: Test passing invalid option. -: -$c <'test -c a 2>"test: invalid option" == 2' && $b - -: unexpected-arg -: -: Test passing extra argument. -: -$c <'test -f a b 2>"test: unexpected argument" == 2' && $b - -: empty-path -: -: Test testing an empty path. -: -$c <"test: invalid path ''" == 2 -EOI diff --git a/tests/test/script/builtin/test.testscript b/tests/test/script/builtin/test.testscript new file mode 100644 index 0000000..f49b92b --- /dev/null +++ b/tests/test/script/builtin/test.testscript @@ -0,0 +1,69 @@ +# file : tests/test/script/builtin/test.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: file +: +{ + : exists + : + $c <"test: missing path" == 2' && $b + +: invalid-option +: +: Test passing invalid option. +: +$c <'test -c a 2>"test: invalid option" == 2' && $b + +: unexpected-arg +: +: Test passing extra argument. +: +$c <'test -f a b 2>"test: unexpected argument" == 2' && $b + +: empty-path +: +: Test testing an empty path. +: +$c <"test: invalid path ''" == 2 +EOI diff --git a/tests/test/script/builtin/touch.test b/tests/test/script/builtin/touch.test deleted file mode 100644 index 04391bd..0000000 --- a/tests/test/script/builtin/touch.test +++ /dev/null @@ -1,88 +0,0 @@ -# file : tests/test/script/builtin/touch.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: file -: -$c <'touch a' && $b - -: file-create -: -: Test that file is created. If it didn't then 'rm' would fail. -: -$c <=a; -touch a -EOI - -: no-cleanup -: -: Test that touching an existing file does not 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 <"touch: missing file" != 0' && $b - -: empty-path -: -: Test touching an empty path. -: -$c <"touch: invalid path ''" != 0 -EOI - -: dir-update -: -: Test touching an existing directory. -: -$c <~'%touch: cannot create/update .+: .+%' != 0 -EOI - -: after -: -{ - : success - : - $c <'touch: missing --after option value' != 0 - EOI - - : not-exists - : - $c <~"%touch: cannot obtain file '.+a' modification time: .+%" != 0 - EOI -} diff --git a/tests/test/script/builtin/touch.testscript b/tests/test/script/builtin/touch.testscript new file mode 100644 index 0000000..d58ed7f --- /dev/null +++ b/tests/test/script/builtin/touch.testscript @@ -0,0 +1,88 @@ +# file : tests/test/script/builtin/touch.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: file +: +$c <'touch a' && $b + +: file-create +: +: Test that file is created. If it didn't then 'rm' would fail. +: +$c <=a; +touch a +EOI + +: no-cleanup +: +: Test that touching an existing file does not 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 <"touch: missing file" != 0' && $b + +: empty-path +: +: Test touching an empty path. +: +$c <"touch: invalid path ''" != 0 +EOI + +: dir-update +: +: Test touching an existing directory. +: +$c <~'%touch: cannot create/update .+: .+%' != 0 +EOI + +: after +: +{ + : success + : + $c <'touch: missing --after option value' != 0 + EOI + + : not-exists + : + $c <~"%touch: cannot obtain file '.+a' modification time: .+%" != 0 + EOI +} -- cgit v1.1