automake-commit
[Top][All Lists]
Advanced

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

[Automake-commit] [SCM] GNU Automake branch, test-protocols, updated. v1


From: Stefano Lattarini
Subject: [Automake-commit] [SCM] GNU Automake branch, test-protocols, updated. v1.11-1052-gd630a0d
Date: Mon, 22 Aug 2011 13:33:40 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Automake".

http://git.sv.gnu.org/gitweb/?p=automake.git;a=commitdiff;h=d630a0d4dc7c1af141ab3c61458cdbc690dac88c

The branch, test-protocols has been updated
       via  d630a0d4dc7c1af141ab3c61458cdbc690dac88c (commit)
       via  5116cc978798cedd7a522d3fdd3140efde9933b3 (commit)
       via  48b98a63bd53c93a64f43cbcd8ca93f541c7d5ee (commit)
      from  8a4e2afa54cbc1f148d899bd5cea6a2ada39d2e9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit d630a0d4dc7c1af141ab3c61458cdbc690dac88c
Author: Stefano Lattarini <address@hidden>
Date:   Mon Aug 22 15:00:09 2011 +0200

    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.

commit 5116cc978798cedd7a522d3fdd3140efde9933b3
Author: Stefano Lattarini <address@hidden>
Date:   Mon Aug 22 12:14:32 2011 +0200

    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.

commit 48b98a63bd53c93a64f43cbcd8ca93f541c7d5ee
Author: Stefano Lattarini <address@hidden>
Date:   Mon Aug 22 12:00:05 2011 +0200

    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
    BEGIN block, using the `getline' builtin.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog             |   26 +++++
 lib/tap-driver.sh     |  251 ++++++++++++++++++++++++++++---------------------
 tests/tap-signal.test |   19 +++--
 3 files changed, 183 insertions(+), 113 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1dec4b3..db6a46b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,31 @@
 2011-08-22  Stefano Lattarini  <address@hidden>
 
+       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  <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
+       BEGIN block, using the `getline' builtin.
+
+2011-08-22  Stefano Lattarini  <address@hidden>
+
        testsuite: avoid spurious failure if rst2html program is missing
        * tests/tap-html.test ($required): Require `rst2html'.
 
diff --git a/lib/tap-driver.sh b/lib/tap-driver.sh
index ac87b9e..1255662 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" \
@@ -416,6 +416,23 @@ function setup_result_obj(line)
   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
@@ -426,131 +443,153 @@ function write_test_results()
   close(trs_file);
 }
 
+BEGIN {
+
 ## ------- ##
 ##  SETUP  ##
 ## ------- ##
 
-BEGIN {
-
-  '"$init_colors"'
+'"$init_colors"'
 
-  # Properly initialized once the TAP plan is seen.
-  planned_tests = 0
+# Properly initialized once the TAP plan is seen.
+planned_tests = 0
 
-  COOKED_PASS = expect_failure ? "XPASS": "PASS";
-  COOKED_FAIL = expect_failure ? "XFAIL": "FAIL";
+COOKED_PASS = expect_failure ? "XPASS": "PASS";
+COOKED_FAIL = expect_failure ? "XFAIL": "FAIL";
 
-  # Enumeration-like constants to remember which kind of plan (if any)
-  # has been seen.  It is important that NO_PLAN evaluates "false" as
-  # a boolean.
-  NO_PLAN = 0
-  EARLY_PLAN = 1
-  LATE_PLAN = 2
+# Enumeration-like constants to remember which kind of plan (if any)
+# has been seen.  It is important that NO_PLAN evaluates "false" as
+# a boolean.
+NO_PLAN = 0
+EARLY_PLAN = 1
+LATE_PLAN = 2
 
-  testno = 0     # Number of test results seen so far.
-  bailed_out = 0 # Whether a "Bail out!" directive has been seen.
+testno = 0     # Number of test results seen so far.
+bailed_out = 0 # Whether a "Bail out!" directive has been seen.
 
-  # Whether the TAP plan has been seen or not, and if yes, which kind
-  # it is ("early" is seen before any test result, "late" otherwise).
-  plan_seen = NO_PLAN
-
-}
+# Whether the TAP plan has been seen or not, and if yes, which kind
+# it is ("early" is seen before any test result, "late" otherwise).
+plan_seen = NO_PLAN
 
 ## --------- ##
 ##  PARSING  ##
 ## --------- ##
 
-{
-  # Copy any input line verbatim into the log file.
-  print
-  # Parsing of TAP input should stop after a "Bail out!" directive.
-  if (bailed_out)
-    next
-}
-
-# TAP test result.
-($0 ~ /^(not )?ok$/ || $0 ~ /^(not )?ok[^a-zA-Z0-9_]/) {
-
-  testno += 1
-  setup_result_obj($0)
-  handle_tap_result()
-  next
-
-}
-
-# TAP plan (normal or "SKIP" without explanation).
-/^1\.\.[0-9]+[ \t]*$/ {
-
-  # The next two lines will put the number of planned tests in $0.
-  sub("^1\\.\\.", "")
-  sub("[^0-9]*$", "")
-  handle_tap_plan($0, "")
-  next
-
-}
-
-# TAP "SKIP" plan, with an explanation.
-/^1\.\.0+[ \t]*#/ {
-
-  # The next lines will put the skip explanation in $0, stripping any
-  # leading and trailing whitespace.  This is a little more tricky in
-  # thruth, since we want to also strip a potential leading "SKIP"
-  # string from the message.
-  sub("^[^#]*#[ \t]*(SKIP[: \t][ \t]*)?", "")
-  sub("[ \t]*$", "");
-  handle_tap_plan(0, $0)
-  next
-
-}
-
-# "Bail out!" magic.
-/^Bail out!/ {
-
-  bailed_out = 1
-  # Get the bailout message (if any), with leading and trailing
-  # whitespace stripped.  The message remains stored in `$0`.
-  sub("^Bail out![ \t]*", "");
-  sub("[ \t]*$", "");
-  # Format the error message for the
-  bailout_message = "Bail out!"
-  if (length($0))
-    bailout_message = bailout_message " " $0
-  testsuite_error(bailout_message)
-  next
-
-}
-
-(comments != 0) {
-
-  comment = extract_tap_comment($0);
-  if (length(comment))
-    report("#", comment);
-
-}
+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) # 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.
+    if (bailed_out)
+      continue
+
+    # TAP test result.
+    if ($0 ~ /^(not )?ok$/ || $0 ~ /^(not )?ok[^a-zA-Z0-9_]/)
+      {
+        testno += 1
+        setup_result_obj($0)
+        handle_tap_result()
+      }
+    # TAP plan (normal or "SKIP" without explanation).
+    else if ($0 ~ /^1\.\.[0-9]+[ \t]*$/)
+      {
+        # The next two lines will put the number of planned tests in $0.
+        sub("^1\\.\\.", "")
+        sub("[^0-9]*$", "")
+        handle_tap_plan($0, "")
+        continue
+      }
+    # TAP "SKIP" plan, with an explanation.
+    else if ($0 ~ /^1\.\.0+[ \t]*#/)
+      {
+        # The next lines will put the skip explanation in $0, stripping
+        # any leading and trailing whitespace.  This is a little more
+        # tricky in truth, since we want to also strip a potential leading
+        # "SKIP" string from the message.
+        sub("^[^#]*#[ \t]*(SKIP[: \t][ \t]*)?", "")
+        sub("[ \t]*$", "");
+        handle_tap_plan(0, $0)
+      }
+    # "Bail out!" magic.
+    else if ($0 ~ /^Bail out!/)
+      {
+        bailed_out = 1
+        # Get the bailout message (if any), with leading and trailing
+        # whitespace stripped.  The message remains stored in `$0`.
+        sub("^Bail out![ \t]*", "");
+        sub("[ \t]*$", "");
+        # Format the error message for the
+        bailout_message = "Bail out!"
+        if (length($0))
+          bailout_message = bailout_message " " $0
+        testsuite_error(bailout_message)
+      }
+    # Maybe we have too look for dianogtic comments too.
+    else if (comments != 0)
+      {
+        comment = extract_tap_comment($0);
+        if (length(comment))
+          report("#", comment);
+      }
+  }
 
 ## -------- ##
 ##  FINISH  ##
 ## -------- ##
 
-END {
-
-  # A "Bail out!" directive should cause us to ignore any following TAP
-  # error, as well as a non-zero exit status from the TAP producer.
-  if (!bailed_out)
-    {
-      if (!plan_seen)
+# A "Bail out!" directive should cause us to ignore any following TAP
+# error, as well as a non-zero exit status from the TAP producer.
+if (!bailed_out)
+  {
+    if (!plan_seen)
+      {
         testsuite_error("missing test plan")
-      else if (planned_tests != testno)
-        {
-          bad_amount = testno > planned_tests ? "many" : "few"
-          testsuite_error(sprintf("too %s tests run (expected %d, got %d)",
-                                  bad_amount, planned_tests, testno))
-        }
-    }
-  write_test_results()
-
-  exit 0
-}
+      }
+    else if (planned_tests != testno)
+      {
+        bad_amount = testno > planned_tests ? "many" : "few"
+        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()
+
+exit 0
+
+} # End of "BEGIN" block.
 '
 
 # TODO: document that we consume the file descriptor 3 :-(
diff --git a/tests/tap-signal.test b/tests/tap-signal.test
index 8ceeddd..416422e 100755
--- a/tests/tap-signal.test
+++ b/tests/tap-signal.test
@@ -55,22 +55,27 @@ signal_caught ()
   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


hooks/post-receive
-- 
GNU Automake



reply via email to

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