From 44b0a5989f76570fc19dc41314f31c4fa9c2039b Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 11 Nov 2022 20:41:25 +0300 Subject: Add buffering for simple test diagnostics Also fix simple test redirecting diff's stdout to stderr. --- tests/test/simple/generated/driver.cxx | 18 ++++- tests/test/simple/generated/testscript | 139 ++++++++++++++++++++++++++++++--- 2 files changed, 144 insertions(+), 13 deletions(-) (limited to 'tests/test/simple/generated') diff --git a/tests/test/simple/generated/driver.cxx b/tests/test/simple/generated/driver.cxx index 89dacca..ca6dfcb 100644 --- a/tests/test/simple/generated/driver.cxx +++ b/tests/test/simple/generated/driver.cxx @@ -49,13 +49,23 @@ main (int argc, char* argv[]) } else { - ifstream ifs (argv[i]); + istream* is; + ifstream ifs; - if (!ifs.is_open ()) - cerr << "unable to open " << argv[1] << endl; + if (argv[i] != string ("-")) + { + ifs.open (argv[i]); + + if (!ifs.is_open ()) + cerr << "unable to open " << argv[1] << endl; + + is = &ifs; + } + else + is = &cin; string s; - r = getline (ifs, s) && s == "1.2.3" ? 0 : 1; + r = getline (*is, s) && s == "1.2.3" ? 0 : 1; } return r; diff --git a/tests/test/simple/generated/testscript b/tests/test/simple/generated/testscript index 9ce40ba..878120a 100644 --- a/tests/test/simple/generated/testscript +++ b/tests/test/simple/generated/testscript @@ -43,6 +43,123 @@ driver = $src_root/../exe{driver} file{output}: in{output} $src_root/manifest #@@ in module EOI +: output-mismatch +: +{ + # Get rid of --serial-stop --quiet. + # + test.options = $regex.apply($test.options, '^(--serial-stop|--quiet)$', '') + + : verbose-0 + : + { + echo '1.2.3' >=input; + echo '3.4.5' >=output; + $* -q <>/~%EOE% != 0 + driver = $src_root/../exe{driver} + ./: test = $driver + ./: $driver + ./: test.arguments = '-' + ./: file{input}: test.stdin = true + ./: file{output}: test.stdout = true + EOI + %.+ + -3.4.5 + error: test dir{./} failed + error: process diff exited with code 1 + EOE + } + + : verbose-1 + : + { + echo '1.2.3' >=input; + echo '3.4.5' >=output; + $* <>/~%EOE% != 0 + driver = $src_root/../exe{driver} + ./: test = $driver + ./: $driver + ./: test.arguments = '-' + ./: file{input}: test.stdin = true + ./: file{output}: test.stdout = true + EOI + test dir{./} + %.+ + -3.4.5 + error: test dir{./} failed + error: process diff exited with code 1 + % info: test command line: cat .+/input \| .+/driver.* - \| diff -u .+% + info: while testing dir{./} + info: failed to test dir{./} + EOE + } + + : verbose-2 + : + { + echo '1.2.3' >=input; + echo '3.4.5' >=output; + $* --verbose 2 <>/~%EOE% != 0 + driver = $src_root/../exe{driver} + ./: test = $driver + ./: $driver + ./: test.arguments = '-' + ./: file{input}: test.stdin = true + ./: file{output}: test.stdout = true + EOI + %cat .+/input \| .+/driver.* - \| diff -u .+% + %.+ + -3.4.5 + error: test dir{./} failed + error: process diff exited with code 1 + info: while testing dir{./} + info: failed to test dir{./} + EOE + } + + : verbose-3 + : + { + echo '1.2.3' >=input; + echo '3.4.5' >=output; + $* --verbose 3 <>/~%EOE% != 0 + driver = $src_root/../exe{driver} + ./: test = $driver + ./: $driver + ./: test.arguments = '-' + ./: file{input}: test.stdin = true + ./: file{output}: test.stdout = true + EOI + %cat .+/input \| .+/driver.* - \| diff -u .+% + %.+ + -3.4.5 + %error: test .+dir\{.+\} failed% + error: process diff exited with code 1 + % info: while testing .+dir\{.+\}% + %info: failed to test .+dir\{.+\}% + EOE + } + + : input-not-found + : + { + echo '1.2.3' >=input; + echo '3.4.5' >=output; + $* -q <>/~%EOE% != 0 + driver = $src_root/../exe{driver} + ./: test = $driver + ./: $driver + ./: test.arguments = 'foo' + ./: file{input}: test.stdin = true + ./: file{output}: test.stdout = true + EOI + unable to open foo + error: test dir{./} failed + % error: process .+/driver.* exited with code 1% + EOE + } +} + : timeout : { @@ -59,25 +176,30 @@ EOI ./: $driver EOI error: test dir{./} failed - % error: .+ -s terminated: execution timeout expired% - % info: test command line: .+% + % error: process .+driver.* terminated: execution timeout expired% EOE - : output + : stdin-stdout : + ln -s $src_base/input.in ./; ln -s $src_base/output.in ./; - $* config.test.timeout=1 &output &output.d <>/~%EOE% != 0 + $* config.test.timeout=1 --verbose 1 &input &input.d &output &output.d <>/~%EOE% != 0 driver = $src_root/../exe{driver} ./: test = $driver ./: test.options = -s ./: $driver + ./: file{input}: test.stdin = true ./: file{output}: test.stdout = true + file{input}: in{input} $src_root/manifest #@@ in module file{output}: in{output} $src_root/manifest #@@ in module EOI + %version\.in in\{.+\}%{2} + test dir{./} error: test dir{./} failed - % error: diff .+ terminated: execution timeout expired% - % error: .+ -s terminated: execution timeout expired% - % info: test command line: .+% + % error: process .+driver.* terminated: execution timeout expired% + % info: test command line: cat .+/input \| .+driver.* -s \| diff -u .+% + info: while testing dir{./} + info: failed to test dir{./} EOE } @@ -94,8 +216,7 @@ EOI ./: $driver EOI error: test dir{./} failed - % error: .+ -s terminated: execution timeout expired% - % info: test command line: .+% + % error: process .+driver.* terminated: execution timeout expired% EOE } } -- cgit v1.1