+2011-08-22 Stefano Lattarini <stefano.lattarini@gmail.com>
+
+ tap/awk: handle non-zero exit status from the test command
+ * lib/tap-driver.sh (get_test_exit_message): New function in the
+ awk script, used to extract the exit status of the test program,
+ or at least a good guess of it.
+ (write_test_results): Use it, reporting an ERROR result if it
+ detects that the test program exited with a non-zero status.
+ * tests/tap-signal.test: Account for the differences in the
+ error messages generated by the awk and perl TAP drivers. Fix
+ an unrelated typo in comments since we are at it.
+
2011-08-22 Stefano Lattarini <stefano.lattarini@gmail.com>
tap/awk: prepare to fetch the exit status of the test command
result_obj["explanation"] = line
}
+function get_test_exit_message(status)
+{
+ if (status == 0)
+ return ""
+ if (status !~ /^[1-9][0-9]*$/)
+ abort("getting exit status")
+ if (status < 127)
+ exit_details = ""
+ else if (status == 127)
+ exit_details = " (command not found?)"
+ else if (status >= 128 && status <= 255)
+ exit_details = sprintf(" (terminated by signal %d?)", status - 128)
+ else if (status >= 256)
+ exit_details = " (abnormal termination)"
+ return sprintf("exited with status %d%s", status, exit_details)
+}
+
function write_test_results()
{
print ":global-test-result: " get_global_test_result() > trs_file
testsuite_error(sprintf("too %s tests run (expected %d, got %d)",
bad_amount, planned_tests, testno))
}
+ if (!ignore_exit)
+ {
+ # Fetch exit status from the last line.
+ exit_message = get_test_exit_message(nextline)
+ if (exit_message)
+ testsuite_error(exit_message)
+ }
}
write_test_results()
numeric=$1
symbolic=$2
sig_re="((SIG)?$symbolic|$numeric)"
- tst_re="signal-$numeric\\.test"
- if $EGREP "^ERROR: $tst_re - terminated by signal $sig_re$" stdout; then
+ wbound_re="($|[^a-zA-Z0-9_-])"
+ pfx_re="^ERROR: signal-$numeric\\.test"
+ case $am_tap_implementation in
+ perl) rx="$pfx_re - terminated by signal $sig_re$";;
+ shell) rx="$pfx_re .*terminated by signal $sig_re$wbound_re";;
+ *) fatal_ "invalid \$am_tap_implementation '$am_tap_implementation'";;
+ esac
+ if LC_ALL=C $EGREP "$rx" stdout; then
return 0
elif test $have_solaris_bug = yes; then
case $symbolic in
- INT|TERM) $EGREP "^ERROR: $tst_re - exited with status 208$" stdout;;
- *) return 1;;
+ INT|TERM)
+ $EGREP "$pfx_re - exited with status 208( |$)" stdout;;
esac
- else
- return 1
fi
+ return 1
}
all_signals_caught ()
{
- # This are the only signals that are portably trappable.
+ # These are the only signals that are portably trappable.
signal_caught 1 HUP
signal_caught 2 INT
signal_caught 13 PIPE