]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
tap/awk: prepare to fetch the exit status of the test command
authorStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 22 Aug 2011 10:14:32 +0000 (12:14 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 22 Aug 2011 12:31:19 +0000 (14:31 +0200)
* 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.

ChangeLog
lib/tap-driver.sh

index e536ff6dd4c911f9caba299a616be51df075b3c5..5f17e99a0157a3d3d79eccf4aa4a984bc4fc4542 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+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
index 34da1813f53de369e76ffabbabcdf6bbda9e9082..09fcaee0f7ee6962e2b61c58d1bba03bd1b249e2 100755 (executable)
@@ -121,7 +121,7 @@ fi
   #   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" \
@@ -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.