From e698ee3ea801e1a02263516d75bc4fb1f25e7b3c Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Thu, 25 Aug 2011 13:22:58 +0200 Subject: 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. --- lib/tap-driver.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'lib/tap-driver.sh') diff --git a/lib/tap-driver.sh b/lib/tap-driver.sh index 535bc2b9b..44317d9de 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) -- cgit v1.2.1