# file : tests/test/script/runner/redirect.test # copyright : Copyright (c) 2014-2016 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file .include ../common.test b += --no-column # null-redirect tests. # : out-null : $c <'$* -o foo >-'; $b : err-null : $c <'$* -e foo 2>-'; $b # Here-string tests. # : in-str : $c <'$* -i 0 foo'; $b : err-str : $c <'$* -e foo 2>foo'; $b : inout-str : $c <'$* -i 1 foo'; $b : inout-str-fail : $c <'$* -i 1 bar'; $b 2>>~%EOE% != 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-str : $c <'$* -i 2 foo'; $b : inout-err-str : $c <'$* -i 1 -e bar foo 2>bar'; $b # Here-document tests. # : in-doc : $c <>EOO foo bar EOO EOI $b : err-doc : $c <>EOO foo bar EOO EOI $b : inout-doc : $c <>EOO foo bar EOF foo bar EOO EOI $b : inerr-doc : $c <>EOE foo bar EOF foo bar EOE EOI $b : empty-str-doc : $c <>EOO 2>"" EOF EOO EOI $b : nl-containing-doc : $c <>EOO EOF EOO EOI $b : doc-fail-largediff : : Make sure that the large (>4KB) expected/real output difference is not : printed as a part of diagnostics. : $c <>"EOO" $s EOF x$s EOO EOI $b 2>>~%EOE% != 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 # No-newline tests. # : no-newline-str : $c <'$* -i 1 <:"foo" >:"foo"'; $b : no-newline-empty-str : $c <'$* -i 1 <:"" >:""'; $b : no-newline-str-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-str-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 : no-newline-doc : $c <>:EOO foo EOF foo EOO EOI $b : no-newline-doc-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-doc-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-str-doc : $c <>:EOO 2>:"" EOF EOO EOI $b : no-newline-nl-cont-doc : $c <>:EOO EOF EOO EOI $b # Merge tests. # : merge-str : $c <>EOE 1>&2 foo bar EOE EOI $b : merge-doc : $c <>EOO 2>&1 foo bar EOF foo bar baz EOO EOI $b # File tests. # : file : $c <>>out; $* -e bar 2>>>&out; $* -i 1 <<>EOO foo bar EOO EOI $b : merge-file : $c <&1 >>>out; $* -e baz -o biz 1>&2 2>>>&out; $* -i 1 <<>EOO foo bar baz biz EOO EOI $b # Regex tests. # : out-str-regex : { : match : $c <'$* -o foo >~/Foo?/i'; $b : fail : $c <'$* -o fooo >~/Foo?/i'; $b 2>>~%EOE% != 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 } : out-doc-regex : { : match : $c <>~/EOO/i /FO*/* bar /* EOO EOI $b : match-empty : $c <>:~/EOO/i /.{0} EOO EOI $b } # Builtins redirects. # # @@ 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 }