diff --git a/xargs/testsuite/config/unix.exp b/xargs/testsuite/config/unix.exp index 8f562ae3..10ca690c 100644 --- a/xargs/testsuite/config/unix.exp +++ b/xargs/testsuite/config/unix.exp @@ -72,15 +72,16 @@ proc xargs_start { passfail options {infile ""}} { set testname [file tail $testbase] set outfile "$testbase.xo" + set errfile "$testbase.xe" if {$infile != ""} then { set infile "[file dirname [file dirname $testbase]]/inputs/$infile" } else { set infile /dev/null } - catch "exec rm -f xargs.out" + catch "exec rm -f xargs.out xargs.err" - set cmd "$XARGS $XARGSFLAGS $options < $infile > xargs.out" + set cmd "$XARGS $XARGSFLAGS $options < $infile > xargs.out 2> xargs.err" send_log "$cmd\n" if $verbose>1 then { send_user "Spawning \"$cmd\"\n" @@ -88,29 +89,52 @@ proc xargs_start { passfail options {infile ""}} { catch "exec $cmd" comp_output if {$comp_output != ""} then { + # The command failed; if that was the desired effect, the + # test might still pass send_log "$comp_output\n" if $verbose>1 then { send_user "$comp_output\n" } if $fail_good then { + # expected failure pass "$testname" } else { + # unexpected failure fail "$testname, $comp_output" } return } + # The command succeeded, but that might not have been the expected result. if [file exists $outfile] then { set cmp_cmd "cmp xargs.out $outfile" send_log "$cmp_cmd\n" catch "exec $cmp_cmd" cmpout if {$cmpout != ""} then { - fail "$testname, $cmpout" + # stdout is wrong. + fail "$testname, wrong stdout output: $cmpout" return } } else { if {[file size xargs.out] != 0} then { - fail "$testname, output should be empty" + fail "$testname, output on stdout should be empty" + return + } + } + + # If testname.xe exists, check the stderr result. + if [file exists $errfile] then { + set cmp_cmd "cmp xargs.err $errfile" + send_log "$cmp_cmd\n" + catch "exec $cmp_cmd" cmperr + if {$cmperr != ""} then { + # stderr is wrong. + fail "$testname, wrong stderr output: $cmperr" + return + } + } else { + if {[file size xargs.err] != 0} then { + fail "$testname, output on stderr should be empty" return } } @@ -120,5 +144,7 @@ proc xargs_start { passfail options {infile ""}} { # Called by runtest. # Clean up (remove temporary files) before runtest exits. proc xargs_exit {} { - catch "exec rm -f xargs.out" + catch "exec rm -f xargs.out xargs.err" } + + diff --git a/xargs/testsuite/inputs/foobar.xi b/xargs/testsuite/inputs/foobar.xi new file mode 100644 index 00000000..e10988cb --- /dev/null +++ b/xargs/testsuite/inputs/foobar.xi @@ -0,0 +1,3 @@ +foo bar +baz +ugh diff --git a/xargs/testsuite/xargs.gnu/r.exp b/xargs/testsuite/xargs.gnu/r.exp index 8de762fd..448055dc 100644 --- a/xargs/testsuite/xargs.gnu/r.exp +++ b/xargs/testsuite/xargs.gnu/r.exp @@ -1 +1 @@ -xargs_start p {-r echo this plus that} {} +xargs_start p {-r echo this plus that} blank.xi diff --git a/xargs/testsuite/xargs.gnu/r.xo b/xargs/testsuite/xargs.gnu/r.xo new file mode 100644 index 00000000..e69de29b diff --git a/xargs/xargs.1 b/xargs/xargs.1 index e2002c1a..1e4f7861 100644 --- a/xargs/xargs.1 +++ b/xargs/xargs.1 @@ -109,6 +109,7 @@ with `y' or `Y'. Implies \fI\-t\fR. .I "\-\-no\-run\-if\-empty, \-r" If the standard input does not contain any nonblanks, do not run the command. Normally, the command is run once even if there is no input. +This option is a GNU extension. .TP .I "\-\-max\-chars=max-chars, \-s max-chars" Use at most \fImax-chars\fR characters per command line, including the