# file : tests/test/script/runner/redirect.test # copyright : Copyright (c) 2014-2017 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file .include ../common.test b += --no-column ps = ($cxx.target.class != 'windows' ? '/' : '\') # Path separator. psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. : null : { : out : $c <'$* -o foo >-'; $b : err : $c <'$* -e foo 2>-'; $b } : str : { : literal : { : in : $c <'$* -i 0 foo'; $b : err : $c <'$* -e foo 2>foo'; $b : inout : $c <'$* -i 1 foo'; $b : inout-fail : $c <'$* -i 1 bar'; $b 2>>/~%EOE%d != 0 %testscript:1: error: ../../../../../driver(.exe)? stdout doesn't match the expected output% 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 EOE : inerr : $c <'$* -i 2 foo'; $b : inout-err : $c <'$* -i 1 -e bar foo 2>bar'; $b : empty : $c <'$* -o "" >""'; $b : no-newline : $c <'$* -i 1 <:"foo" >:"foo"'; $b : no-newline-empty : $c <'$* -i 1 <:"" >:""'; $b : no-newline-fail1 : $c <'$* -i 1 <:"foo" >"foo"'; $b 2>>~/EOE/ != 0 /testscript:1: error: .+driver(\.exe)? stdout doesn't match the expected output/ /.{7} -foo +foo \ No newline at end of file EOE : no-newline-fail2 : $c <'$* -i 1 <"foo" >:"foo"'; $b 2>>~/EOE/ != 0 /testscript:1: error: .+driver(\.exe)? stdout doesn't match the expected output/ /.{7} -foo \ No newline at end of file +foo EOE : merge : $c <>EOE 1>&2 foo bar EOE EOI $b : portable-path : { : in : $c <"\$* -i 1 'foo$ps'"; $b : out : $c <"\$* -i 1 <'foo$ps' >/'foo/'"; $b : err : $c <"\$* -i 2 <'foo$ps' 2>/'foo/'"; $b } } : regex : : Test regex matching. Note that tests that check regex parsing are located : in regex.test 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 the regex% info: stdout: test/1/stdout info: stdout regex: test/1/stdout.regex 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 the regex% info: stdout: test/1/stdout info: stdout regex: test/1/stdout.regex info: stdin: test/1/stdin 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 the regex% info: stdout: test/1/stdout info: stdout regex: test/1/stdout.regex info: stdin: test/1/stdin EOE cat test/1/stdout.regex >:"%bar$psr%" } } } : doc : { : literal : { : in : $c <>EOO foo bar EOO EOI $b : err : $c <>EOO foo bar EOO EOI $b : inout : $c <>EOO foo bar EOF foo bar EOO EOI $b : inerr : $c <>EOE foo bar EOF foo bar EOE EOI $b : empty : $c <>EOO EOF EOO EOI $b : extra-newline : $c <>EOO EOF EOO EOI $b : no-newline : $c <>:EOO foo EOF foo EOO EOI $b : no-newline-fail1 : $c <>EOO foo EOF foo EOO EOI $b 2>>~/EOE/ != 0 /testscript:1: error: .+driver(\.exe)? stdout doesn't match the expected output/ /.{7} -foo +foo \ No newline at end of file EOE : no-newline-fail2 : $c <>:EOO foo EOF foo EOO EOI $b 2>>~/EOE/ != 0 /testscript:1: error: .+driver(\.exe)? stdout doesn't match the expected output/ /.{7} -foo \ No newline at end of file +foo EOE : no-newline-empty : $c <>:EOO EOF EOO EOI $b : no-newline-extra-newline : $c <>:EOO EOF EOO EOI $b : merge : $c <>EOO 2>&1 foo bar EOF foo bar baz EOO EOI $b : large-diff : : Make sure that the large (>4KB) expected/real output difference is not : printed as a part of the diagnostics. : $c <>"EOO" $s EOF x$s EOO EOI $b 2>>/~%EOE%d != 0 %testscript:3: error: ../../../../../driver(.exe)? stdout doesn't match the expected output% info: stdout: test/1/stdout info: expected stdout: test/1/stdout.orig info: stdout diff: test/1/stdout.diff info: stdin: test/1/stdin EOE : portable-path : { : in : $c <<"EOI"; \$* -i 1 <'foo$ps' foo/ EOF EOI $b : out : $c <<"EOI"; \$* -i 1 <'foo$ps' >>/EOO foo/ EOO EOI $b : err : $c <<"EOI"; \$* -i 2 <'foo$ps' 2>>/EOE foo/ EOE EOI $b } } : regex : : Test regex matching. Note that tests that check regex parsing are located : in regex.test testscript. : { : match : $c <>~/EOO/i /FO*/* bar /* EOO EOI $b : match-empty : $c <>:~/EOO/ /.{0} EOO EOI $b : mismatch : $c <>~/EOO/ bar EOO EOI $b 2>>/~%EOE%d != 0 %testscript:1: error: ../../../../../driver(.exe)? stdout doesn't match the regex% info: stdout: test/1/stdout info: stdout regex: test/1/stdout.regex EOE : mismatch-icase : $c <>~/EOO/i bar EOO EOI $b 2>>/~%EOE%d != 0 %testscript:1: error: ../../../../../driver(.exe)? stdout doesn't match the regex% info: stdout: test/1/stdout info: stdout regex: test/1/stdout.regex~i EOE } } : file : { : in-out : $c <>>out; $* -i 1 <<foo EOI $b : append : $c <>>out; $* -e bar 2>>>&out; $* -i 1 <<>EOO foo bar EOO EOI $b : merge : $c <&1 >>>out; $* -e baz -o biz 1>&2 2>>>&out; $* -i 1 <<>EOO foo bar baz biz EOO EOI $b } # @@ That will probably become redundant when builtins and process obtain file # descriptors uniformly. # : builtins : { : out-null : $c <'echo "abc" >-'; $b : err-null : $c <'echo "abc" 1>&2 2>-'; $b : in-str : $c <'echo -'; $b : out-str : $c <'echo "foo" >foo'; $b : err-str : $c <'echo "foo" 2>foo 1>&2'; $b : inout-str : $c <'cat foo'; $b : inerr-str : $c <'cat foo 1>&2'; $b }