automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[FYI 2/3] {test-protocols} tap/awk: prepare to fetch the exit status of


From: Stefano Lattarini
Subject: [FYI 2/3] {test-protocols} tap/awk: prepare to fetch the exit status of the test command
Date: Mon, 22 Aug 2011 15:33:07 +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         |    7 +++++++
 lib/tap-driver.sh |   28 ++++++++++++++++++++++++----
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e536ff6..5f17e99 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2011-08-22  Stefano Lattarini  <address@hidden>
 
+       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  <address@hidden>
+
        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
diff --git a/lib/tap-driver.sh b/lib/tap-driver.sh
index 34da181..09fcaee 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
   # <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.
-- 
1.7.2.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]