Codebase list libbareword-filehandles-perl / 29114ca
Disable checking filetest ops on perl < 5.31.1 (RT#127073) Hooking the op check function breaks stacked file tests. Dagfinn Ilmari Mannsåker 4 years ago
4 changed file(s) with 24 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
00 Revision history for bareword::filehandles
11
22 {{$NEXT}}
3 - Disable checking filetest ops on perl < 5.31.1 (RT#127073)
34
45 0.006 2018-04-26 22:36:49+01:00 Europe/London
56 - Only use Lexical::SealRequireHints before perl 5.12
145145
146146 bareword_check(stat, OP_STAT);
147147 bareword_check(stat, OP_LSTAT);
148 #if PERL_VERSION_GE(5,31,1)
148149 bareword_check(stat, OP_FTRREAD);
149150 bareword_check(stat, OP_FTRWRITE);
150151 bareword_check(stat, OP_FTREXEC);
172173 bareword_check(stat, OP_FTTTY);
173174 bareword_check(stat, OP_FTTEXT);
174175 bareword_check(stat, OP_FTBINARY);
176 #endif
5151
5252 sub import { delete $^H{__PACKAGE__.'/disabled'} }
5353
54 =head1 LIMITATIONS
55
56 L<Filetest operators|perlfunc/-X> (C<-X>) can not be checked on Perl
57 versions before 5.32, because hooking the op check function for these
58 breaks stacked tests, e.g. C<-f -w -x $file>.
59
5460 =head1 SEE ALSO
5561
5662 L<perlfunc>,
1414 socket socketpair bind connect listen accept shutdown getsockopt
1515 setsockopt getsockname getpeername truncate chdir pipe
1616 )) {
17 eval "sub { no bareword::filehandles; $func BAREWORD }";
18 $@ =~ s/-([oO])/"-".chr(ord($1)^0x20)/e if "$]" < 5.008008; # workaround Perl RT#36672
19 like "$@", qr/^Use of bareword filehandle in \Q$func\E\b/, "$func BAREWORD dies";
17 SKIP: {
18 skip "Can't check filetest '$func' on Perl < 5.31.1", 1 if "$]" < 5.031001 and $func =~ /\A-.\z/;
19 eval "sub { no bareword::filehandles; $func BAREWORD }";
20 $@ =~ s/-([oO])/"-".chr(ord($1)^0x20)/e if "$]" < 5.008008; # workaround Perl RT#36672
21 like "$@", qr/^Use of bareword filehandle in \Q$func\E\b/, "$func BAREWORD dies";
22 }
2023 foreach my $fh ("", qw(STDIN STDERR STDOUT DATA ARGV)) {
2124 eval "sub { no bareword::filehandles; $func $fh }";
2225 unlike "$@", qr/Use of bareword filehandle/, "$func $fh lives";
2831 like "$@", qr/^Use of bareword filehandle in \Q$func\E\b/, "$func my \$fh, BAREWORD dies";
2932 }
3033
34
35 SKIP: {
36 skip "no stacked file tests on perl $]", 2 if "$]" < 5.010;
37 my $warnings = '';
38 local $SIG{__WARN__} = sub { $warnings .= $_[0] };
39 ok -d -e ".", "stacked file test works";
40 is $warnings, '', "no warnings for stacked file test";
41 };
42
3143 done_testing;
3244