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.