From e698ee3ea801e1a02263516d75bc4fb1f25e7b3c Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Thu, 25 Aug 2011 13:22:58 +0200 Subject: [PATCH] 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. --- ChangeLog | 10 ++++++++++ lib/tap-driver.sh | 17 +++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7177583..e407d89 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2011-08-25 Stefano Lattarini + 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 + coverage: more about escaping of TAP directives * tests/tap-escape-directive.test: Make grepping of testsuite progress output slightly stricter. diff --git a/lib/tap-driver.sh b/lib/tap-driver.sh index 535bc2b..44317d9 100755 --- a/lib/tap-driver.sh +++ b/lib/tap-driver.sh @@ -23,7 +23,7 @@ # bugs to or send patches to # . -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) -- 2.7.4