This arose when testing escape substitutions and identifying each test by
interpolating the character sequence into the test description. This gets
confusing
if gratuitous '\'s appear in the test report.
However, when repeating the test a few minutes ago, I found that the
problem has gone
away!
# trivial.t
use Test::More 0.94;
plan tests => 2;
ok( 1, 'test name containing # character' );
ok( 1, 'test name containing \# sequence' );
now produces:
$ perl trivial.t
1..2
ok 1 - test name containing # character
ok 2 - test name containing \# sequence
This works for me.
> This arose when testing escape substitutions and identifying each test by
> interpolating the character sequence into the test description. This gets
> confusing
> if gratuitous '\'s appear in the test report.
What are you using to interpret the test output? I don't know if
Test::Harness
understands the escaping.
> However, when repeating the test a few minutes ago, I found that the
> problem
> has gone away!
I do not get that result and no change was made to the escaping. Something
is wrong
or you're using an altered version. Can you tell me what operating system
and
version of that OS you're using (for example, Fedora 13) and if you're
using the
system installed version?
TAP::Parser::Grammar.pm has SKIP|TODO hard-coded in a regex at line 145. It
will fail
to match # <random thing>, in which case the entire line is treated as the
test name.
Escaping the # only makes a difference for \#SKIP or \#TODO which I guess
would only
arise when testing test programs and is of little interest to other users.
I overcame my problem by deleting line 750 from a copy of Test::Builder.pm.
The modified version got back into the @INC path accidentally. I am using
Fedora13
and think @INC may have changed since Fedora12. My mistake, I should have
checked the
result more carefully.
My considered view remains that deleting line 750 would be an improvement
for most
users. The penalty is some minor inconvenience for those wishing to use
#SKIP as part
of a test name (that is, not as a directive).
> TAP::Parser::Grammar.pm has SKIP|TODO hard-coded in a regex at line 145.
> It
> will fail to match # <random thing>, in which case the entire line is
> treated
> as the test name.
Test::Builder does not write to the quirks of TAP::Parser but to the TAP
specification. We deliberately decouple Test::Builder from TAP::Parser.
TAP::Parser's quirks today are not its quirks tomorrow. The above behavior
can
arguably be called a bug, the spec isn't entirely clear on that point, but
it could
have just as easily not hard coded them. The TAP::Parser folks tend to do
a very
strict reading of the spec.
In addition, TAP is a specification which can be extended. Escaping the #
is a
deliberate feature to guard against new TAP directives (skip and todo are
directives). SKIP was added in 1997 and TODO was added in 2001.
> I overcame my problem by deleting line 750 from a copy of
> Test::Builder.pm.
> ...
> My considered view remains that deleting line 750 would be an improvement
> for most users. The penalty is some minor inconvenience for those wishing
> to use #SKIP as part of a test name (that is, not as a directive).
Most users don't even know this feature exists, and that is as it should be.
Test::Builder shields users from the details of TAP, especially the little
things
that could silently cause tests to do weird things. That is far more
important than
an aesthetically displeasing backslash.
It hasn't been made clear why the escape is a problem. I asked earlier
what you're
using to parse the TAP. Is it TAP::Parser, or Test::Harness, or did you
write your
own parser? Or are you eyeballing it? Please show the code which is
affected.
There is one minor bug here, it is that the # is escaped in the comment as
well.
# Failed test 'test name containing \# character'
should technically be
# Failed test 'test name containing # character'