aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-12-16 17:29:01 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-12-16 17:29:01 +0200
commit2af491cc4ad0ae4064f2e858c83ed485613adafa (patch)
tree18010b6c7b9ef13072f6e2514fcb1bb60f38d60a /tests
parent3ab61fbc2ce25afa617ed6bb50c2f8d701beeaba (diff)
Convert tests/ to subproject, initial work on cross-testing support
Diffstat (limited to 'tests')
-rw-r--r--tests/build/.gitignore1
-rw-r--r--tests/build/bootstrap.build9
-rw-r--r--tests/build/root.build17
-rw-r--r--tests/common.test1
-rw-r--r--tests/directive/buildfile2
-rw-r--r--tests/eval/buildfile2
-rw-r--r--tests/expansion/buildfile2
-rw-r--r--tests/function/builtin/buildfile2
-rw-r--r--tests/function/path/buildfile2
-rw-r--r--tests/function/path/testscript4
-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
23 files changed, 112 insertions, 67 deletions
diff --git a/tests/build/.gitignore b/tests/build/.gitignore
new file mode 100644
index 0000000..225c27f
--- /dev/null
+++ b/tests/build/.gitignore
@@ -0,0 +1 @@
+config.build
diff --git a/tests/build/bootstrap.build b/tests/build/bootstrap.build
new file mode 100644
index 0000000..42a1bce
--- /dev/null
+++ b/tests/build/bootstrap.build
@@ -0,0 +1,9 @@
+# file : tests/build/bootstrap.build
+# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+project = # Unnamed subproject.
+
+using config
+using dist
+using test
diff --git a/tests/build/root.build b/tests/build/root.build
new file mode 100644
index 0000000..d69845d
--- /dev/null
+++ b/tests/build/root.build
@@ -0,0 +1,17 @@
+# file : tests/build/root.build
+# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+cxx.std = latest
+
+using cxx
+
+hxx{*}: extension =
+cxx{*}: extension = cxx
+
+# Setup the build system driver that we are testing (which may not be the same
+# as our $build.path).
+#
+import b = build2%exe{b}
+
+dir{*}: test = $b
diff --git a/tests/common.test b/tests/common.test
index 370db00..71bdf40 100644
--- a/tests/common.test
+++ b/tests/common.test
@@ -11,7 +11,6 @@ project = test
amalgamation =
EOI
-test = $effect($build.path)
test.options += --jobs 1 --quiet --buildfile -
# By default just load the buildfile.
diff --git a/tests/directive/buildfile b/tests/directive/buildfile
index 583b149..66d2535 100644
--- a/tests/directive/buildfile
+++ b/tests/directive/buildfile
@@ -2,4 +2,4 @@
# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
-./: test{assert}
+./: test{assert} $b
diff --git a/tests/eval/buildfile b/tests/eval/buildfile
index 184a72a..c753f56 100644
--- a/tests/eval/buildfile
+++ b/tests/eval/buildfile
@@ -2,4 +2,4 @@
# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
-./: test{comma comp or-and qual ternary value}
+./: test{comma comp or-and qual ternary value} $b
diff --git a/tests/expansion/buildfile b/tests/expansion/buildfile
index 2f02852..e17c7b8 100644
--- a/tests/expansion/buildfile
+++ b/tests/expansion/buildfile
@@ -2,4 +2,4 @@
# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
-./: test{type}
+./: test{type} $b
diff --git a/tests/function/builtin/buildfile b/tests/function/builtin/buildfile
index fb06e73..a3446bb 100644
--- a/tests/function/builtin/buildfile
+++ b/tests/function/builtin/buildfile
@@ -2,4 +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/function/path/buildfile b/tests/function/path/buildfile
index 65ed19b..f39a237 100644
--- a/tests/function/path/buildfile
+++ b/tests/function/path/buildfile
@@ -2,4 +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/function/path/testscript b/tests/function/path/testscript
index 8467bce..828263f 100644
--- a/tests/function/path/testscript
+++ b/tests/function/path/testscript
@@ -32,7 +32,9 @@ s = ($cxx.target.class != windows ? '/' : '\')
if ($cxx.target.class == windows)
{
mkdir Foo;
- $* <"print \$path.normalize\('$~/foo', true)" >"$~\\Foo"
+ # @@ regex
+ #$* <'print $path.normalize($out_base/foo, true)' >~'/.+\Foo/' # cross
+ $* <'print $path.normalize($out_base/foo, true)' >"$~\\Foo"
}
}
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