From fb34688841668e6e4c939395c8387feabe8ddfdf Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 30 Nov 2020 22:42:40 +0300 Subject: Add support for config.test.runner --- tests/recipe/buildscript/testscript | 51 ++++++++++++++++++++++++- tests/test/script/runner/test-runner.testscript | 31 +++++++++++++++ tests/test/simple/generated/testscript | 27 +++++++++++++ 3 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 tests/test/script/runner/test-runner.testscript (limited to 'tests') diff --git a/tests/recipe/buildscript/testscript b/tests/recipe/buildscript/testscript index 2603f62..6bdbd32 100644 --- a/tests/recipe/buildscript/testscript +++ b/tests/recipe/buildscript/testscript @@ -406,7 +406,7 @@ }} % [diag=test] test {{ - cat <$path($<) >?$path($>) + cat <$path($>) >?$path($<) }} EOI @@ -431,7 +431,7 @@ % [diag=test] test {{ depdb clear - cat <$path($<) >?$path($>) + cat <$path($>) >?$path($<) }} EOI @@ -439,6 +439,53 @@ buildfile:7:3: error: 'depdb' builtin cannot be used to perform test EOE } + + : runner + : + if ($cxx.target.class != 'windows') + { + echo 'bar' >=bar; + + cat <=run; + #!/bin/sh + if test "$1" = "--trace"; then + shift + echo "$*" + fi + "$@" + EOI + + chmod u+x run; + + cat <=buildfile; + foo: bar + {{ + cp $path($<) $path($>) + }} + % [diag=test] test + {{ + if ($test.runner.path != [null]) + $test.runner.path $test.runner.options cat <$path($>) + else + cat <$path($>) + end + }} + EOI + + $* test 2>>EOE; + cp file{foo} + test file{foo} + bar + EOE + + $* test config.test.runner="./run --trace" 2>>EOE; + test file{foo} + cat + bar + EOE + + $* clean 2>- + } } : diff-label diff --git a/tests/test/script/runner/test-runner.testscript b/tests/test/script/runner/test-runner.testscript new file mode 100644 index 0000000..772fa1b --- /dev/null +++ b/tests/test/script/runner/test-runner.testscript @@ -0,0 +1,31 @@ +# file : tests/test/script/runner/test-runner.testscript +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + ++if ($cxx.target.class == 'windows') + exit +end + ++cat <=run + #!/bin/sh + if test "$1" = "--trace"; then + shift + echo "$*" + fi + "$@" + EOI + ++chmod u+x run + +run=$~/run + +: basic +: +$c <<"EOI" && $b "config.test.runner=$run --trace" + cat <'text' >'text'; # Non-test program. + \$* -o 'text' >>~%EOO% # Test program. + %.+/driver -o text% + text + EOO + EOI diff --git a/tests/test/simple/generated/testscript b/tests/test/simple/generated/testscript index f6a89d8..9ce40ba 100644 --- a/tests/test/simple/generated/testscript +++ b/tests/test/simple/generated/testscript @@ -99,3 +99,30 @@ EOI EOE } } + +: runner +: +if ($cxx.target.class != 'windows') +{ + cat <=run; + #!/bin/sh + if test "$1" = "--trace"; then + shift + echo "tracing" + fi + "$@" + EOI + + chmod u+x run; + + echo 'tracing' >=output.in; + cat $src_base/output.in >+output.in; + + $* config.test.runner="./run --trace" <