Skip to content

Commit 2f34bff

Browse files
janduboiscraigberry
authored andcommitted
Test::Harness resets last error
So preserve it immediately after call.
1 parent 9d42114 commit 2f34bff

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

t/HttpGetFile.t

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,19 @@ END { 1 while unlink $tmpfile; }
1212
# set PERL_WIN32_INTERNET_OK=1
1313
plan tests => $ENV{PERL_WIN32_INTERNET_OK} ? 6 : 4;
1414

15-
ok(Win32::HttpGetFile('nonesuch://example.com', 'NUL:'), "", "'nonesuch://' is not a real protocol");
16-
ok(Win32::GetLastError(), '12006', "correct error code for unrecognized protocol");
17-
ok(Win32::HttpGetFile('http://!#@!&@$', 'NUL:'), "", "invalid URL");
18-
ok(Win32::GetLastError(), '12005', "correct error code for invalid URL");
15+
# On Cygwin the test_harness will invoke additional Win32 APIs that
16+
# will reset the Win32::GetLastError() value, so capture it immediately.
17+
my $LastError;
18+
sub HttpGetFile {
19+
my $ok = Win32::HttpGetFile(@_);
20+
$LastError = Win32::GetLastError();
21+
return $ok;
22+
}
23+
24+
ok(HttpGetFile('nonesuch://example.com', 'NUL:'), "", "'nonesuch://' is not a real protocol");
25+
ok($LastError, '12006', "correct error code for unrecognized protocol");
26+
ok(HttpGetFile('http://!#@!&@$', 'NUL:'), "", "invalid URL");
27+
ok($LastError, '12005', "correct error code for invalid URL");
1928

2029
if ($ENV{PERL_WIN32_INTERNET_OK}) {
2130
# The digest for version 0.57 should obviously stay the same even after new versions are released

0 commit comments

Comments
 (0)