From 28106f96de8ae5cdb3a0ee0e3a8a8185551e3b00 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 20 Jan 2017 20:25:59 +0300 Subject: Add support for comparison of test command output to a file --- tests/common.test | 2 +- tests/search/dir/testscript | 4 +-- tests/test/common.test | 2 +- tests/test/config-test/testscript | 36 +++++++++++------------ tests/test/script-integration/testscript | 2 +- tests/test/script/builtin/cat.test | 2 +- tests/test/script/builtin/touch.test | 2 +- tests/test/script/common.test | 6 ++-- tests/test/script/runner/cleanup.test | 6 ++-- tests/test/script/runner/redirect.test | 50 +++++++++++++++++++++++--------- 10 files changed, 67 insertions(+), 45 deletions(-) (limited to 'tests') diff --git a/tests/common.test b/tests/common.test index d495da0..250948e 100644 --- a/tests/common.test +++ b/tests/common.test @@ -6,7 +6,7 @@ # +mkdir build -+cat <>>build/bootstrap.build ++cat <=build/bootstrap.build project = test amalgamation = EOI diff --git a/tests/search/dir/testscript b/tests/search/dir/testscript index 4c427b2..49c964e 100644 --- a/tests/search/dir/testscript +++ b/tests/search/dir/testscript @@ -11,11 +11,11 @@ test.arguments = 'update(../)' # baz/ has invalid buildfile # +mkdir foo bar baz -+cat <>>bar/buildfile ++cat <=bar/buildfile print bar ./: EOI -+cat <'assert false' >>>baz/buildfile ++cat <'assert false' >=baz/buildfile : no-buildfile : diff --git a/tests/test/common.test b/tests/test/common.test index 0f63bd3..7e3aa67 100644 --- a/tests/test/common.test +++ b/tests/test/common.test @@ -7,7 +7,7 @@ # +mkdir build -+cat <>>build/bootstrap.build ++cat <=build/bootstrap.build project = test amalgamation = diff --git a/tests/test/config-test/testscript b/tests/test/config-test/testscript index be342ef..0851da7 100644 --- a/tests/test/config-test/testscript +++ b/tests/test/config-test/testscript @@ -12,14 +12,14 @@ test.cleanups = &!./ #@@ TMP +mkdir proj +mkdir proj/build -+cat <>>proj/build/bootstrap.build ++cat <=proj/build/bootstrap.build project = proj amalgamation = using test EOI -+cat <>>proj/buildfile ++cat <=proj/buildfile d = tests/ units/ ./: $d include $d @@ -29,13 +29,13 @@ EOI # +mkdir proj/tests +mkdir proj/tests/build -+cat <>>proj/tests/build/bootstrap.build ++cat <=proj/tests/build/bootstrap.build project = using test EOI -+cat <>>proj/tests/buildfile ++cat <=proj/tests/buildfile d = script/ ./: $d include $d @@ -44,17 +44,17 @@ EOI # tests/script - scripted test # +mkdir proj/tests/script -+cat <>>proj/tests/script/buildfile ++cat <=proj/tests/script/buildfile ./: test{basics.test} EOI -+cat <>>proj/tests/script/basics.test -echo 'tests/script/basics/foo' >+ : foo -echo 'tests/script/basics/bar' >+ : bar ++cat <=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 + echo 'tests/script/basics/baz/foo' >| : foo + echo 'tests/script/basics/baz/bar' >| : bar } EOI @@ -64,13 +64,13 @@ EOI # This one is "dual": test and sub-test alias. # -+cat <>>proj/units/buildfile ++cat <=proj/units/buildfile d = simple/ script/ ./: $d test{testscript} include $d EOI -+cat <>>proj/units/testscript -echo 'units' >+ ++cat <=proj/units/testscript +echo 'units' >| EOI # units/simple - simple (non-scripted) test @@ -81,7 +81,7 @@ EOI # +mkdir proj/units/simple +touch proj/units/simple/driver -+cat <>>proj/units/simple/buildfile ++cat <=proj/units/simple/buildfile driver = $src_root/../../exe{driver} #@@ TMP file{driver}@./: $driver ./: file{driver} $driver @@ -92,12 +92,12 @@ EOI # units/script - scripted test # +mkdir proj/units/script -+cat <>>proj/units/script/buildfile ++cat <=proj/units/script/buildfile ./: test{testscript} EOI -+cat <>>proj/units/script/testscript -echo 'units/script/foo' >+ : foo -echo 'units/script/bar' >+ : bar ++cat <=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). diff --git a/tests/test/script-integration/testscript b/tests/test/script-integration/testscript index f102f5b..faade22 100644 --- a/tests/test/script-integration/testscript +++ b/tests/test/script-integration/testscript @@ -74,7 +74,7 @@ EOE : scope. Also note that we still have to remove everything after detecting the : failure. : -cat <>>foo.test; +cat <=foo.test; touch ../../dummy EOI $* <>/EOE &test/*** != 0 diff --git a/tests/test/script/builtin/cat.test b/tests/test/script/builtin/cat.test index f5041fc..442ef00 100644 --- a/tests/test/script/builtin/cat.test +++ b/tests/test/script/builtin/cat.test @@ -33,7 +33,7 @@ $b : file : $c <>>out; +cat <=out; foo bar EOF diff --git a/tests/test/script/builtin/touch.test b/tests/test/script/builtin/touch.test index a80a05c..b3a043e 100644 --- a/tests/test/script/builtin/touch.test +++ b/tests/test/script/builtin/touch.test @@ -24,7 +24,7 @@ $b : Test that existing file touch doesn't fail. : $c <>>a; +cat <"" >=a; touch a EOI $b diff --git a/tests/test/script/common.test b/tests/test/script/common.test index 177fa75..781be30 100644 --- a/tests/test/script/common.test +++ b/tests/test/script/common.test @@ -7,7 +7,7 @@ # +mkdir build -+cat <<"EOI" >>>build/bootstrap.build ++cat <<"EOI" >=build/bootstrap.build project = test amalgamation = @@ -18,7 +18,7 @@ EOI # levels up from our working directory. # +if! $empty($target) - cat <<"EOI" >>>build/root.build + cat <<"EOI" >=build/root.build target = \$src_root/../../$string([name] $target) test{*}: test = \$target EOI @@ -31,6 +31,6 @@ end # Note that the buildfile is clever hack that relies on the first target # automatically becoming dir{./}'s prerequisite. # -c = cat >>>testscript +c = cat >=testscript b = $0 --jobs 1 --quiet --buildfile - test <"'test{testscript}: \$target'" \ &?test/*** diff --git a/tests/test/script/runner/cleanup.test b/tests/test/script/runner/cleanup.test index ed724ee..1c3ccae 100644 --- a/tests/test/script/runner/cleanup.test +++ b/tests/test/script/runner/cleanup.test @@ -46,7 +46,7 @@ b += --no-column : $c <>>&a; + $* -o foo >+a; rm a EOI $b @@ -224,7 +224,7 @@ $b : : 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 test/1/ is not empty EOE @@ -235,7 +235,7 @@ EOE : $c <>>a +$* -o foo >=a EOO $b 2>>/EOE != 0 testscript:2: error: registered for cleanup directory test/1/ is not empty diff --git a/tests/test/script/runner/redirect.test b/tests/test/script/runner/redirect.test index e2d765c..f32492a 100644 --- a/tests/test/script/runner/redirect.test +++ b/tests/test/script/runner/redirect.test @@ -465,31 +465,53 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. : file : { - : in-out + : in : $c <>>out; + $* -o foo >=out; $* -i 1 <<foo EOI $b - : append + : out : - $c <>>out; - $* -e bar 2>>>&out; - $* -i 1 <<>EOO - foo - bar - EOO - EOI - $b + { + : match + : + $c <=out; + $* -e bar 2>+out; + $* -i 1 <>>out + foo + bar + EOF + EOI + $b + + : mismatch + : + $c <=out; + $* -o bar >>>out + EOI + $b 2>>/~%EOE%d != 0 + %testscript:2: error: ../../../../../driver(.exe)? stdout doesn't match the expected output% + info: stdout: test/1/stdout-2 + info: expected stdout: test/1/out + info: stdout diff: test/1/stdout-2.diff + %--- \.*% + %\+\+\+ \.*% + %@@ \.*% + -foo + +bar + EOE + } : merge : $c <&1 >>>out; - $* -e baz -o biz 1>&2 2>>>&out; + $* -o foo -e bar 2>&1 >=out; + $* -e baz -o biz 1>&2 2>+out; $* -i 1 <<>EOO foo bar -- cgit v1.1