aboutsummaryrefslogtreecommitdiff
path: root/tests/test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test')
-rw-r--r--tests/test/common.test1
-rw-r--r--tests/test/script/builtin/buildfile2
-rw-r--r--tests/test/script/builtin/cat.test2
-rw-r--r--tests/test/script/builtin/echo.test10
-rw-r--r--tests/test/script/builtin/mkdir.test2
-rw-r--r--tests/test/script/builtin/rm.test2
-rw-r--r--tests/test/script/builtin/touch.test2
-rw-r--r--tests/test/script/common.test27
-rw-r--r--tests/test/script/integration/buildfile3
-rw-r--r--tests/test/script/runner/buildfile9
-rw-r--r--tests/test/script/runner/cleanup.test65
-rw-r--r--tests/test/script/runner/redirect.test2
-rw-r--r--tests/test/script/runner/status.test10
13 files changed, 77 insertions, 60 deletions
diff --git a/tests/test/common.test b/tests/test/common.test
index ad0ae36..6b54bc9 100644
--- a/tests/test/common.test
+++ b/tests/test/common.test
@@ -14,7 +14,6 @@ amalgamation =
using test
EOI
-test = $effect($build.path)
test.options += --jobs 1 --quiet --buildfile -
# By default perform test.
diff --git a/tests/test/script/builtin/buildfile b/tests/test/script/builtin/buildfile
index 77d74cb..3d07a73 100644
--- a/tests/test/script/builtin/buildfile
+++ b/tests/test/script/builtin/buildfile
@@ -2,4 +2,4 @@
# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
-./: test{cat echo mkdir rm touch}
+./: test{cat echo mkdir rm touch} $b
diff --git a/tests/test/script/builtin/cat.test b/tests/test/script/builtin/cat.test
index f94b7bd..edde422 100644
--- a/tests/test/script/builtin/cat.test
+++ b/tests/test/script/builtin/cat.test
@@ -1,4 +1,4 @@
-# file : tests/test/script/runner/cat.test
+# file : tests/test/script/builtin/cat.test
# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
diff --git a/tests/test/script/builtin/echo.test b/tests/test/script/builtin/echo.test
index 7f43aac..73bc480 100644
--- a/tests/test/script/builtin/echo.test
+++ b/tests/test/script/builtin/echo.test
@@ -1,11 +1,15 @@
-# file : tests/test/script/runner/echo.test
+# file : tests/test/script/builtin/echo.test
# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
+.include ../common.test
+
: string
:
-echo foo >foo
+$c <'echo foo >foo';
+$b
: strings
:
-echo foo bar >"foo bar"
+$c <'echo foo bar >"foo bar"';
+$b
diff --git a/tests/test/script/builtin/mkdir.test b/tests/test/script/builtin/mkdir.test
index 6b7b5c9..a8857c1 100644
--- a/tests/test/script/builtin/mkdir.test
+++ b/tests/test/script/builtin/mkdir.test
@@ -1,4 +1,4 @@
-# file : tests/test/script/runner/mkdir.test
+# file : tests/test/script/builtin/mkdir.test
# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
diff --git a/tests/test/script/builtin/rm.test b/tests/test/script/builtin/rm.test
index bb12827..cf5d2fa 100644
--- a/tests/test/script/builtin/rm.test
+++ b/tests/test/script/builtin/rm.test
@@ -1,4 +1,4 @@
-# file : tests/test/script/runner/rm.test
+# file : tests/test/script/builtin/rm.test
# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
diff --git a/tests/test/script/builtin/touch.test b/tests/test/script/builtin/touch.test
index 0f9e4ef..da9ed91 100644
--- a/tests/test/script/builtin/touch.test
+++ b/tests/test/script/builtin/touch.test
@@ -1,4 +1,4 @@
-# file : tests/test/script/runner/touch.test
+# file : tests/test/script/builtin/touch.test
# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
diff --git a/tests/test/script/common.test b/tests/test/script/common.test
index abd1faa..f58ed86 100644
--- a/tests/test/script/common.test
+++ b/tests/test/script/common.test
@@ -7,21 +7,30 @@
#
+mkdir build
-+cat <<EOI >>>build/bootstrap.build
++cat <<"EOI" >>>build/bootstrap.build
project = test
amalgamation =
using test
EOI
-# The "cat & build" setup: first cat ($c) the testscript, then run build
-# ($b) which will execute the testscript.
+# We assume the specified target if any is in out_base which would be two
+# levels up from our working directory.
#
-c = cat >>>testscript
-b = $effect($build.path) --jobs 1 --quiet --buildfile - test \
- <'./: test{testscript}' &?test/***
++if! $empty($target)
+ cat <<"EOI" >>>build/root.build
+ target = \$src_root/../../$string([name] $target)
+ test{*}: test = \$target
+ EOI
+end
-# Add extra set of quotes since this value will be "cat" (normally as $*)
-# into testscript.
+# The "cat & build" setup: first cat ($c) the testscript, then run build ($b)
+# which will execute the testscript. We have to quote stdin because of the
+# command line re-expansion.
+#
+# Note that the buildfile is clever hack that relies on the first target
+# automatically becoming dir{./}'s prerequisite.
#
-test = "'$test'"
+c = cat >>>testscript
+b = $0 --jobs 1 --quiet --buildfile - test <"'test{testscript}: \$target'" \
+&?test/***
diff --git a/tests/test/script/integration/buildfile b/tests/test/script/integration/buildfile
index 28aa014..e74eed7 100644
--- a/tests/test/script/integration/buildfile
+++ b/tests/test/script/integration/buildfile
@@ -2,5 +2,4 @@
# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
-./: test{testscript}
-
+./: test{testscript} $b
diff --git a/tests/test/script/runner/buildfile b/tests/test/script/runner/buildfile
index e5f2761..375be18 100644
--- a/tests/test/script/runner/buildfile
+++ b/tests/test/script/runner/buildfile
@@ -2,8 +2,11 @@
# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
-import libs = libbutl%lib{butl}
+./: test{cleanup status} exe{driver} $b
-exe{driver}: cxx{driver} $libs test{cleanup redirect status}
+# @@ Do test{*} once redirect folds in.
+#
+test{cleanup}@./ test{status}@./: target = exe{driver}
-include ../../../../../build2/
+import libs = libbutl%lib{butl}
+exe{driver}: cxx{driver} $libs test{redirect}
diff --git a/tests/test/script/runner/cleanup.test b/tests/test/script/runner/cleanup.test
index c68304c..f14d02d 100644
--- a/tests/test/script/runner/cleanup.test
+++ b/tests/test/script/runner/cleanup.test
@@ -10,39 +10,39 @@ td = [string] $path.canonicalize(test/)
# Valid cleanups.
#
-# @@ TODO: $c <"$* -f a &a" && $b
+# @@ TODO: $c <'$* -f a &a' && $b
#
: file-always
:
-$c <"$* -f a &a";
+$c <'$* -f a &a';
$b
: file-maybe
:
-$c <"$* &?a";
+$c <'$* &?a';
$b
: file-never
:
-$c <"$* &!a";
+$c <'$* &!a';
$b
: file-implicit
:
: Test that a file created out of the testscript working directory is not
: implicitly registered for cleanup. If it were, the test would fail due to
-: 'rm' failure.
+: rm failure.
:
-$c <"touch ../../a";
+$c <'touch ../../a';
$b;
rm a
: file-append
:
-: Test that file append redirect doesn't not register cleanup. If it did, that
-: cleanup would fail as the file would be already deleted by 'rm'.
+: Test that file append redirect does not not register cleanup. If it did,
+: that cleanup would fail as the file would be already deleted by rm.
:
-$c <<"EOI";
+$c <<EOI;
touch a &!a;
$* -o foo >>>&a;
rm a
@@ -51,39 +51,39 @@ $b
: dir-always
:
-$c <"$* -d a &a/";
+$c <'$* -d a &a/';
$b
: dir-maybe
:
-$c <"$* &?a/";
+$c <'$* &?a/';
$b
: dir-implicit
:
: Test that a directory created out of the testscript working directory is not
: implicitly registered for cleanup. If it were, the test would fail due to
-: 'rm' failure.
+: rm failure.
:
-$c <"mkdir ../../a";
+$c <'mkdir ../../a';
$b;
rm -r a
: wildcard-always
:
-$c <"$* -d a/b -f a/b/c &a/***";
+$c <'$* -d a/b -f a/b/c &a/***';
$b
: wildcard-maybe
:
-$c <"$* &?a/***";
+$c <'$* &?a/***';
$b
: order
:
: Test that cleanup is performed in registration reversed order.
:
-$c <"$* -d a/b &a/ &a/b/";
+$c <'$* -d a/b &a/ &a/b/';
$b
# Invalid cleanups.
@@ -92,7 +92,7 @@ $b
:
: Test cleanup of non-existing file.
:
-$c <"$* &a";
+$c <'$* &a';
$b 2>>"EOE" != 0
testscript:1: error: registered for cleanup file $path.canonicalize(test/1/a) does not exist
EOE
@@ -101,7 +101,7 @@ EOE
:
: Test explicit cleanup of a file out of the testscript working directory.
:
-$c <"$* &../../a";
+$c <'$* &../../a';
$b 2>>"EOE" != 0
testscript:1: error: file cleanup $path.canonicalize(../../a) is out of working directory $td
EOE
@@ -111,7 +111,7 @@ EOE
: Test cleanup explicit registration of a file being outside the test working
: directory but inside the script working directory.
:
-$c <"$* &../a";
+$c <'$* &../a';
$b 2>>"EOE" != 0
testscript:1: error: registered for cleanup file $path.canonicalize(test/a) does not exist
EOE
@@ -120,14 +120,14 @@ EOE
:
: Test cleanup of a directory as a file.
:
-$c <"$* -d a &a";
+$c <'$* -d a &a';
$b 2>- != 0 # @@ REGEX
: dir-not-exists
:
: Test cleanup of non-existing directory.
:
-$c <"$* &a/";
+$c <'$* &a/';
$b 2>>"EOE" != 0
testscript:1: error: registered for cleanup directory ([string] $path.canonicalize(test/1/a/)) does not exist
EOE
@@ -136,7 +136,7 @@ EOE
:
: Test cleanup of a directory out of the testscript working directory.
:
-$c <"$* &../../a/";
+$c <'$* &../../a/';
$b 2>>"EOE" != 0
testscript:1: error: directory cleanup ([string] $path.canonicalize(../../a/)) is out of working directory $td
EOE
@@ -146,7 +146,7 @@ EOE
: Test cleanup explicit registration of a directory being outside the test
: working directory but inside the testscript working directory.
:
-$c <"$* &../a/";
+$c <'$* &../a/';
$b 2>>"EOE" != 0
testscript:1: error: registered for cleanup directory ([string] $path.canonicalize(test/a/)) does not exist
EOE
@@ -155,7 +155,7 @@ EOE
:
: Test cleanup of a non-empty directory.
:
-$c <"$* -d a -f a/b &a/";
+$c <'$* -d a -f a/b &a/';
$b 2>>"EOE" != 0
testscript:1: error: registered for cleanup directory ([string] $path.canonicalize(test/1/a/)) is not empty
EOE
@@ -164,14 +164,14 @@ EOE
:
: Test cleanup of a file as a directory.
:
-$c <"$* -f a &a/";
+$c <'$* -f a &a/';
$b 2>- != 0 # @@ REGEX
: wildcard-not-exists
:
: Test cleanup of a wildcard not matching any directory.
:
-$c <"$* &a/***";
+$c <'$* &a/***';
$b 2>>"EOE" != 0
testscript:1: error: registered for cleanup wildcard $path.canonicalize(test/1/a/***) doesn't match a directory
EOE
@@ -180,7 +180,7 @@ EOE
:
: Test cleanup of a wildcard out of the testscript working directory.
:
-$c <"$* &../../a/***";
+$c <'$* &../../a/***';
$b 2>>"EOE" != 0
testscript:1: error: wildcard cleanup $path.canonicalize(../../a/***) is out of working directory $td
EOE
@@ -188,9 +188,10 @@ EOE
: wildcard-in-wd
:
: Test cleanup registration of a wildcard matching the directory that being
-: outside the test working directory is inside the testscript working directory.
+: outside the test working directory is inside the testscript working
+: directory.
:
-$c <"$* &../a/***";
+$c <'$* &../a/***';
$b 2>>"EOE" != 0
testscript:1: error: registered for cleanup wildcard $path.canonicalize(test/a/***) doesn't match a directory
EOE
@@ -199,14 +200,14 @@ EOE
:
: Test cleanup of a file as a wildcard.
:
-$c <"$* -f a &a/***";
+$c <'$* -f a &a/***';
$b 2>- != 0 # @@ REGEX
: implicit-overwrite
:
: Test an implicit cleanup being overwritten with the explicit one,
:
-$c <"$* -o foo >>>a &!a";
+$c <'$* -o foo >>>a &!a';
$b 2>>"EOE" != 0
testscript:1: error: registered for cleanup directory ([string] $path.canonicalize(test/1/)) is not empty
EOE
@@ -215,7 +216,7 @@ EOE
:
: Test an explicit cleanup not being overwritten with the implicit one.
:
-$c <<"EOO";
+$c <<EOO;
$* &!a;
$* -o foo >>>a
EOO
diff --git a/tests/test/script/runner/redirect.test b/tests/test/script/runner/redirect.test
index 16c17d8..e8d57c1 100644
--- a/tests/test/script/runner/redirect.test
+++ b/tests/test/script/runner/redirect.test
@@ -2,6 +2,8 @@
# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
+# @@ Needs conversion to cat & build (then adjust buildfile).
+
$* -o foo >- : out-null
$* -e foo 2>- : err-null
$* -i 0 <foo : in-str
diff --git a/tests/test/script/runner/status.test b/tests/test/script/runner/status.test
index 941d485..e115f13 100644
--- a/tests/test/script/runner/status.test
+++ b/tests/test/script/runner/status.test
@@ -7,33 +7,33 @@
b += --no-column
if ($cxx.target.class == "windows")
- ext = ".exe"
+ ext = .exe
end
# Successfull tests.
#
: eq-true
:
-$c <"$* == 0";
+$c <'$* == 0';
$b
: ne-true
:
-$c <"$* -s 1 != 0";
+$c <'$* -s 1 != 0';
$b
# Faulty tests.
#
: eq-false
:
-$c <"$* -s 1 == 0";
+$c <'$* -s 1 == 0';
$b 2>>"EOE" != 0
testscript:1: error: $path.canonicalize(../../../driver$ext) exit status 1 != 0
EOE
: ne-false
:
-$c <"$* -s 1 != 1";
+$c <'$* -s 1 != 1';
$b 2>>"EOE" != 0
testscript:1: error: $path.canonicalize(../../../driver$ext) exit status 1 == 1
EOE