[tapx-dev] [commit][177] Fixed handling of escaped hashes (\#) in test description.
andy at hexten.net
andy at hexten.net
Thu Jul 12 23:41:44 BST 2007
Revision: 177
Author: andy
Date: 2007-07-12 23:41:44 +0100 (Thu, 12 Jul 2007)
Log Message:
-----------
Fixed handling of escaped hashes (\#) in test description.
Modified Paths:
--------------
trunk/Changes
trunk/lib/TAP/Parser/Grammar.pm
trunk/t/020-regression.t
Added Paths:
-----------
trunk/t/sample-tests/escape_eol
trunk/t/sample-tests/escape_hash
Modified: trunk/Changes
===================================================================
--- trunk/Changes 2007-07-12 22:40:45 UTC (rev 176)
+++ trunk/Changes 2007-07-12 22:41:44 UTC (rev 177)
@@ -66,7 +66,7 @@
- Made runtests return the TAP::Parser::Aggregator
- Fixed t/120-harness.t has failures if TAP::Harness::Color cannot
load optional modules [27125] - thanks DROLKSY
-
+ - Fixed parsing of \# in test description
0.51 12 March 2007
- 'execrc' file now allows 'regex' matches for tests.
- rename 'TAPx' --> 'TAP'
Modified: trunk/lib/TAP/Parser/Grammar.pm
===================================================================
--- trunk/lib/TAP/Parser/Grammar.pm 2007-07-12 22:40:45 UTC (rev 176)
+++ trunk/lib/TAP/Parser/Grammar.pm 2007-07-12 22:41:44 UTC (rev 177)
@@ -60,22 +60,6 @@
my $ok = qr/(?:not )?ok\b/;
my $num = qr/\d+/;
-# description is *any* which is not followed by an odd number of escapes
-# following by '#': \\\# \#
-my $description = qr/.*?(?!\\(?:\\\\)*)#?/;
-
-# if we have an even number of escapes in front of the '#', assert that it
-# does not have an escape in front of it (this gets around the 'no variable
-# length lookbehind assertions')
-my $directive = qr/
- (?<!\\)(?:\\\\)*
- (?i:
- \#\s+
- (TODO|SKIP)\b
- (.*)
- )?
- /x;
-
my %v12 = (
version => {
syntax => qr/^TAP\s+version\s+(\d+)\s*\z/i,
@@ -104,21 +88,20 @@
},
},
test => {
- syntax => qr/^
- ($ok)
- \s*
- ($num)?
- \s*
- ($description)?
- $directive # $4 = directive, $5 = explanation
- \z/x,
+ syntax => qr/^($ok) \s* ($num)? \s* (.*) \z/x,
handler => sub {
my ( $self, $line ) = @_;
local *__ANON__ = '__ANON__test_token_handler';
- my ( $ok, $num, $desc, $dir, $explanation )
- = ( $1, $2, $3, $4, $5 );
- return $self->_make_test_token( $line, $ok, $num, $desc, uc $dir,
- $explanation );
+ my ( $ok, $num, $desc ) = ( $1, $2, $3 );
+ my ( $dir, $explanation ) = ( '', '' );
+ if ( $desc
+ =~ m/^ ( [^\\\#]* (?: \\. [^\\\#]* )* )
+ \# \s* (SKIP|TODO) \b \s* (.*) $/ix
+ ) {
+ ( $desc, $dir, $explanation ) = ( $1, $2, $3 );
+ }
+ return $self->_make_test_token( $line, $ok, $num, _trim( $desc ),
+ uc $dir, $explanation );
},
},
comment => {
Modified: trunk/t/020-regression.t
===================================================================
--- trunk/t/020-regression.t 2007-07-12 22:40:45 UTC (rev 176)
+++ trunk/t/020-regression.t 2007-07-12 22:41:44 UTC (rev 177)
@@ -2871,6 +2871,122 @@
wait => 0,
version => 12,
},
+
+ escape_eol => {
+ results => [
+ {
+ is_plan => TRUE,
+ raw => '1..2',
+ tests_planned => 2,
+ passed => TRUE,
+ is_ok => TRUE,
+ },
+ {
+ actual_passed => TRUE,
+ is_actual_ok => TRUE,
+ description => 'Should parse as literal backslash --> \\',
+ passed => TRUE,
+ is_ok => TRUE,
+ is_test => TRUE,
+ has_skip => FALSE,
+ has_todo => FALSE,
+ number => 1,
+ is_unplanned => FALSE,
+ },
+ {
+ actual_passed => TRUE,
+ is_actual_ok => TRUE,
+ passed => TRUE,
+ is_ok => TRUE,
+ is_test => TRUE,
+ has_skip => FALSE,
+ has_todo => FALSE,
+ number => 2,
+ description => 'Not a continuation line',
+ is_unplanned => FALSE,
+ },
+ ],
+ plan => '1..2',
+ passed => [ 1 .. 2 ],
+ actual_passed => [ 1 .. 2 ],
+ failed => [],
+ actual_failed => [],
+ todo => [],
+ todo_passed => [],
+ skipped => [],
+ good_plan => TRUE,
+ is_good_plan => TRUE,
+ tests_planned => 2,
+ tests_run => 2,
+ parse_errors => [],
+ 'exit' => 0,
+ wait => 0,
+ version => 12,
+ },
+
+ escape_hash => {
+ results => [
+ {
+ is_plan => TRUE,
+ raw => '1..3',
+ tests_planned => 3,
+ passed => TRUE,
+ is_ok => TRUE,
+ },
+ {
+ actual_passed => TRUE,
+ is_actual_ok => TRUE,
+ description => 'Not a \\# TODO',
+ passed => TRUE,
+ is_ok => TRUE,
+ is_test => TRUE,
+ has_skip => FALSE,
+ has_todo => FALSE,
+ number => 1,
+ is_unplanned => FALSE,
+ },
+ {
+ actual_passed => TRUE,
+ is_actual_ok => TRUE,
+ passed => TRUE,
+ is_ok => TRUE,
+ is_test => TRUE,
+ has_skip => FALSE,
+ has_todo => FALSE,
+ number => 2,
+ description => 'Not a \\# SKIP',
+ is_unplanned => FALSE,
+ },
+ {
+ actual_passed => TRUE,
+ is_actual_ok => TRUE,
+ passed => TRUE,
+ is_ok => TRUE,
+ is_test => TRUE,
+ has_skip => FALSE,
+ has_todo => FALSE,
+ number => 3,
+ description => 'Escaped \\\\\\#',
+ is_unplanned => FALSE,
+ },
+ ],
+ plan => '1..3',
+ passed => [ 1 .. 3 ],
+ actual_passed => [ 1 .. 3 ],
+ failed => [],
+ actual_failed => [],
+ todo => [],
+ todo_passed => [],
+ skipped => [],
+ good_plan => TRUE,
+ is_good_plan => TRUE,
+ tests_planned => 3,
+ tests_run => 3,
+ parse_errors => [],
+ 'exit' => 0,
+ wait => 0,
+ version => 12,
+ },
);
my %HANDLER_FOR = (
Added: trunk/t/sample-tests/escape_eol
===================================================================
--- trunk/t/sample-tests/escape_eol (rev 0)
+++ trunk/t/sample-tests/escape_eol 2007-07-12 22:41:44 UTC (rev 177)
@@ -0,0 +1,5 @@
+print <<DUMMY_TEST;
+1..2
+ok 1 Should parse as literal backslash --> \\
+ok 2 Not a continuation line
+DUMMY_TEST
Added: trunk/t/sample-tests/escape_hash
===================================================================
--- trunk/t/sample-tests/escape_hash (rev 0)
+++ trunk/t/sample-tests/escape_hash 2007-07-12 22:41:44 UTC (rev 177)
@@ -0,0 +1,6 @@
+print <<DUMMY_TEST;
+1..3
+ok 1 Not a \\# TODO
+ok 2 Not a \\# SKIP
+ok 3 Escaped \\\\\\#
+DUMMY_TEST
More information about the tapx-dev
mailing list