Skip to content

Commit 56a79a5

Browse files
committed
Avoid odd portability problem in TestLib.pm's slurp_file function.
For unclear reasons, this function doesn't always read the expected data in some old Perl versions. Rewriting it to avoid use of ARGV seems to dodge the problem, and this version is clearer anyway if you ask me. In passing, also improve error message in adjacent append_to_file function.
1 parent 0901d68 commit 56a79a5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/test/perl/TestLib.pm

+5-2
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,12 @@ sub slurp_dir
242242

243243
sub slurp_file
244244
{
245+
my ($filename) = @_;
245246
local $/;
246-
local @ARGV = @_;
247-
my $contents = <>;
247+
open(my $in, '<', $filename)
248+
or die "could not read \"$filename\": $!";
249+
my $contents = <$in>;
250+
close $in;
248251
$contents =~ s/\r//g if $Config{osname} eq 'msys';
249252
return $contents;
250253
}

0 commit comments

Comments
 (0)