]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
tap/awk: allow escaping of TAP directives
authorStefano Lattarini <stefano.lattarini@gmail.com>
Thu, 25 Aug 2011 11:22:58 +0000 (13:22 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Thu, 25 Aug 2011 11:56:35 +0000 (13:56 +0200)
* lib/tap-driver.sh (setup_result_obj): Handle escaping of TAP
directives in a way tat is (mostly) compatible by what is done
by the TAP::Parser module.
With this change, the tests `tap-escape-directive.test' and
`tap-escape-directive-2.test' now also pass with the shell/awk
implementation of the TAP driver.

ChangeLog
lib/tap-driver.sh

index 71775835e11710f98b42e59a0b560b672df7a8bf..e407d8989209f8e86d7e9c11ecb8b69ed8d5ca89 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-08-25  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       tap/awk: allow escaping of TAP directives
+       * lib/tap-driver.sh (setup_result_obj): Handle escaping of TAP
+       directives in a way tat is (mostly) compatible by what is done
+       by the TAP::Parser module.
+       With this change, the tests `tap-escape-directive.test' and
+       `tap-escape-directive-2.test' now also pass with the shell/awk
+       implementation of the TAP driver.
+
 2011-08-25  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
        coverage: more about escaping of TAP directives
index 535bc2b9bbe2db85c7d161310aae99e03a26463a..44317d9de90fe202900f9decc7e8d676cfd65032 100755 (executable)
@@ -23,7 +23,7 @@
 # bugs to <bug-automake@gnu.org> or send patches to
 # <automake-patches@gnu.org>.
 
-scriptversion=2011-08-25.10; # UTC
+scriptversion=2011-08-25.11; # UTC
 
 # Make unconditional expansion of undefined variables an error.  This
 # helps a lot in preventing typo-related bugs.
@@ -382,7 +382,6 @@ function setup_result_obj(line)
   result_obj["directive"] = ""
   result_obj["explanation"] = ""
 
-  # TODO: maybe we should allow a way to escape "#"?
   if (index(line, "#") == 0)
     return # No possible directive, nothing more to do.
 
@@ -398,6 +397,20 @@ function setup_result_obj(line)
   if (!pos)
     return
 
+  # Let`s now see if the TAP directive has been escaped.  For example:
+  #  escaped:     ok \# SKIP
+  #  not escaped: ok \\# SKIP
+  #  escaped:     ok \\\\\# SKIP
+  #  not escaped: ok \ # SKIP
+  if (substr(line, pos, 1) == "#")
+    {
+      bslash_count = 0
+      for (i = pos; i > 1 && substr(line, i - 1, 1) == "\\"; i--)
+        bslash_count += 1
+      if (bslash_count % 2)
+        return # Directive was escaped.
+    }
+
   # Strip the directive and its explanation (if any) from the test
   # description.
   result_obj["description"] = substr(line, 1, pos - 1)