From 36ec90018e1a6337d23fc5286ed926c2134bde1f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 5 Feb 2018 14:39:47 +0200 Subject: Add tests for auto-generated test inputs/outputs --- tests/test/script-integration/buildfile | 8 --- tests/test/script-integration/testscript | 84 ------------------------------ tests/test/script/generated/buildfile | 8 +++ tests/test/script/generated/driver.cxx | 11 ++++ tests/test/script/generated/testscript | 34 ++++++++++++ tests/test/script/generated/testscript.in | 5 ++ tests/test/script/integration/buildfile | 8 +++ tests/test/script/integration/testscript | 86 +++++++++++++++++++++++++++++++ tests/test/simple/generated/buildfile | 8 +++ tests/test/simple/generated/driver.cxx | 11 ++++ tests/test/simple/generated/output.in | 1 + tests/test/simple/generated/testscript | 42 +++++++++++++++ tests/test/simple/generated/utility.cxx | 28 ++++++++++ 13 files changed, 242 insertions(+), 92 deletions(-) delete mode 100644 tests/test/script-integration/buildfile delete mode 100644 tests/test/script-integration/testscript create mode 100644 tests/test/script/generated/buildfile create mode 100644 tests/test/script/generated/driver.cxx create mode 100644 tests/test/script/generated/testscript create mode 100644 tests/test/script/generated/testscript.in create mode 100644 tests/test/script/integration/buildfile create mode 100644 tests/test/script/integration/testscript create mode 100644 tests/test/simple/generated/buildfile create mode 100644 tests/test/simple/generated/driver.cxx create mode 100644 tests/test/simple/generated/output.in create mode 100644 tests/test/simple/generated/testscript create mode 100644 tests/test/simple/generated/utility.cxx (limited to 'tests/test') diff --git a/tests/test/script-integration/buildfile b/tests/test/script-integration/buildfile deleted file mode 100644 index 4249e1f..0000000 --- a/tests/test/script-integration/buildfile +++ /dev/null @@ -1,8 +0,0 @@ -# file : tests/test/script-integration/buildfile -# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test integration of testscript into build system. -# - -./: test{testscript} $b diff --git a/tests/test/script-integration/testscript b/tests/test/script-integration/testscript deleted file mode 100644 index faade22..0000000 --- a/tests/test/script-integration/testscript +++ /dev/null @@ -1,84 +0,0 @@ -# file : tests/test/script-integration/testscript -# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: script-files -: -{ - +touch testscript foo.test bar.test - - : testscript-and-other - : - $* <>/EOE != 0 - ./: test{../testscript ../foo} - EOI - error: both 'testscript' and other names specified for dir{./} - EOE - - : other-and-testscript - : - $* <>/EOE != 0 - ./: test{../foo ../testscript} - EOI - error: both 'testscript' and other names specified for dir{./} - EOE - - : others - : - $* <>~%EOE% != 0 -./: test{foo} -EOI -%error: working directory test[/\\] is a file/symlink% -EOE - -: wd-exists-before -: -touch foo.test; -mkdir test &!test/; -$* <>/EOE -./: test{foo} -EOI -warning: working directory test/ exists at the beginning of the test -EOE - -: wd-not-empty-before -: -touch foo.test; -mkdir test &!test/; -touch test/dummy &!test/dummy; -$* <>/EOE -./: test{foo} -EOI -warning: working directory test/ exists and is not empty at the beginning of the test -EOE - -: wd-not-empty-after -: -: The idea here is to run a nested testscript that creates (but does not -: clean up) a file in our working directory. Note that an implicit cleanup -: cancelation is not required as the file is out of the test root directory -: scope. Also note that we still have to remove everything after detecting the -: failure. -: -cat <=foo.test; -touch ../../dummy -EOI -$* <>/EOE &test/*** != 0 -./: test{foo} -EOI -error: working directory test/ is not empty at the end of the test -EOE diff --git a/tests/test/script/generated/buildfile b/tests/test/script/generated/buildfile new file mode 100644 index 0000000..c27b49d --- /dev/null +++ b/tests/test/script/generated/buildfile @@ -0,0 +1,8 @@ +# file : tests/test/script/generated/buildfile +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test generated testscripts. +# + +./: test{testscript} $b file{*.cxx +*.in} diff --git a/tests/test/script/generated/driver.cxx b/tests/test/script/generated/driver.cxx new file mode 100644 index 0000000..e155462 --- /dev/null +++ b/tests/test/script/generated/driver.cxx @@ -0,0 +1,11 @@ +// file : tests/test/script/generated/driver.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include + +int +main () +{ + std::cout << "1.2.3" << std::endl; +} diff --git a/tests/test/script/generated/testscript b/tests/test/script/generated/testscript new file mode 100644 index 0000000..572c73f --- /dev/null +++ b/tests/test/script/generated/testscript @@ -0,0 +1,34 @@ +# file : tests/test/script/generated/testscript +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +test.arguments = test clean + +# Note: using common.test from test/, not script/. +# +.include ../../common.test + +# @@ in module +# ++cat <+build/bootstrap.build +using version +EOI ++cat <=manifest +: 1 +name: test +version: 1.2.3 +EOI + ++cat <=build/root.build +using cxx +EOI + +: testscript +: +ln -s $src_base/driver.cxx ./; +ln -s $src_base/testscript.in ./; +$* <'@version@' diff --git a/tests/test/script/integration/buildfile b/tests/test/script/integration/buildfile new file mode 100644 index 0000000..1cc1e30 --- /dev/null +++ b/tests/test/script/integration/buildfile @@ -0,0 +1,8 @@ +# file : tests/test/script/integration/buildfile +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test integration of testscript into build system. +# + +./: test{testscript} $b diff --git a/tests/test/script/integration/testscript b/tests/test/script/integration/testscript new file mode 100644 index 0000000..7074e36 --- /dev/null +++ b/tests/test/script/integration/testscript @@ -0,0 +1,86 @@ +# file : tests/test/script/integration/testscript +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Note: using common.test from test/, not script/. +# +.include ../../common.test + +: script-files +: +{ + +touch testscript foo.test bar.test + + : testscript-and-other + : + $* <>/EOE != 0 + ./: test{../testscript ../foo} + EOI + error: both 'testscript' and other names specified for dir{./} + EOE + + : other-and-testscript + : + $* <>/EOE != 0 + ./: test{../foo ../testscript} + EOI + error: both 'testscript' and other names specified for dir{./} + EOE + + : others + : + $* <>~%EOE% != 0 +./: test{foo} +EOI +%error: working directory test[/\\] is a file/symlink% +EOE + +: wd-exists-before +: +touch foo.test; +mkdir test &!test/; +$* <>/EOE +./: test{foo} +EOI +warning: working directory test/ exists at the beginning of the test +EOE + +: wd-not-empty-before +: +touch foo.test; +mkdir test &!test/; +touch test/dummy &!test/dummy; +$* <>/EOE +./: test{foo} +EOI +warning: working directory test/ exists and is not empty at the beginning of the test +EOE + +: wd-not-empty-after +: +: The idea here is to run a nested testscript that creates (but does not +: clean up) a file in our working directory. Note that an implicit cleanup +: cancelation is not required as the file is out of the test root directory +: scope. Also note that we still have to remove everything after detecting the +: failure. +: +cat <=foo.test; +touch ../../dummy +EOI +$* <>/EOE &test/*** != 0 +./: test{foo} +EOI +error: working directory test/ is not empty at the end of the test +EOE diff --git a/tests/test/simple/generated/buildfile b/tests/test/simple/generated/buildfile new file mode 100644 index 0000000..af97abd --- /dev/null +++ b/tests/test/simple/generated/buildfile @@ -0,0 +1,8 @@ +# file : tests/test/simple/generated/buildfile +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test generated test inputs/outputs. +# + +./: test{testscript} $b file{*.cxx +*.in} diff --git a/tests/test/simple/generated/driver.cxx b/tests/test/simple/generated/driver.cxx new file mode 100644 index 0000000..fb3ab8f --- /dev/null +++ b/tests/test/simple/generated/driver.cxx @@ -0,0 +1,11 @@ +// file : tests/test/simple/generated/driver.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include + +int +main () +{ + std::cout << "1.2.3" << std::endl; +} diff --git a/tests/test/simple/generated/output.in b/tests/test/simple/generated/output.in new file mode 100644 index 0000000..36d79d4 --- /dev/null +++ b/tests/test/simple/generated/output.in @@ -0,0 +1 @@ +$version$ diff --git a/tests/test/simple/generated/testscript b/tests/test/simple/generated/testscript new file mode 100644 index 0000000..9ec5220 --- /dev/null +++ b/tests/test/simple/generated/testscript @@ -0,0 +1,42 @@ +# file : tests/test/simple/generated/testscript +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +test.arguments = test clean + +.include ../../common.test + +# @@ in module +# ++cat <+build/bootstrap.build +using version +EOI ++cat <=manifest +: 1 +name: test +version: 1.2.3 +EOI + ++cat <=build/root.build +using cxx +EOI + +: input +: +ln -s $src_base/driver.cxx ./; +ln -s $src_base/utility.cxx ./; +$* < +#include + +using namespace std; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " " << endl; + return 1; + } + + ifstream ifs (argv[1], ifstream::in | ifstream::binary | ifstream::ate); + + if (!ifs.is_open ()) + cerr << "unable to open " << argv[1] << endl; + + if (ifs.tellg () == 0) + cerr << argv[1] << " is empty" << endl; + + return 0; +} -- cgit v1.1