2011-08-22 Stefano Lattarini <stefano.lattarini@gmail.com>
+ tap/awk: prepare to fetch the exit status of the test command
+ * lib/tap-driver.sh: Rewrite some logic in the main parsing loop,
+ to make it possible to read the exit status of the test command
+ from the last line of the input stream.
+
+2011-08-22 Stefano Lattarini <stefano.lattarini@gmail.com>
+
tap/awk: refactor for future changes
* lib/tap-driver.sh: Rewrite the awk script so that the parsing
of the input stream is implemented as a hand-rolled loop in the
# expression | getline [var]
# idiom, which should allow us to obtain the final exit status from
# <expression> when closing it.
- { test $merge -eq 0 || exec 2>&1; "$@"; } \
+ { test $merge -eq 0 || exec 2>&1; "$@"; echo $?; } \
| LC_ALL=C ${AM_TAP_AWK-awk} \
-v me="$me" \
-v test_script_name="$test_name" \
## PARSING ##
## --------- ##
+is_first_read = 1
+
while (1)
{
+ # Involutions required so that we are able to read the exit status
+ # from the last input line.
st = getline
- if (st == 0) # End-of-input
- break
- else if (st < 0) # I/O error.
+ if (st < 0) # I/O error.
fatal("I/O error while reading from input stream")
+ else if (st == 0) # End-of-input
+ {
+ if (is_first_read)
+ abort("in input loop: only one input line")
+ break
+ }
+ if (is_first_read)
+ {
+ is_first_read = 0
+ nextline = $0
+ continue
+ }
+ else
+ {
+ curline = nextline
+ nextline = $0
+ $0 = curline
+ }
# Copy any input line verbatim into the log file.
print
# Parsing of TAP input should stop after a "Bail out!" directive.