Subject: | bug fix in bleadperl causes test failure in t/08-errors.t |
Due to a bug fix in blead perl (which will become perl 5.20.0 in a few months) I see the following test failure in Text-MicroMason:
t/08-errors.t ............... 1/28
# Failed test 'first line of $@ describes the error location'
# at t/08-errors.t line 37.
# 'MicroMason compilation failed: syntax error at text template (compiled at t/08-errors.t line 35) line 9, at EOF'
# doesn't match '(?^:MicroMason compilation failed: syntax error at text template \(compiled at t/08-errors.t line \d+\) line 8)'
# MicroMason compilation failed: syntax error at text template (compiled at t/08-errors.t line 35) line 9, at EOF
#
# 0 # line 1 "text template (compiled at t/08-errors.t line 35)"
# 1 sub {
# 2 local $SIG{__DIE__} = sub { die "MicroMason execution failed: ", @_ };
# 3 my @OUT; my $_out = sub {push @OUT, @_};
# 4 my %ARGS = @_ if ($#_ % 2);
# 5 push @OUT,( qq(Hello\ world\!\
# 6 This\ ) );
# 7 push @OUT,( "".do{
# 8 thing(
# 9 } );
# 10 push @OUT,( qq(\ is\ a\ test\.\
# 11 End\.\
# 12 ) );
# 13 join("", @OUT)
# 14 }
# ** Please use Text::MicroMason->new(-LineNumbers) for better diagnostics!
# at t/08-errors.t line 35.
# eval {...} called at t/08-errors.t line 35
# Looks like you failed 1 test of 28.
t/08-errors.t ............... Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/28 subtests
The fix is that older versions of perl don't properly take into account the escaped newlines in the string starting in the line numbered 5 above.
If I add extra escaped newlines, blead's error reports line number increases, but this doesn't occur for older perls (I tested on 5.14.2). e.g. with a file:
# line 1 "text template (compiled at t/08-errors.t line 35)"
sub {
local $SIG{__DIE__} = sub { die "MicroMason execution failed: ", @_ };
my @OUT; my $_out = sub {push @OUT, @_};
my %ARGS = @_ if ($#_ % 2);
push @OUT,( qq(Hello\ world\!\
\
\
\
This\ ) );
push @OUT,( "".do{
thing(
} );
push @OUT,( qq(\ is\ a\ test\.\
End\.\
) );
join("", @OUT)
}
first 5.14.2:
$ perl -e '$code = `cat ../foo.compiled.pl`; eval $code; print $@'
syntax error at text template (compiled at t/08-errors.t line 35) line 8, at EOF
and blead:
$ ./perl -e '$code = `cat ../foo.compiled.pl`; eval $code; print $@'
syntax error at text template (compiled at t/08-errors.t line 35) line 12, at EOF
In perl, this is ticket 119593 which can be found at https://rt.perl.org/Ticket/Display.html?id=119593
Tony