aboutsummaryrefslogtreecommitdiff
path: root/tests/test/script/builtin
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-09-10 23:23:43 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-09-27 18:04:30 +0300
commitdbed808c7d534069f76e63a1a68a85f30d2be81c (patch)
tree3161d9c9617f2fccf37bd278f0c9bf45fad2e20e /tests/test/script/builtin
parent6e84c0f9c5e4d7d98d2a352eec6bc19de0d75d28 (diff)
Move testscript builtins to libbutl
Diffstat (limited to 'tests/test/script/builtin')
-rw-r--r--tests/test/script/builtin/buildfile2
-rw-r--r--tests/test/script/builtin/cat.testscript90
-rw-r--r--tests/test/script/builtin/cp-dir/cp-file0
-rw-r--r--tests/test/script/builtin/cp.testscript367
-rw-r--r--tests/test/script/builtin/echo.testscript27
-rw-r--r--tests/test/script/builtin/ln.testscript180
-rw-r--r--tests/test/script/builtin/mkdir.testscript95
-rw-r--r--tests/test/script/builtin/mv.testscript231
-rw-r--r--tests/test/script/builtin/rm.testscript93
-rw-r--r--tests/test/script/builtin/rmdir.testscript82
-rw-r--r--tests/test/script/builtin/sed.testscript355
-rw-r--r--tests/test/script/builtin/sleep.testscript28
-rw-r--r--tests/test/script/builtin/test.testscript85
-rw-r--r--tests/test/script/builtin/touch.testscript97
14 files changed, 201 insertions, 1531 deletions
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 <<EOI && $b
-cat -u 2>"cat: unknown option '-u'" == 1
-EOI
-
-: in
-:
-$c <<EOI && $b
-cat <<EOF >>EOO
-foo
-bar
-EOF
-foo
-bar
-EOO
-EOI
-
-: dash
-:
-$c <<EOI && $b
-cat - <<EOF >>EOO
-foo
-bar
-EOF
-foo
-bar
-EOO
-EOI
-
-: file
-:
-$c <<EOI && $b
-cat <<EOF >=out;
-foo
-bar
-EOF
-cat out >>EOO
-foo
-bar
-EOO
-EOI
-
-: in-repeat
-:
-$c <<EOI && $b
-cat - <<EOF >>EOO
-foo
-bar
-EOF
-foo
-bar
-EOO
-EOI
-
-: non-existent
-:
-$c <<EOI && $b
-cat in 2>>/~%EOE% != 0
-%cat: unable to print '.+/test/cat/non-existent/test/1/in': .+%
-EOE
-EOI
-
-: empty-path
-:
-: Cat an empty path.
-:
-$c <<EOI && $b
-cat '' 2>"cat: invalid path ''" == 1
-EOI
-
-: big
-:
-: Cat a big file (about 100K) to test that the builtin is asynchronous.
-:
-{
- $c <<EOI && $b
- s="--------------------------------"
- s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s"
- s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s"
- s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s"
- cat <"$s" | cat >"$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
--- a/tests/test/script/builtin/cp-dir/cp-file
+++ /dev/null
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 <<EOI && $b
-cp -u 2>"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 <<EOI && $b
- cp a b c 2>"cp: multiple source paths without trailing separator for destination directory" == 1
- EOI
-
- : empty
- :
- {
- : dest
- :
- $c <<EOI && $b
- cp '' 2>"cp: invalid path ''" == 1
- EOI
-
- : src1
- :
- $c <<EOI && $b
- cp '' a 2>"cp: invalid path ''" == 1
- EOI
-
- : src2
- :
- $c <<EOI && $b
- cp '' a b/ 2>"cp: invalid path ''" == 1
- EOI
- }
-}
-
: file
:
: Test synopsis 1: make a file copy at the specified path.
:
{
- : existing
+ : cleanup
:
{
- : to-non-existing
- :
- $c <<EOI && $b
- touch a;
- cp a b && test -f b
- EOI
-
- : to-existing
+ : enabled
:
$c <<EOI && $b
- touch a b;
- cp a b
- EOI
+ touch a;
+ cp a b
+ EOI
- : to-dir
+ : disabled
:
$c <<EOI && $b
- touch a;
- mkdir b;
- cp a b 2>>/~%EOE% != 0
- %cp: unable to copy file '.+/a' to '.+/b': .+%
- EOE
- EOI
- }
-
- : non-existing
- :
- {
- $c <<EOI && $b
- cp a b 2>>/~%EOE% != 0
- %cp: unable to copy file '.+/a' to '.+/b': .+%
- EOE
- EOI
- }
-
- : non-file
- :
- {
- $c <<EOI && $b
- mkdir a;
- cp a b 2>>/~%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 <<EOI && $b
- +touch b
- {
- touch a;
- cp a ../b
- }
- EOI
+ +touch b
+ {
+ touch a;
+ cp a ../b
+ }
+ EOI
}
}
@@ -128,66 +48,22 @@ EOI
: Test synopsis 2: make a directory copy at the specified path.
:
{
- : existing
+ : cleanup
:
- {
- : to-non-existing
- :
- $c <<EOI && $b
- mkdir a;
- cp -r a b && test -d b
- EOI
-
- : to-existing
- :
- $c <<EOI && $b
- mkdir a b;
- cp -R a b 2>>/~%EOE% != 0
- %cp: unable to copy directory '.+/a' to '.+/b': .+%
- EOE
- EOI
-
- : to-file
- :
- $c <<EOI && $b
+ $c <<EOI && $b
mkdir a;
- touch b;
- cp -r a b 2>>/~%EOE% != 0
- %cp: unable to copy directory '.+/a' to '.+/b': .+%
- EOE
- EOI
-
- : recursively
- :
- {
- $c <<EOI && $b
- mkdir -p a/b/c;
- touch a/x a/b/y;
- cp -r a d && test -d d/b/c && test -f d/x && test -f d/b/y
- EOI
- }
- }
-
- : non-existing
- :
- {
- $c <<EOI && $b
- cp -r a b 2>>/~%EOE% != 0
- %cp: unable to copy directory '.+/a' to '.+/b': .+%
- EOE
+ touch a/b;
+ cp -r a b
EOI
- }
- : non-dir
+ : no-cleanup
:
- {
- $c <<EOI && $b
- touch a;
- cp -r a b 2>>/~%EOE% != 0
- %cp: unable to copy directory '.+/a' to '.+/b': .+%
- EOE
+ $c <<EOI && $b
+ mkdir a;
+ touch a/b;
+ cp --no-cleanup -r a b;
+ rm -r b
EOI
- }
}
: files
@@ -195,83 +71,22 @@ EOI
: Test synopsis 3: copy files into the specified directory.
:
{
- : existing
+ : cleanup
:
- {
- : into-dir
- :
- {
- : over-non-existing
- :
- $c <<EOI && $b
- mkdir b;
- touch a;
- cp a b/ && test -f b/a
- EOI
-
- : over-dir
- :
- $c <<EOI && $b
- mkdir -p b/a;
- touch a;
- cp a b/ 2>>/~%EOE% != 0
- %cp: unable to copy file '.+/a' to '.+/b/a': .+%
- EOE
- EOI
-
- : multiple
- :
- $c <<EOI && $b
+ $c <<EOI && $b
touch a b;
mkdir c;
- cp a b c/ && test -f c/a && test -f c/b
- EOI
- }
-
- : into-non-existing-dir
- :
- {
- $c <<EOI && $b
- touch a;
- cp a b/ 2>>/~%EOE% != 0
- %cp: unable to copy file '.+/a' to '.+/b/a': .+%
- EOE
+ cp a b c/
EOI
- }
- : into-non-dir
- :
- {
- $c <<EOI && $b
- touch a b;
- cp a b/ 2>>/~%EOE% != 0
- %cp: unable to copy file '.+/a' to '.+/b/a': .+%
- EOE
- EOI
- }
- }
-
- : non-existing
- :
- {
- $c <<EOI && $b
- mkdir b;
- cp a b/ 2>>/~%EOE% != 0
- %cp: unable to copy file '.+/a' to '.+/b/a': .+%
- EOE
- EOI
- }
-
- : non-file
+ : no-cleanup
:
- {
$c <<EOI && $b
- mkdir a b;
- cp a b/ 2>>/~%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 <<EOI && $b
- mkdir b;
- touch a;
- cp -R a b/ && test -f b/a
+ $c <<EOI && $b
+ mkdir a b;
+ touch c a/c;
+ cp -R a c b/
EOI
- }
- : dir
+ : no-cleanup
:
- {
- : over-non-existing
- :
- $c <<EOI && $b
+ $c <<EOI && $b
mkdir a b;
- touch a/c;
- cp -R a b/ && test -f b/a/c
- EOI
-
- : over-existing
- :
- $c <<EOI && $b
- mkdir -p a b/a;
- cp -R a b/ 2>>/~%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 <<EOI && $b
- s="--------------------------------"
- s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s"
- s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s"
- s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s"
- echo "$s" | cat >"$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 <<EOI && $b
-ln -u 2>"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 <<EOI && $b
- ln -s a b c 2>"ln: multiple target paths with non-directory link path" == 1
- EOI
-
- : empty
- :
- {
- : link
- :
- $c <<EOI && $b
- ln -s '' 2>"ln: invalid path ''" == 1
- EOI
-
- : target1
- :
- $c <<EOI && $b
- ln -s '' a 2>"ln: invalid path ''" == 1
- EOI
-
- : target2
- :
- $c <<EOI && $b
- ln -s '' a b/ 2>"ln: invalid path ''" == 1
- EOI
- }
-}
-
: file
:
: Test creating a file symlink.
:
{
- : non-existing-link-path
+ : cleanup
:
$c <<EOI && $b
- touch a;
- ln -s a b && test -f b
- EOI
-
- : existing-link
- :
- {
- : file
- :
- $c <<EOI && $b
- touch a b;
- ln -s a b 2>>/~%EOE% != 0
- %(
- %ln: unable to create .+link '.+/b' to '.+/a': .+%|
- %ln: unable to copy file '.+/a' to '.+/b': .+%
- %)
- EOE
- EOI
-
- : dir
- :
- $c <<EOI && $b
touch a;
- mkdir b;
- ln -s a b 2>>/~%EOE% != 0
- %(
- %ln: unable to create .+link '.+/b' to '.+/a': .+%|
- %ln: unable to copy file '.+/a' to '.+/b': .+%
- %)
- EOE
- EOI
- }
-
- : non-existing
- {
- : target
- :
- $c <<EOI && $b
- ln -s a b 2>>/~%EOE% != 0
- %ln: unable to create symlink to '.+/a': no such file or directory%
- EOE
+ ln -s a b
EOI
- : link-dir
- :
- $c <<EOI && $b
+ : no-cleanup
+ :
+ $c <<EOI && $b
touch a;
- ln -s a b/c 2>>/~%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 <<EOI && $b
- mkdir a;
- touch a/b;
- ln -s a c && test -f c/b
- EOI
-
- : existing-link
- :
- {
- : dir
- :
- $c <<EOI && $b
- mkdir a b;
- ln -s a b 2>>/~%EOE% != 0
- %(
- %ln: unable to create .+link '.+/b' to '.+/a': .+%|
- %ln: unable to copy directory '.+/a' to '.+/b': .+%
- %)
- EOE
- EOI
-
- : file
- :
- $c <<EOI && $b
mkdir a;
- touch b;
- ln -s a b 2>>/~%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 <<EOI && $b
+ : no-cleanup
+ :
+ $c <<EOI && $b
mkdir a;
- ln -s a b/c 2>>/~%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 <<EOI && $b
- touch a;
- mkdir b c;
- ln -s a b c/ && test -f c/a && test -d c/b
- EOI
+ mkdir b c;
+ touch a b/c;
+ ln -s a b c/
+ EOI
+
+ : no-cleanup
+ :
+ $c <<EOI && $b
+ mkdir b c;
+ touch a b/c;
+ ln -s --no-cleanup a b c/;
+ rm -r c/a c/b
+ EOI
}
diff --git a/tests/test/script/builtin/mkdir.testscript b/tests/test/script/builtin/mkdir.testscript
index d1a3b4a..00fc5cf 100644
--- a/tests/test/script/builtin/mkdir.testscript
+++ b/tests/test/script/builtin/mkdir.testscript
@@ -4,69 +4,38 @@
.include ../common.testscript
-: unknown-option
-:
-$c <<EOI && $b
-mkdir -u 2>"mkdir: unknown option '-u'" == 1
-EOI
-
-: dirs
-:
-$c <<EOI && $b
-mkdir a b;
-touch a/a b/b
-EOI
+: dir
+:
+{
+ : cleanup
+ :
+ $c <<EOI && $b
+ mkdir a b
+ EOI
+
+ : no-cleanup
+ :
+ : Also test that `--` is handled properly.
+ :
+ $c <<EOI && $b
+ mkdir --no-cleanup -- --no-cleanup;
+ rmdir -- --no-cleanup
+ EOI
+}
: parent
:
-$c <<EOI && $b
-mkdir -p a/b;
-touch a/a a/b/b
-EOI
-
-: exists
-:
-$c <'mkdir -p a a a/b a/b' && $b
-
-: double-dash
-:
-: Make sure '-p' directory is created.
-:
-$c <<EOI && $b
-mkdir -p -- -p;
-touch -- -p/a
-EOI
-
-: no-args
-:
-: Test passing no arguments.
-:
-$c <'mkdir 2>"mkdir: missing directory" == 1' && $b
-
-: empty-path
-:
-: Test creation of empty directory path.
-:
-$c <<EOI && $b
-mkdir '' 2>"mkdir: invalid path ''" == 1
-EOI
-
-: already-exists
-:
-: Test creation of an existing directory.
-:
-$c <<EOI && $b
-mkdir a a 2>>/~%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 <<EOI && $b
-mkdir a/b 2>>/~%EOE% == 1
-%mkdir: unable to create directory '.+/test/mkdir/not-exists/test/1/a/b': .+%
-EOE
-EOI
+{
+ : cleanup
+ :
+ $c <<EOI && $b
+ mkdir -p a/b
+ EOI
+
+ : no-cleanup
+ :
+ $c <<EOI && $b
+ mkdir -p --no-cleanup a/b;
+ rm -r a
+ EOI
+}
diff --git a/tests/test/script/builtin/mv.testscript b/tests/test/script/builtin/mv.testscript
index eb4860e..d703faf 100644
--- a/tests/test/script/builtin/mv.testscript
+++ b/tests/test/script/builtin/mv.testscript
@@ -4,52 +4,6 @@
.include ../common.testscript
-: unknown-option
-:
-$c <<EOI && $b
-mv -u 2>"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 <<EOI && $b
- mv a b c 2>"mv: multiple source paths without trailing separator for destination directory" == 1
- EOI
-
- : empty
- :
- {
- : dest
- :
- $c <<EOI && $b
- mv '' 2>"mv: invalid path ''" == 1
- EOI
-
- : src1
- :
- $c <<EOI && $b
- mv '' a 2>"mv: invalid path ''" == 1
- EOI
-
- : src2
- :
- $c <<EOI && $b
- mv '' a b/ 2>"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 <<EOI && $b
- touch a;
- mv a b && test -f b && test -f a == 1
- EOI
-
- : to-existing
- :
- $c <<EOI && $b
- touch a b;
- mv a b && test -f b && test -f a == 1
- EOI
-
- : to-self
- :
- $c <<EOI && $b
- touch a;
- mv a a 2>>/~%EOE% != 0
- %mv: unable to move entity '.+/a' to itself%
- EOE
- EOI
-
- : to-dir
- :
- $c <<EOI && $b
- touch a;
- mkdir b;
- mv a b 2>>/~%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 <<EOI && $b
- mv ../../a/b/c ./c 2>>/~%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 <<EOI && $b
- mv -f ../../a/b/c ./c 2>>/~%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 <<EOI && $b
+ touch a;
+ mv a b
+ EOI
+
+ : disabled
+ :
+ $c <<EOI && $b
+ touch a;
+ mv --no-cleanup a b &!a;
+ rm b
+ EOI
+
: existing
:
: Test that moving over an existing file does not move the cleanup. If
@@ -135,91 +67,60 @@ EOI
: fail.
:
$c <<EOI && $b
- +touch b
- {
- touch a;
- mv a ../b
- }
- EOI
+ +touch b
+ {
+ touch a;
+ mv a ../b
+ }
+ EOI
}
}
: dir
:
{
- : existing
+ : working-dir
:
{
- : to-non-existing
- :
- : Note the here we also test that b path is cleaned up as a directory.
- :
- $c <<EOI && $b
- mkdir a;
- mv a b && test -d b && test -d a == 1
- EOI
-
- : to-non-empty
+ : src
:
$c <<EOI && $b
- mkdir a b;
- touch b/c;
- mv a b 2>>/~%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 <<EOI && $b
- mkdir a;
- touch b;
- mv a b 2>>/~%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 <<EOI && $b
- mv $~ b 2>"mv: '([string] $~)' contains test working directory '$~'" != 0
+ $c <<EOI && $b
+ mkdir a;
+ mv a b
EOI
- }
- : dst
+ : disabled
:
- {
- $c <<EOI && $b
+ $c <<EOI && $b
mkdir a;
- mv a "$~" 2>"mv: '$~' contains test working directory '$~'" != 0
+ mv --no-cleanup a b &!a/;
+ rm -r b
EOI
- }
- }
-
- : overlap
- :
- $c <<EOI && $b
- mkdir a;
- mv a a/b 2>>/~%EOE% != 0
- %mv: unable to move entity '.+/a' to '.+/a/b': .+%
- EOE
- EOI
- : cleanup
- :
- {
: sub-entry
:
- {
+ $c <<EOI && $b
mkdir a;
touch a/b;
mv a c
- }
+ EOI
: reorder
:
@@ -227,21 +128,11 @@ EOI
: it, get removed before b/ after being renamed to b/c.
:
$c <<EOI && $b
- mkdir a b;
- mv a b/c
- EOI
+ mkdir a b;
+ mv a b/c
+ EOI
}
}
-
- : non-existing
- :
- {
- $c <<EOI && $b
- mv a b 2>>/~%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 <<EOI && $b
- mkdir a c;
- touch a/b b;
- mv a b c/;
- test -d c/a && test -f c/a/b && test -f c/b
- EOI
+ mkdir a c;
+ touch a/b b;
+ mv a b c/
+ EOI
+
+ : no-cleanup
+ :
+ $c <<EOI && $b
+ mkdir a c;
+ touch a/b b;
+ mv --no-cleanup a b c/ &!a/ &!a/b &!b;
+ rm -r c/a/ c/b
+ EOI
}
diff --git a/tests/test/script/builtin/rm.testscript b/tests/test/script/builtin/rm.testscript
index 46ed566..7160c73 100644
--- a/tests/test/script/builtin/rm.testscript
+++ b/tests/test/script/builtin/rm.testscript
@@ -4,102 +4,21 @@
.include ../common.testscript
-: unknown-option
-:
-$c <<EOI && $b
-rm -u 2>"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 <<EOI && $b
- touch a &!a;
- rm a
- EOI
-
- : not-exists
- :
- {
- : fail
- :
- : Removing non-existing file fails.
- :
- $c <<EOI && $b
- rm a 2>>/~%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 <<EOI && $b
- mkdir a;
- rm a 2>"rm: '$normalize([path] $~/a)' is a directory" == 1
- EOI
-
- : recursive
- :
- : Removing directory succeeds with -r option.
- :
- $c <<EOI && $b
- mkdir -p a/b &!a &!a/b;
- rm -r a
- EOI
-
: scope
:
: Removing scope directory fails.
:
$c <<EOI && $b
- rm -r ./ 2>"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 <<EOI && $b
- rm '' 2>"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 <<EOI && $b
- 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
+ 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 <<EOI && $b
-rmdir -u 2>"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 <<EOI && $b
- rmdir '' 2>"rmdir: invalid path ''" == 1
- EOI
-
: test-scope
:
: Removing scope directory fails.
@@ -56,7 +26,7 @@ EOI
:
$c <<EOI && $b
rmdir ../../a/b/c 2>>/~%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 <<EOI && $b
- mkdir a &!a;
- rmdir a
- EOI
-
- : not-exists
- :
- {
- : fail
- : Removing non-existing directory fails.
- :
- $c <<EOI && $b
- rmdir a 2>>/~%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 <<EOI && $b
- mkdir -p a/b;
- rmdir a 2>>/~%EOE% == 1
- %rmdir: unable to remove '.+/dir/not-empty/test/1/a': .+%
- EOE
- EOI
-
- : not-dir
- :
- : Removing not a directory path fails.
- :
- $c <<EOI && $b
- touch a;
- rmdir a 2>>/~%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 <<EOI && $b
-sed -u 2>"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 <<EOI && $b
- cat <'foo' >=f;
- sed -e 's/foo/bar/' f >'bar'
- EOI
-
- : none
- :
- $c <<EOI && $b
- sed -e 's/foo/bar/' <'foo' >'bar'
- EOI
-
- : dash
- :
- $c <<EOI && $b
- sed -e 's/foo/bar/' - <'foo' >'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 <<EOI && $b
- sed <'abcdefghij' -e 's/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)/$1$10/' >'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 <<EOI && $b
- sed <'abcdefghij' -e 's/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)/\1\10/' >'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 <<EOI && $b
- touch f;
- sed -e 's/a//' f
- EOI
- }
- }
-}
-
-: in-place
-:
-{
- : no-file
- :
- $c <"sed -i -e 's/a/b/'" && $b 2>>/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 <<EOI && $b
- cat <'foo' >=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 <<EOI && $b
- s="--------------------------------"
- s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s"
- s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s"
- s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s"
- cat <"$s" | sed -e 's/^x//' | cat >"$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 <<EOI && $b
-sleep -u 2>"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 <<EOI && $b
-sleep 1a 2>"sleep: invalid time interval '1a'" != 0
-EOI
-
-: unexpected-arg
-:
-: Test passing extra argument.
-:
-$c <<EOI && $b
-sleep 1 1 2>"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 <<EOI && $b
- touch a;
- test -f a
- EOI
-
- : not-exists
- :
- $c <'test -f a == 1' && $b
-
- : not-file
- :
- $c <'test -f . == 1' && $b
-}
-
-: dir
-:
-{
- : exists
- :
- $c <'test -d .' && $b
-
- : not-exists
- :
- $c <'test -d a == 1' && $b
-
- : not-dir
- :
- $c <<EOI && $b
- touch a;
- test -d a == 1
- EOI
-}
-
-: options
-:
-{
- : unknown
- :
- $c <<EOI && $b
- test -u 2>"test: unknown option '-u'" == 2
- EOI
-
- : none
- :
- $c <<EOI && $b
- test 2>"test: either -f|--file or -d|--directory must be specified" == 2
- EOI
-
- : both-file-dir
- :
- $c <<EOI && $b
- test -fd 2>"test: both -f|--file and -d|--directory specified" == 2
- EOI
-}
-
-: args
-:
-{
- : none
- :
- $c <'test -f 2>"test: missing path" == 2' && $b
-
- : unexpected
- :
- $c <<EOI && $b
- test -f a b 2>"test: unexpected argument 'b'" == 2
- EOI
-
- : empty-path
- :
- $c <<EOI && $b
- test -d '' 2>"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 <<EOI && $b
-touch a &!a;
-rm a
-EOI
-
-: file-update
-:
-: Test that existing file touch doesn't fail.
-:
-$c <<EOI && $b
-cat <'' >=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 <<EOI && $b
-{
- +touch a
- {
- touch ../a
- }
-}
-EOI
-
-: unknown-option
-:
-$c <<EOI && $b
-touch -u 2>"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 <<EOI && $b
-touch '' 2>"touch: invalid path ''" != 0
-EOI
-
-: dir-update
-:
-: Test touching an existing directory.
-:
-$c <<EOI && $b
-mkdir a;
-touch a 2>~'%touch: cannot create/update .+: .+%' != 0
-EOI
-
-: after
+: cleanup
:
{
- : success
+ : enabled
:
- $c <<EOI && $b
- touch a;
- touch --after a b
- EOI
+ $c <'touch a' && $b
- : no-value
+ : disabled
:
$c <<EOI && $b
- touch --after 2>"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 <<EOI && $b
- touch --after a b 2>~"%touch: cannot obtain file '.+a' modification time: .+%" != 0
- EOI
+ {
+ +touch a
+ {
+ touch ../a
+ }
+ }
+ EOI
}