Skip to content

Commit 30e9477

Browse files
simbabqueoalders
authored andcommitted
run test that captures STDERR without taint mode #350
It seems that on certain Windows versions File::Temp is not working properly when run under taint mode. This problem must have been around for a while. Test::Output uses File::Temp, and therefore runs into this problem as our mech-dump.t has had the -T flag enabled. I do not know why we run under taint for some tests, but I have decided the most pragmatic fix is to undo my previous changes from #292 to the test an to move this particular test into its own file, which can run without taint. Also see https://www.perlmonks.org/?node_id=1122816 for details on the original problem.
1 parent 5b2cdbf commit 30e9477

File tree

3 files changed

+43
-22
lines changed

3 files changed

+43
-22
lines changed

Changes

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Revision history for WWW::Mechanize
22

33
{{$NEXT}}
4+
[FIXED]
5+
- There was a test suite failure on some Windows machines introduced in
6+
2.14 that is now fixed. (GH#350) (Julien Fiegehenn)
47
[ENHANCEMENTS]
58
- form_with and all_forms_with() now support the "action" attribute to find
69
forms (GH#349) (Julien Fiegehenn)

t/mech-dump/file_not_found.t

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!perl
2+
3+
use warnings;
4+
use strict;
5+
6+
use Test::More;
7+
use Test::Output qw(output_like);
8+
use File::Spec ();
9+
10+
# See https://stackoverflow.com/a/32054866/1331451
11+
plan skip_all =>
12+
'capturing output from system() is broken in 5.14 and 5.16 on Windows'
13+
if $^O eq 'MSWin32' && ( $] >= 5.014 && $] < 5.017 );
14+
15+
plan skip_all => 'Not installing mech-dump'
16+
if -e File::Spec->catfile(qw( t SKIP-MECH-DUMP ));
17+
18+
my $exe = File::Spec->catfile(qw( script mech-dump ));
19+
if ( $^O eq 'VMS' ) {
20+
$exe = qq[mcr $^X -Ilib $exe];
21+
}
22+
23+
my $perl;
24+
$perl = $1 if $^X =~ /^(.+)$/;
25+
26+
# The following file should not exist.
27+
my $source = 'file:not_found.404';
28+
29+
my $command = "$perl -Ilib $exe $source";
30+
31+
output_like(
32+
sub {
33+
system $command;
34+
},
35+
undef,
36+
qr/file:not_found.404 returns status 404/,
37+
'Errors when a local file is not found'
38+
);
39+
40+
done_testing;

t/mech-dump/mech-dump.t

-22
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use warnings;
44
use strict;
55

66
use Test::More;
7-
use Test::Output qw( output_like );
87
use File::Spec ();
98
use LWP ();
109

@@ -149,25 +148,4 @@ EOF
149148
is_deeply( \@actual, \@expected, 'Rest of the lines match' );
150149
};
151150

152-
subtest 'Local file not found' => sub {
153-
SKIP: {
154-
# See https://stackoverflow.com/a/32054866/1331451
155-
skip 'capturing output from system() is broken in 5.14 and 5.16 on Windows', 1
156-
if $^O eq 'MSWin32' && ( $] >= 5.014 && $] < 5.017 );
157-
158-
# The following file should not exist.
159-
my $source = 'file:not_found.404';
160-
161-
my $command = "$perl -Ilib $exe $source";
162-
163-
output_like(
164-
sub {
165-
system $command;
166-
},
167-
undef,
168-
qr/file:not_found.404 returns status 404/,
169-
'Errors when a local file is not found' );
170-
};
171-
};
172-
173151
done_testing;

0 commit comments

Comments
 (0)