Skip Menu |

This queue is for tickets about the Time-HiRes-Value CPAN distribution.

Report information
The Basics
Id: 105406
Status: resolved
Priority: 0/
Queue: Time-HiRes-Value

People
Owner: Nobody in particular
Requestors: wesdmalone [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.08



Subject: Patch for test failures on Windows
Date: Mon, 22 Jun 2015 13:18:55 -0500
To: bug-Time-HiRes-Value [...] rt.cpan.org
From: Wes Malone <wesdmalone [...] gmail.com>
Tests fail on Windows with the following output: # Failed test 'divide t1 / 0 fails' # at t\01test.t line 111. # 'Illegal division by zero at t\01test.t line 110. # ' # doesn't match '(?^:^Illegal division by zero at t\01test.t line)' # Looks like you failed 1 test of 51. $0 on MSWin32 can have unescaped backslashes, breaking the exception regex. This patch will escape those paths. The escaping here is naive, but we only need to escape the relative path of $0, not account for every possible absolute path that the test can run from. diff --git a/t/01test.t b/t/01test.t index 95b60e0..9d9fe5c 100755 --- a/t/01test.t +++ b/t/01test.t @@ -108,5 +108,7 @@ dies_ok( sub { $t1 / $t2 }, # Test::Exception seems to mess this one up via Carp, so we'll do it the old- # fashioned way $_ = eval { $t1 / 0 }; -like( $@, qr/^Illegal division by zero at $0 line/, +my $safe_path = $0; +$safe_path =~ s/\\/\\\\/g; # MSWin32 paths can have unescaped backslashes +like( $@, qr/^Illegal division by zero at $safe_path line/, 'divide t1 / 0 fails' ); Hope this helps.
On 2015-06-22 14:19:30, wesdmalone@gmail.com wrote: Show quoted text
> Tests fail on Windows with the following output: > > # Failed test 'divide t1 / 0 fails' > # at t\01test.t line 111. > # 'Illegal division by zero at t\01test.t line 110. > # ' > # doesn't match '(?^:^Illegal division by zero at t\01test.t > line)' > # Looks like you failed 1 test of 51. > > $0 on MSWin32 can have unescaped backslashes, breaking the exception > regex. This patch will escape those paths. The escaping here is naive, > but we only need to escape the relative path of $0, not account for > every possible absolute path that the test can run from. > > diff --git a/t/01test.t b/t/01test.t > index 95b60e0..9d9fe5c 100755 > --- a/t/01test.t > +++ b/t/01test.t > @@ -108,5 +108,7 @@ dies_ok( sub { $t1 / $t2 }, > # Test::Exception seems to mess this one up via Carp, so we'll do it > the old- > # fashioned way > $_ = eval { $t1 / 0 }; > -like( $@, qr/^Illegal division by zero at $0 line/, > +my $safe_path = $0; > +$safe_path =~ s/\\/\\\\/g; # MSWin32 paths can have unescaped > backslashes > +like( $@, qr/^Illegal division by zero at $safe_path line/, > 'divide t1 / 0 fails' ); > > Hope this helps.
I think it's even better if quotemeta() is used here, or alternatively put a \Q in the regexp before $0.
Subject: Re: [rt.cpan.org #105406] Patch for test failures on Windows
Date: Tue, 23 Jun 2015 10:21:01 -0500
To: bug-Time-HiRes-Value [...] rt.cpan.org
From: Wes Malone <wesdmalone [...] gmail.com>
On Tue, Jun 23, 2015 at 2:31 AM, Slaven_Rezic via RT <bug-Time-HiRes-Value@rt.cpan.org> wrote: Show quoted text
> On 2015-06-22 14:19:30, wesdmalone@gmail.com wrote:
>> Tests fail on Windows with the following output: >> >> # Failed test 'divide t1 / 0 fails' >> # at t\01test.t line 111. >> # 'Illegal division by zero at t\01test.t line 110. >> # ' >> # doesn't match '(?^:^Illegal division by zero at t\01test.t >> line)' >> # Looks like you failed 1 test of 51. >> >> $0 on MSWin32 can have unescaped backslashes, breaking the exception >> regex. This patch will escape those paths. The escaping here is naive, >> but we only need to escape the relative path of $0, not account for >> every possible absolute path that the test can run from. >> >> diff --git a/t/01test.t b/t/01test.t >> index 95b60e0..9d9fe5c 100755 >> --- a/t/01test.t >> +++ b/t/01test.t >> @@ -108,5 +108,7 @@ dies_ok( sub { $t1 / $t2 }, >> # Test::Exception seems to mess this one up via Carp, so we'll do it >> the old- >> # fashioned way >> $_ = eval { $t1 / 0 }; >> -like( $@, qr/^Illegal division by zero at $0 line/, >> +my $safe_path = $0; >> +$safe_path =~ s/\\/\\\\/g; # MSWin32 paths can have unescaped >> backslashes >> +like( $@, qr/^Illegal division by zero at $safe_path line/, >> 'divide t1 / 0 fails' ); >> >> Hope this helps.
> > I think it's even better if quotemeta() is used here, or alternatively put a \Q in the regexp before $0. >
Ah, that's what it is. I went hunting through the docs trying to find that regexp escape sequence. This is much better, thanks. diff --git a/t/01test.t b/t/01test.t index 95b60e0..fc55fbd 100755 --- a/t/01test.t +++ b/t/01test.t @@ -108,5 +108,5 @@ dies_ok( sub { $t1 / $t2 }, # Test::Exception seems to mess this one up via Carp, so we'll do it the old- # fashioned way $_ = eval { $t1 / 0 }; -like( $@, qr/^Illegal division by zero at $0 line/, +like( $@, qr/^Illegal division by zero at \Q$0 line/, 'divide t1 / 0 fails' );
\Q is indeed much preferred. -- Paul Evans
Oh, huh. I actually fixed this in 2009 and then forgot to release it. Oops. 62: Paul "LeoNerd" Evans 2009-09-13 Remember to quotemeta $0 in regexps, because on Windows the dir. separator is \ -- Paul Evans
Released back in June. -- Paul Evans