From: Stefano Lattarini Date: Mon, 22 Aug 2011 10:14:32 +0000 (+0200) Subject: tap/awk: prepare to fetch the exit status of the test command X-Git-Tag: ng-0.5a~89^2~97^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5116cc978798cedd7a522d3fdd3140efde9933b3;p=thirdparty%2Fautomake.git 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. --- diff --git a/ChangeLog b/ChangeLog index e536ff6dd..5f17e99a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-08-22 Stefano Lattarini + + 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 tap/awk: refactor for future changes diff --git a/lib/tap-driver.sh b/lib/tap-driver.sh index 34da1813f..09fcaee0f 100755 --- a/lib/tap-driver.sh +++ b/lib/tap-driver.sh @@ -121,7 +121,7 @@ fi # expression | getline [var] # idiom, which should allow us to obtain the final exit status from # 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" \ @@ -458,13 +458,33 @@ plan_seen = NO_PLAN ## 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.