aboutsummaryrefslogtreecommitdiff
path: root/tests/test/script/builtin
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test/script/builtin')
-rw-r--r--tests/test/script/builtin/cat.test31
-rw-r--r--tests/test/script/builtin/echo.test18
-rw-r--r--tests/test/script/builtin/mkdir.test24
-rw-r--r--tests/test/script/builtin/rm.test33
-rw-r--r--tests/test/script/builtin/rmdir.test33
-rw-r--r--tests/test/script/builtin/test.test30
-rw-r--r--tests/test/script/builtin/touch.test21
7 files changed, 78 insertions, 112 deletions
diff --git a/tests/test/script/builtin/cat.test b/tests/test/script/builtin/cat.test
index 442ef00..33515bc 100644
--- a/tests/test/script/builtin/cat.test
+++ b/tests/test/script/builtin/cat.test
@@ -6,7 +6,7 @@
: in
:
-$c <<EOI;
+$c <<EOI && $b
cat <<EOF >>EOO
foo
bar
@@ -15,11 +15,10 @@ foo
bar
EOO
EOI
-$b
: dash
:
-$c <<EOI;
+$c <<EOI && $b
cat - <<EOF >>EOO
foo
bar
@@ -28,11 +27,10 @@ foo
bar
EOO
EOI
-$b
: file
:
-$c <<EOI;
+$c <<EOI && $b
cat <<EOF >=out;
foo
bar
@@ -42,11 +40,10 @@ foo
bar
EOO
EOI
-$b
: in-repeat
:
-$c <<EOI;
+$c <<EOI && $b
cat - <<EOF >>EOO
foo
bar
@@ -55,25 +52,31 @@ foo
bar
EOO
EOI
-$b
: non-existent
:
-$c <<EOI;
+$c <<EOI && $b
cat in 2>>/~%EOE% != 0
%cat: unable to print '.+/test/cat/non-existent/test/1/in': .+%
EOE
EOI
-$b
: empty-path
:
: Cat an empty path.
:
-$c <<EOI;
+$c <<EOI && $b
cat '' 2>"cat: invalid path ''" == 1
EOI
-$b
-# @@ When piping is ready test cat on a big file to test it is asynchronous.
-#
+: big
+:
+: Cat a big file (about 3MB) to test that the builtin is asynchronous.
+:
+{
+ 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$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$s$s$s$s$s$s$s$s"
+ $c <"cat <'$s' | cat >'$s'" && $b
+}
diff --git a/tests/test/script/builtin/echo.test b/tests/test/script/builtin/echo.test
index 967e330..9e49a91 100644
--- a/tests/test/script/builtin/echo.test
+++ b/tests/test/script/builtin/echo.test
@@ -6,10 +6,20 @@
: string
:
-$c <'echo foo >foo';
-$b
+$c <'echo foo >foo' && $b
: strings
:
-$c <'echo foo bar >"foo bar"';
-$b
+$c <'echo foo bar >"foo bar"' && $b
+
+: big
+:
+: Echo a big string (about 3MB) to test that the builtin is asynchronous.
+:
+{
+ 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$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$s$s$s$s$s$s$s$s"
+ $c <"echo '$s' | cat >'$s'" && $b
+}
diff --git a/tests/test/script/builtin/mkdir.test b/tests/test/script/builtin/mkdir.test
index ace4012..8f97fe3 100644
--- a/tests/test/script/builtin/mkdir.test
+++ b/tests/test/script/builtin/mkdir.test
@@ -6,69 +6,61 @@
: dirs
:
-$c <<EOI;
+$c <<EOI && $b
mkdir a b;
touch a/a b/b
EOI
-$b
: parent
:
-$c <<EOI;
+$c <<EOI && $b
mkdir -p a/b;
touch a/a a/b/b
EOI
-$b
: exists
:
-$c <'mkdir -p a a a/b a/b';
-$b
+$c <'mkdir -p a a a/b a/b' && $b
: double-dash
:
: Make sure '-p' directory is created.
:
-$c <<EOI;
+$c <<EOI && $b
mkdir -p -- -p;
touch -p/a
EOI
-$b
: no-args
:
: Test passing no arguments.
:
-$c <'mkdir 2>"mkdir: missing directory" == 1';
-$b
+$c <'mkdir 2>"mkdir: missing directory" == 1' && $b
: empty-path
:
: Test creation of empty directory path.
:
-$c <<EOI;
+$c <<EOI && $b
mkdir '' 2>"mkdir: invalid path ''" == 1
EOI
-$b
: already-exists
:
: Test creation of an existing directory.
:
-$c <<EOI;
+$c <<EOI && $b
mkdir a a 2>>/~%EOE% == 1
%mkdir: unable to create directory '.+/test/mkdir/already-exists/test/1/a': .+%
EOE
EOI
-$b
: not-exists
:
: Test creation of a directory with non-existent parent.
:
-$c <<EOI;
+$c <<EOI && $b
mkdir a/b 2>>/~%EOE% == 1
%mkdir: unable to create directory '.+/test/mkdir/not-exists/test/1/a/b': .+%
EOE
EOI
-$b
diff --git a/tests/test/script/builtin/rm.test b/tests/test/script/builtin/rm.test
index 937633b..9a9ffc6 100644
--- a/tests/test/script/builtin/rm.test
+++ b/tests/test/script/builtin/rm.test
@@ -11,15 +11,13 @@
:
: Removing with no arguments fails.
:
- $c <'rm 2>"rm: missing file" == 1';
- $b
+ $c <'rm 2>"rm: missing file" == 1' && $b
: force
:
: Removing with no arguments succeeds with -f option.
:
- $c <'rm -f';
- $b
+ $c <'rm -f' && $b
}
: file
@@ -29,11 +27,10 @@
:
: Removing existing file succeeds.
:
- $c <<EOI;
+ $c <<EOI && $b
touch a &!a;
rm a
EOI
- $b
: not-exists
:
@@ -42,19 +39,17 @@
:
: Removing non-existing file fails.
:
- $c <<EOI;
+ $c <<EOI && $b
rm a 2>>/~%EOE% == 1
%rm: unable to remove '.+/file/not-exists/fail/test/1/a': .+%
EOE
EOI
- $b
: force
:
: Removing non-existing file succeeds with -f option.
:
- $c <'rm -f a';
- $b
+ $c <'rm -f a' && $b
}
}
@@ -65,30 +60,27 @@
:
: Removing directory fails by default.
:
- $c <<EOI;
+ $c <<EOI && $b
mkdir a;
rm a 2>"rm: '$normalize([path] $~/a)' is a directory" == 1
EOI
- $b
: recursive
:
: Removing directory succeeds with -r option.
:
- $c <<EOI;
+ $c <<EOI && $b
mkdir -p a/b &!a &!a/b;
rm -r a
EOI
- $b
: scope
:
: Removing scope directory fails.
:
- $c <<EOI;
+ $c <<EOI && $b
rm -r ./ 2>"rm: '([string] $~)' contains test working directory '$~'" == 1
EOI
- $b
}
: path
@@ -98,10 +90,9 @@
:
: Removing an empty path fails.
:
- $c <<EOI;
+ $c <<EOI && $b
rm '' 2>"rm: invalid path ''" == 1
EOI
- $b
: outside-scope
:
@@ -112,19 +103,17 @@
:
: Removing path outside the testscript working directory fails.
:
- $c <<EOI;
+ $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
- $b
: force
:
: Removing path outside the testscript working directory succeeds with -f
: option.
:
- $c <'rm -f ../../a/b/c';
- $b
+ $c <'rm -f ../../a/b/c' && $b
}
}
diff --git a/tests/test/script/builtin/rmdir.test b/tests/test/script/builtin/rmdir.test
index 7621425..6666f79 100644
--- a/tests/test/script/builtin/rmdir.test
+++ b/tests/test/script/builtin/rmdir.test
@@ -11,15 +11,13 @@
:
: Removing with no arguments fails.
:
- $c <'rmdir 2>"rmdir: missing directory" == 1';
- $b
+ $c <'rmdir 2>"rmdir: missing directory" == 1' && $b
: force
:
: Removing with no arguments succeeds with -f option.
:
- $c <'rmdir -f';
- $b
+ $c <'rmdir -f' && $b
}
: dir
@@ -29,19 +27,17 @@
:
: Removing an empty path fails.
:
- $c <<EOI;
+ $c <<EOI && $b
rmdir '' 2>"rmdir: invalid path ''" == 1
EOI
- $b
: test-scope
:
: Removing scope directory fails.
:
- $c <<EOI;
+ $c <<EOI && $b
rmdir ./ 2>"rmdir: '$~' contains test working directory '$~'" == 1
EOI
- $b
: outside-scope
:
@@ -52,31 +48,28 @@
:
: Removing directory outside the testscript working directory fails.
:
- $c <<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'%
EOE
EOI
- $b
: force
:
: Removing path outside the testscript working directory succeeds with -f
: option.
:
- $c <'rmdir -f ../../a/b/c';
- $b
+ $c <'rmdir -f ../../a/b/c' && $b
}
: exists
:
: Removing existing directory succeeds.
:
- $c <<EOI;
+ $c <<EOI && $b
mkdir a &!a;
rmdir a
EOI
- $b
: not-exists
:
@@ -84,42 +77,38 @@
: fail
: Removing non-existing directory fails.
:
- $c <<EOI;
+ $c <<EOI && $b
rmdir a 2>>/~%EOE% == 1
%rmdir: unable to remove '.+/dir/not-exists/fail/test/1/a': .+%
EOE
EOI
- $b
: force
:
: Removing non-existing directory succeeds with -f option.
:
- $c <'rmdir -f a';
- $b
+ $c <'rmdir -f a' && $b
}
: not-empty
:
: Removing non-empty directory fails.
:
- $c <<EOI;
+ $c <<EOI && $b
mkdir -p a/b;
rmdir a 2>>/~%EOE% == 1
%rmdir: unable to remove '.+/dir/not-empty/test/1/a': .+%
EOE
EOI
- $b
: not-dir
:
: Removing not a directory path fails.
:
- $c <<EOI;
+ $c <<EOI && $b
touch a;
rmdir a 2>>/~%EOE% == 1
%rmdir: unable to remove '.+/dir/not-dir/test/1/a': .+%
EOE
EOI
- $b
}
diff --git a/tests/test/script/builtin/test.test b/tests/test/script/builtin/test.test
index 7e9ace4..2e792ad 100644
--- a/tests/test/script/builtin/test.test
+++ b/tests/test/script/builtin/test.test
@@ -9,21 +9,18 @@
{
: exists
:
- $c <<EOI;
+ $c <<EOI && $b
touch a;
test -f a
EOI
- $b
: not-exists
:
- $c <'test -f a == 1';
- $b
+ $c <'test -f a == 1' && $b
: not-file
:
- $c <'test -f . == 1';
- $b
+ $c <'test -f . == 1' && $b
}
: dir
@@ -31,49 +28,42 @@
{
: exists
:
- $c <'test -d .';
- $b
+ $c <'test -d .' && $b
: not-exists
:
- $c <'test -d a == 1';
- $b
+ $c <'test -d a == 1' && $b
: not-dir
:
- $c <<EOI;
+ $c <<EOI && $b
touch a;
test -d a == 1
EOI
- $b
}
: no-args
:
: Test passing no arguments.
:
-$c <'test 2>"test: missing path" == 2';
-$b
+$c <'test 2>"test: missing path" == 2' && $b
: invalid-option
:
: Test passing invalid option.
:
-$c <'test -c a 2>"test: invalid option" == 2';
-$b
+$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
+$c <'test -f a b 2>"test: unexpected argument" == 2' && $b
: empty-path
:
: Test testing an empty path.
:
-$c <<EOI;
+$c <<EOI && $b
test -d '' 2>"test: invalid path ''" == 2
EOI
-$b
diff --git a/tests/test/script/builtin/touch.test b/tests/test/script/builtin/touch.test
index b3a043e..3a543e8 100644
--- a/tests/test/script/builtin/touch.test
+++ b/tests/test/script/builtin/touch.test
@@ -6,28 +6,25 @@
: file
:
-$c <'touch a';
-$b
+$c <'touch a' && $b
: file-create
:
: Test that file is created. If it didn't then 'rm' would fail.
:
-$c <<EOI;
+$c <<EOI && $b
touch a &!a;
rm a
EOI
-$b
: file-update
:
: Test that existing file touch doesn't fail.
:
-$c <<EOI;
+$c <<EOI && $b
cat <"" >=a;
touch a
EOI
-$b
: no-cleanup
:
@@ -35,7 +32,7 @@ $b
: the file would be removed while leaving the embedded scope, and so the
: cleanup registered by the first touch would fail.
:
-$c <<EOI;
+$c <<EOI && $b
{
+touch a
{
@@ -43,32 +40,28 @@ $c <<EOI;
}
}
EOI
-$b
: no-args
:
: Test passing no arguments.
:
-$c <'touch 2>"touch: missing file" == 1';
-$b
+$c <'touch 2>"touch: missing file" == 1' && $b
: empty-path
:
: Test touching an empty path.
:
-$c <<EOI;
+$c <<EOI && $b
touch '' 2>"touch: invalid path ''" == 1
EOI
-$b
: dir-update
:
: Test touching an existing directory.
:
-$c <<EOI;
+$c <<EOI && $b
a = $~;
a += "a";
mkdir a;
touch a 2>"touch: '$a' exists and is not a file" == 1
EOI
-$b