tests: avoid a spurious failure on MSYS
[platform/upstream/automake.git] / lib / tap-driver.sh
index c911991..19aa531 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
+# Copyright (C) 2011-2013 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -23,7 +23,7 @@
 # bugs to <bug-automake@gnu.org> or send patches to
 # <automake-patches@gnu.org>.
 
-scriptversion=2011-09-28.14; # UTC
+scriptversion=2011-12-27.17; # UTC
 
 # Make unconditional expansion of undefined variables an error.  This
 # helps a lot in preventing typo-related bugs.
@@ -115,7 +115,10 @@ else
   init_colors=''
 fi
 
-{
+# :; is there to work around a bug in bash 3.2 (and earlier) which
+# does not always set '$?' properly on redirection failure.
+# See the Autoconf manual for more details.
+:;{
   (
     # Ignore common signals (in this subshell only!), to avoid potential
     # problems with Korn shells.  Some Korn shells are known to propagate
@@ -573,12 +576,16 @@ while (1)
         handle_tap_plan(0, $0)
       }
     # "Bail out!" magic.
-    else if ($0 ~ /^Bail out!/)
+    # Older versions of prove and TAP::Harness (e.g., 3.17) did not
+    # recognize a "Bail out!" directive when preceded by leading
+    # whitespace, but more modern versions (e.g., 3.23) do.  So we
+    # emulate the latter, "more modern" behaviour.
+    else if ($0 ~ /^[ \t]*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]*Bail out![ \t]*", "");
         sub("[ \t]*$", "");
         # Format the error message for the
         bailout_message = "Bail out!"