# file : tests/test/script/runner/redirect.testscript # copyright : Copyright (c) 2014-2019 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file .include ../common.testscript b += --no-column ps = ($cxx.target.class != 'windows' ? '/' : '\') # Path separator. psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. : pass : { cat <'$* -i 1 -e bar <| >| 2>|' >=testscript; cat <=buildfile; testscript{testscript}: $target EOI $0 --serial-stop --quiet test foo 2>bar } : null : { $c <'$* -o foo >-' && $b : out $c <'$* -e foo 2>-' && $b : err } : trace : { : default : $c <'$* -o foo -e bar >! 2>!' && $b : verbose : { b += -v : out : $c <'$* -o foo >!' && $b >foo 2>>/~%EOE% %test .+% mkdir test/ touch test/.buildignore cd test/ mkdir test/1/ cd test/1/ %.*/driver(.exe)? -o foo% rmdir test/1/ cd test/ rm test/.buildignore rmdir test/ cd ./ EOE : err : $c <'$* -e foo 2>!' && $b 2>>/~%EOE% %test .+% mkdir test/ touch test/.buildignore cd test/ mkdir test/1/ cd test/1/ %.*/driver(.exe)? -e foo% foo rmdir test/1/ cd test/ rm test/.buildignore rmdir test/ cd ./ EOE } } : str : { : literal : { $c <'$* -i 0 foo' && $b : out $c <'$* -e foo 2>foo' && $b : err $c <'$* -i 1 foo' && $b : inout : inout-fail : $c <'$* -i 1 bar' && $b 2>>/~%EOE%d != 0 %testscript:1: error: ../../../../../driver(.exe)? stdout doesn't match expected% info: stdout: test/1/stdout info: expected stdout: test/1/stdout.orig info: stdout diff: test/1/stdout.diff info: stdin: test/1/stdin %--- \.*% %\+\+\+ \.*% %@@ \.*% -bar +foo info: test id: 1 EOE $c <'$* -i 2 foo' && $b : inerr $c <'$* -i 1 -e bar foo 2>bar' && $b : inout-err $c <'$* -o "" >""' && $b : empty $c <'$* -i 1 <:"foo" >:"foo"' && $b : no-newline $c <'$* -i 1 <:"" >:""' && $b : no-newline-empty : no-newline-fail1 : $c <'$* -i 1 <:"foo" >"foo"' && $b 2>>~/EOE/ != 0 /testscript:1: error: .+driver(\.exe)? stdout doesn't match expected/ /.{7} -foo +foo \ No newline at end of file info: test id: 1 EOE : no-newline-fail2 : $c <'$* -i 1 <"foo" >:"foo"' && $b 2>>~/EOE/ != 0 /testscript:1: error: .+driver(\.exe)? stdout doesn't match expected/ /.{7} -foo \ No newline at end of file +foo info: test id: 1 EOE : merge : $c <>EOE 1>&2 foo bar EOE EOI : portable-path : { $c <"\$* -i 1 'foo$ps'" && $b : in $c <"\$* -i 1 <'foo$ps' >/'foo/'" && $b : out $c <"\$* -i 2 <'foo$ps' 2>/'foo/'" && $b : err } } : regex : : Test regex matching. Note that tests that check regex parsing are located : in regex.testscript. : { : match : $c <'$* -o foo >~/Foo?/i' && $b : mismatch : $c <'$* -o fooo >~/Foo?/i' && $b 2>>/~%EOE%d != 0 %testscript:1: error: ../../../../../driver(.exe)? stdout doesn't match regex% info: stdout: test/1/stdout info: stdout regex: test/1/stdout.regex fooo info: test id: 1 EOE : portable-path-failure : : Note that we check not only build2 diagnostics being produced, but also : the correctness of regex being saved to file (for troubleshooting). : { : newline : $c <"\$* -i 1 <'foo' >/~%bar/%" && $b 2>>/~%EOE%d != 0; %testscript:1: error: ../../../../../../driver(.exe)? stdout doesn't match regex% info: stdout: test/1/stdout info: stdout regex: test/1/stdout.regex info: stdin: test/1/stdin foo info: test id: 1 EOE cat test/1/stdout.regex >"%bar$psr%" : no-newline : $c <"\$* -i 1 <'foo' >:/~%bar/%" && $b 2>>/~%EOE%d != 0; %testscript:1: error: ../../../../../../driver(.exe)? stdout doesn't match regex% info: stdout: test/1/stdout info: stdout regex: test/1/stdout.regex info: stdin: test/1/stdin foo info: test id: 1 EOE cat test/1/stdout.regex >:"%bar$psr%" } } } : doc : { : literal : { : in : $c <>EOO foo bar EOO EOI : err : $c <>EOO foo bar EOO EOI : inout : $c <>EOO foo bar EOF foo bar EOO EOI : inerr : $c <>EOE foo bar EOF foo bar EOE EOI : empty : $c <>EOO EOF EOO EOI : shared : $c <>EOF foo bar EOF EOI : extra-newline : $c <>EOO EOF EOO EOI : no-newline : $c <>:EOO foo EOF foo EOO EOI : no-newline-fail1 : $c <>~/EOE/ != 0 $* -i 1 <<:EOF >>EOO foo EOF foo EOO EOI /testscript:1: error: .+driver(\.exe)? stdout doesn't match expected/ /.{7} -foo +foo \ No newline at end of file info: test id: 1 EOE : no-newline-fail2 : $c <>~/EOE/ != 0 $* -i 1 <>:EOO foo EOF foo EOO EOI /testscript:1: error: .+driver(\.exe)? stdout doesn't match expected/ /.{7} -foo \ No newline at end of file +foo info: test id: 1 EOE : no-newline-empty : $c <>:EOO EOF EOO EOI : no-newline-extra-newline : $c <>:EOO EOF EOO EOI : merge : $c <>EOO 2>&1 foo bar EOF foo bar baz EOO EOI : large-diff : : Make sure that the large (>4KB) expected/real output difference is not : printed as a part of the diagnostics. : $c <>/~%EOE%d != 0 s="----------------------------------------------------------------------"; s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s"; $* -i 1 <<"EOF" >>"EOO" $s EOF x$s EOO EOI %testscript:3: error: ../../../../../driver(.exe)? stdout doesn't match expected% info: stdout: test/1/stdout info: expected stdout: test/1/stdout.orig info: stdout diff: test/1/stdout.diff info: stdin: test/1/stdin info: test id: 1 EOE : portable-path : { : in : $c <<"EOI" && $b \$* -i 1 <'foo$ps' foo/ EOF EOI : out : $c <<"EOI" && $b \$* -i 1 <'foo$ps' >>/EOO foo/ EOO EOI : err : $c <<"EOI" && $b \$* -i 2 <'foo$ps' 2>>/EOE foo/ EOE EOI } } : regex : : Test regex matching. Note that tests that check regex parsing are located : in regex.testscript. : { : match : $c <>~/EOO/i /FO*/* bar /* EOO EOI : match-empty : $c <>:~/EOO/ /.{0} EOO EOI : shared : $c <>~/EOF/ 2>>~/EOF/ foo EOF EOI : mismatch : $c <>/~%EOE%d != 0 $* -o foo >>~/EOO/ bar EOO EOI %testscript:1: error: ../../../../../driver(.exe)? stdout doesn't match regex% info: stdout: test/1/stdout info: stdout regex: test/1/stdout.regex foo info: test id: 1 EOE : mismatch-icase : $c <>/~%EOE%d != 0 $* -o foo >>~/EOO/i bar EOO EOI %testscript:1: error: ../../../../../driver(.exe)? stdout doesn't match regex% info: stdout: test/1/stdout info: stdout regex: test/1/stdout.regex-i foo info: test id: 1 EOE } } : file : { : in : $c <=out; $* -i 1 <<foo EOI : out : { : match : $c <=out; $* -e bar 2>+out; $* -i 1 <>>out foo bar EOF EOI : mismatch : $c <>/~%EOE%d != 0 $* -o foo >=out; $* -o bar >>>out EOI %testscript:2: error: ../../../../../driver(.exe)? stdout doesn't match expected% info: stdout: test/1/stdout-2 info: expected stdout: test/1/out info: stdout diff: test/1/stdout-2.diff %--- \.*% %\+\+\+ \.*% %@@ \.*% -foo +bar info: test id: 1 EOE } : merge : $c <&1 >=out; $* -e baz -o biz 1>&2 2>+out; $* -i 1 <<>EOO foo bar baz biz EOO EOI }