diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-01-11 10:14:23 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-01-12 10:58:19 +0200 |
commit | 9bf93c1ab73ee3cd2b763285fc5fc5456e972854 (patch) | |
tree | 0357c36e12fe2137ef6c9bd228e9d69bb2489a02 /tests | |
parent | 33ed305eac57bff406fa3f672ba8acc4941e8f13 (diff) |
Implement support for narrowing down tests (config.test)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test/buildfile | 2 | ||||
-rw-r--r-- | tests/test/common.test | 10 | ||||
-rw-r--r-- | tests/test/config-test/buildfile | 10 | ||||
-rw-r--r-- | tests/test/config-test/driver.cxx | 19 | ||||
-rw-r--r-- | tests/test/config-test/testscript | 200 |
5 files changed, 238 insertions, 3 deletions
diff --git a/tests/test/buildfile b/tests/test/buildfile index 9c92c93..c0ea682 100644 --- a/tests/test/buildfile +++ b/tests/test/buildfile @@ -2,6 +2,6 @@ # copyright : Copyright (c) 2014-2017 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -d = script/ +d = config-test/ script/ ./: $d file{common.test} include $d diff --git a/tests/test/common.test b/tests/test/common.test index da366ce..0f63bd3 100644 --- a/tests/test/common.test +++ b/tests/test/common.test @@ -14,10 +14,16 @@ amalgamation = using test EOI -test.options += --jobs 1 --quiet --buildfile - +# By default read buildfile from stdin. +# +if ($null($test.options)) + test.options = --buildfile - +end + +test.options += --jobs 1 --quiet # By default perform test. # -if ($empty($test.arguments)) +if ($null($test.arguments)) test.arguments = test end diff --git a/tests/test/config-test/buildfile b/tests/test/config-test/buildfile new file mode 100644 index 0000000..cca33fa --- /dev/null +++ b/tests/test/config-test/buildfile @@ -0,0 +1,10 @@ +# file : tests/test/config-build/buildfile +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test config.test. +# + +./: test{testscript} exe{driver} $b + +exe{driver}: cxx{driver} diff --git a/tests/test/config-test/driver.cxx b/tests/test/config-test/driver.cxx new file mode 100644 index 0000000..1da7c9d --- /dev/null +++ b/tests/test/config-test/driver.cxx @@ -0,0 +1,19 @@ +// file : tests/test/config-test/driver.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include <iostream> + +using namespace std; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " <arg>" << endl; + return 1; + } + + cout << argv[1] << endl; +} diff --git a/tests/test/config-test/testscript b/tests/test/config-test/testscript new file mode 100644 index 0000000..be342ef --- /dev/null +++ b/tests/test/config-test/testscript @@ -0,0 +1,200 @@ +# file : tests/test/config-build/testscript +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Setup a realistic test project that we will then exercise. +# + +test.options = --jobs 1 --quiet +test.arguments = 'test(../proj/@./)' # Test out-of-src (for parallel). +#test.cleanups = &**/ # Cleanup out directory structure. +test.cleanups = &!./ #@@ TMP + ++mkdir proj ++mkdir proj/build ++cat <<EOI >>>proj/build/bootstrap.build +project = proj +amalgamation = + +using test +EOI + ++cat <<EOI >>>proj/buildfile +d = tests/ units/ +./: $d +include $d +EOI + +# tests/ - as a subproject +# ++mkdir proj/tests ++mkdir proj/tests/build ++cat <<EOI >>>proj/tests/build/bootstrap.build +project = + +using test +EOI + ++cat <<EOI >>>proj/tests/buildfile +d = script/ +./: $d +include $d +EOI + +# tests/script - scripted test +# ++mkdir proj/tests/script ++cat <<EOI >>>proj/tests/script/buildfile +./: test{basics.test} +EOI ++cat <<EOI >>>proj/tests/script/basics.test +echo 'tests/script/basics/foo' >+ : foo +echo 'tests/script/basics/bar' >+ : bar + +: baz +{ + echo 'tests/script/basics/baz/foo' >+ : foo + echo 'tests/script/basics/baz/bar' >+ : bar +} +EOI + +# units/ - as a subdirectory +# ++mkdir proj/units + +# This one is "dual": test and sub-test alias. +# ++cat <<EOI >>>proj/units/buildfile +d = simple/ script/ +./: $d test{testscript} +include $d +EOI ++cat <<EOI >>>proj/units/testscript +echo 'units' >+ +EOI + +# units/simple - simple (non-scripted) test +# +# This one is a bit tricky since we need an executable to run. We don't want +# to be building anything as part of our test project so what we do is test +# a dummy file target with an overridden test target. +# ++mkdir proj/units/simple ++touch proj/units/simple/driver ++cat <<EOI >>>proj/units/simple/buildfile +driver = $src_root/../../exe{driver} +#@@ TMP file{driver}@./: $driver +./: file{driver} $driver +file{driver}@./: test = $driver +file{driver}@./: test.arguments = units/simple +EOI + +# units/script - scripted test +# ++mkdir proj/units/script ++cat <<EOI >>>proj/units/script/buildfile +./: test{testscript} +EOI ++cat <<EOI >>>proj/units/script/testscript +echo 'units/script/foo' >+ : foo +echo 'units/script/bar' >+ : bar +EOI + +# Now the tests. Should all be top-level, no groups (or set test.arguments). +# + +: all +: +$* >>EOO +tests/script/basics/foo +tests/script/basics/bar +tests/script/basics/baz/foo +tests/script/basics/baz/bar +units/simple +units/script/foo +units/script/bar +units +EOO + +: alias-pass +: Test lead-up alias pass-through (but not test) +: +$* config.test=units/simple/file{driver} >>EOO +units/simple +EOO + +: alias-test +: Test lead-up alias test (but not pass-through) +: +$* config.test=dir{units/} >>EOO +units +EOO + +: alias-pass-test +: Test lead-up alias pass-through and test +: +$* config.test=units/ >>EOO +units/simple +units/script/foo +units/script/bar +units +EOO + +: alias-pass-id-only +: Test lead-up alias pass-through (ids only) +: +$* config.test=bogus >>EOO +units/simple +EOO + +: target-simple +: +$* config.test=units/simple/file{driver} >>EOO +units/simple +EOO + +: target-script +: +$* config.test=dir{units/script/} >>EOO +units/script/foo +units/script/bar +EOO + +: id +: +$* config.test=foo >>EOO +units/simple +units/script/foo +EOO + +: target-id +: +$* config.test=dir{units/script/}@foo >>EOO +units/script/foo +EOO + +: target-ids +: +$* 'config.test=dir{units/script/}@{foo bar}' >>EOO +units/script/foo +units/script/bar +EOO + +: id-group +: +$* config.test=tests/@{basics/baz} >>EOO +tests/script/basics/baz/foo +tests/script/basics/baz/bar +EOO + +: id-in-group +: +$* config.test=tests/@{basics/baz/bar} >>EOO +tests/script/basics/baz/bar +EOO + +# @@ TMP HACK +# +-rm -r all/ alias-pass/ alias-test/ alias-pass-test/ alias-pass-id-only/ \ + target-simple/ target-script/ id/ target-id/ target-ids/ id-group/ \ + id-in-group/ |