From dbed808c7d534069f76e63a1a68a85f30d2be81c Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 10 Sep 2019 23:23:43 +0300 Subject: Move testscript builtins to libbutl --- tests/test/script/builtin/buildfile | 2 +- tests/test/script/builtin/cat.testscript | 90 ------- tests/test/script/builtin/cp-dir/cp-file | 0 tests/test/script/builtin/cp.testscript | 367 ++++------------------------- tests/test/script/builtin/echo.testscript | 27 --- tests/test/script/builtin/ln.testscript | 180 +++----------- tests/test/script/builtin/mkdir.testscript | 95 +++----- tests/test/script/builtin/mv.testscript | 231 ++++++------------ tests/test/script/builtin/rm.testscript | 93 +------- tests/test/script/builtin/rmdir.testscript | 82 +------ tests/test/script/builtin/sed.testscript | 355 ---------------------------- tests/test/script/builtin/sleep.testscript | 28 --- tests/test/script/builtin/test.testscript | 85 ------- tests/test/script/builtin/touch.testscript | 97 ++------ 14 files changed, 201 insertions(+), 1531 deletions(-) delete mode 100644 tests/test/script/builtin/cat.testscript delete mode 100644 tests/test/script/builtin/cp-dir/cp-file delete mode 100644 tests/test/script/builtin/echo.testscript delete mode 100644 tests/test/script/builtin/sed.testscript delete mode 100644 tests/test/script/builtin/test.testscript (limited to 'tests/test') diff --git a/tests/test/script/builtin/buildfile b/tests/test/script/builtin/buildfile index ca594ff..f5b719d 100644 --- a/tests/test/script/builtin/buildfile +++ b/tests/test/script/builtin/buildfile @@ -2,4 +2,4 @@ # copyright : Copyright (c) 2014-2019 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -./: testscript{*} file{cp-dir/cp-file} $b +./: testscript{*} $b diff --git a/tests/test/script/builtin/cat.testscript b/tests/test/script/builtin/cat.testscript deleted file mode 100644 index b23efcf..0000000 --- a/tests/test/script/builtin/cat.testscript +++ /dev/null @@ -1,90 +0,0 @@ -# file : tests/test/script/builtin/cat.testscript -# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.testscript - -: unknown-option -: -$c <"cat: unknown option '-u'" == 1 -EOI - -: 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-dir/cp-file b/tests/test/script/builtin/cp-dir/cp-file deleted file mode 100644 index e69de29..0000000 diff --git a/tests/test/script/builtin/cp.testscript b/tests/test/script/builtin/cp.testscript index 60497b1..802cfee 100644 --- a/tests/test/script/builtin/cp.testscript +++ b/tests/test/script/builtin/cp.testscript @@ -4,109 +4,29 @@ .include ../common.testscript -: unknown-option -: -$c <"cp: unknown option '-u'" == 1 -EOI - -: 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 + : cleanup : { - : 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 - } + touch a; + cp --no-cleanup a b; + rm b + EOI - : cleanup - : - { : existing : : Test that copy over an existing file does not register cleanup. If it @@ -114,12 +34,12 @@ EOI : 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 + touch a/b; + cp -r a b EOI - } - : non-dir + : no-cleanup : - { - $c <>/~%EOE% != 0 - %cp: unable to copy directory '.+/a' to '.+/b': .+% - EOE + $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 + cp a b c/ 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 + : no-cleanup : - { $c <>/~%EOE% != 0 - %cp: unable to copy file '.+/a' to '.+/b/a': .+% - EOE - EOI - } + touch a b; + mkdir c; + cp --no-cleanup a b c/; + rm c/a c/b + EOI } : filesystem-entries @@ -279,112 +94,20 @@ EOI : Test synopsis 4: copy filesystem entries into the specified directory. : { - : file + : cleanup : - { - $c <>/~%EOE% != 0 - %cp: unable to copy directory '.+/a' to '.+/b/a': .+% - EOE + touch c a/c; + cp --no-cleanup -R a c b/; + rm -r b/a/ b/c 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 -pr $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 - : - : Note that the `ls -l` command by default displays the filesystem entry - : modification time with the minute resolution and the build2 dist - : meta-operation (involved when we fetch from the git repository - : location) doesn't preserve the directory modification time. That's why - : we also pass --full-time and enable the test for only platforms where ls - : supports this option. - : - if ($cxx.target.class == 'linux') - { - $c <<"EOI" && $b 2>>~%EOE% != 0 - ls -l --full-time $src_base | sed -n -e '$ds' | \ - set t; - - cp -r $src_base/cp-dir ./; - ls -l --full-time | sed -n -e '$ds' >"\$t" - EOI - %.+ error: sed stdout doesn't match expected% - %.+ - EOE - } - } } diff --git a/tests/test/script/builtin/echo.testscript b/tests/test/script/builtin/echo.testscript deleted file mode 100644 index 3227e89..0000000 --- a/tests/test/script/builtin/echo.testscript +++ /dev/null @@ -1,27 +0,0 @@ -# file : tests/test/script/builtin/echo.testscript -# copyright : Copyright (c) 2014-2019 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.testscript b/tests/test/script/builtin/ln.testscript index 072c197..456126a 100644 --- a/tests/test/script/builtin/ln.testscript +++ b/tests/test/script/builtin/ln.testscript @@ -4,119 +4,25 @@ .include ../common.testscript -: unknown-option -: -$c <"ln: unknown option '-u'" == 1 -EOI - -: args -: -{ - : -s-option - : - $c <'ln 2>"ln: missing -s|--symbolic 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 + : cleanup : $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 + ln -s a b 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 + ln -s --no-cleanup a b; + rm b EOI - } } : dir @@ -124,57 +30,22 @@ EOI : Test creating a directory symlink. : { - : non-existing-link-path + : cleanup : $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 + touch a/b; + ln -s a c 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 + touch a/b; + ln -s --no-cleanup a c; + rm -r c EOI - } } : multiple-targets @@ -182,9 +53,20 @@ EOI : Test creating links for multiple targets in the specified directory. : { + : cleanup + : $c <"mkdir: unknown option '-u'" == 1 -EOI - -: 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 +{ + : cleanup + : + $c <"mv: unknown option '-u'" == 1 -EOI - -: 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. @@ -58,43 +12,6 @@ EOI : 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). @@ -105,10 +22,10 @@ EOI : 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 + mv ../../a/b/c ./c 2>>/~%EOE% == 1 + %mv: '.+/fail/a/b/c' is out of working directory '.+/fail/test'% + EOE + EOI : force : @@ -117,15 +34,30 @@ EOI : exist. : $c <>/~%EOE% == 1 - %mv: unable to move entity '.+/force/a/b/c' to '.+/c': .+% - EOE - EOI + mv -f ../../a/b/c ./c 2>>/~%EOE% == 1 + %mv: unable to move entity '.+/force/a/b/c' to '.+/c': .+% + EOE + EOI } : cleanup : { + : enabled + : + $c <>/~%EOE% != 0 - %mv: unable to move entity '.+/a' to '.+/b': .+% - EOE - EOI + mv $~ b 2>"mv: '$~' contains test working directory '$~'" != 0 + EOI - : to-non-dir + : dst : $c <>/~%EOE% != 0 - %mv: unable to move entity '.+/a' to '.+/b': .+% - EOE - EOI + mkdir a; + mv a "$~" 2>"mv: '$~' contains test working directory '$~'" != 0 + EOI } - : working-dir + : cleanup : { - : src + : enabled : - { - $c <"mv: '([string] $~)' contains test working directory '$~'" != 0 + $c <"mv: '$~' contains test working directory '$~'" != 0 + mv --no-cleanup a b &!a/; + rm -r b EOI - } - } - - : overlap - : - $c <>/~%EOE% != 0 - %mv: unable to move entity '.+/a' to '.+/a/b': .+% - EOE - EOI - : cleanup - : - { : sub-entry : - { + $c <>/~%EOE% != 0 - %mv: unable to move entity '.+/a' to '.+/b': .+% - EOE - EOI - } } : synopsis-2 @@ -249,10 +140,20 @@ EOI : Move entities into the specified directory. : { + : cleanup + : $c <"rm: unknown option '-u'" == 1 -EOI - -: 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 + rm -r ./ 2>"rm: '$~' 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). @@ -110,10 +29,10 @@ EOI : 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 + rm ../../a/b/c 2>>/~%EOE% == 1 + %rm: '.+/path/outside-scope/fail/a/b/c' is out of working directory '.+/path/outside-scope/fail/test'% + EOE + EOI : force : diff --git a/tests/test/script/builtin/rmdir.testscript b/tests/test/script/builtin/rmdir.testscript index 9f0c945..897b5f4 100644 --- a/tests/test/script/builtin/rmdir.testscript +++ b/tests/test/script/builtin/rmdir.testscript @@ -4,39 +4,9 @@ .include ../common.testscript -: unknown-option -: -$c <"rmdir: unknown option '-u'" == 1 -EOI - -: 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. @@ -56,7 +26,7 @@ EOI : $c <>/~%EOE% == 1 - %rmdir: '.+/dir/outside-scope/fail/a/b/c' is out of working directory '.+/dir/outside-scope/fail/test'% + %rmdir: '.+/dir/outside-scope/fail/a/b/c/' is out of working directory '.+/dir/outside-scope/fail/test'% EOE EOI @@ -67,54 +37,4 @@ EOI : $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.testscript b/tests/test/script/builtin/sed.testscript deleted file mode 100644 index 4a79fe3..0000000 --- a/tests/test/script/builtin/sed.testscript +++ /dev/null @@ -1,355 +0,0 @@ -# file : tests/test/script/builtin/sed.testscript -# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.testscript - -: unknown-option -: -$c <"sed: unknown option '-u'" == 1 -EOI - -: 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 - info: test id: 1 - 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 value for option '-e' - info: test id: 1 - 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 - info: test id: 1 - 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 - info: test id: 1 - 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 - info: test id: 1 - 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': .+% - info: test id: 1 - 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 '' - info: test id: 1 - 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 'b' - info: test id: 1 - 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 - info: test id: 1 - 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 - info: test id: 1 - 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 - info: test id: 1 - 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 - info: test id: 1 - 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.*% - info: test id: 1 - 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 - info: test id: 1 - 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' - info: test id: 1 - 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|--in-place option specified while reading from stdin - info: test id: 1 - 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/sleep.testscript b/tests/test/script/builtin/sleep.testscript index 7d39548..6ba7e38 100644 --- a/tests/test/script/builtin/sleep.testscript +++ b/tests/test/script/builtin/sleep.testscript @@ -4,34 +4,6 @@ .include ../common.testscript -: unknown-option -: -$c <"sleep: unknown option '-u'" == 1 -EOI - : success : $c <'sleep 1' && $b - -: no-time -: -: Test passing no time interval. -: -$c <'sleep 2>"sleep: missing time interval" != 0' && $b - -: invalid-time -: -: Test passing invalid time interval. -: -$c <"sleep: invalid time interval '1a'" != 0 -EOI - -: unexpected-arg -: -: Test passing extra argument. -: -$c <"sleep: unexpected argument '1'" != 0 -EOI diff --git a/tests/test/script/builtin/test.testscript b/tests/test/script/builtin/test.testscript deleted file mode 100644 index 9fde142..0000000 --- a/tests/test/script/builtin/test.testscript +++ /dev/null @@ -1,85 +0,0 @@ -# file : tests/test/script/builtin/test.testscript -# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.testscript - -: file -: -{ - : exists - : - $c <"test: unknown option '-u'" == 2 - EOI - - : none - : - $c <"test: either -f|--file or -d|--directory must be specified" == 2 - EOI - - : both-file-dir - : - $c <"test: both -f|--file and -d|--directory specified" == 2 - EOI -} - -: args -: -{ - : none - : - $c <'test -f 2>"test: missing path" == 2' && $b - - : unexpected - : - $c <"test: unexpected argument 'b'" == 2 - EOI - - : empty-path - : - $c <"test: invalid path ''" == 2 - EOI -} diff --git a/tests/test/script/builtin/touch.testscript b/tests/test/script/builtin/touch.testscript index 731f023..e9549d2 100644 --- a/tests/test/script/builtin/touch.testscript +++ b/tests/test/script/builtin/touch.testscript @@ -4,91 +4,32 @@ .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: unknown option '-u'" == 1 -EOI - -: no-args -: -: Test passing no arguments. -: -$c <'touch --no-cleanup 2>"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 +: cleanup : { - : success + : enabled : - $c <"touch: missing value for option '--after'" != 0 - EOI + touch --no-cleanup a; + rm a + EOI - : not-exists + : existing + : + : 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: cannot obtain file '.+a' modification time: .+%" != 0 - EOI + { + +touch a + { + touch ../a + } + } + EOI } -- cgit v1.1