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.
This commit is contained in:
parent
0901d68bab
commit
56a79a5ae9
@ -242,9 +242,12 @@ sub slurp_dir
|
|||||||
|
|
||||||
sub slurp_file
|
sub slurp_file
|
||||||
{
|
{
|
||||||
|
my ($filename) = @_;
|
||||||
local $/;
|
local $/;
|
||||||
local @ARGV = @_;
|
open(my $in, '<', $filename)
|
||||||
my $contents = <>;
|
or die "could not read \"$filename\": $!";
|
||||||
|
my $contents = <$in>;
|
||||||
|
close $in;
|
||||||
$contents =~ s/\r//g if $Config{osname} eq 'msys';
|
$contents =~ s/\r//g if $Config{osname} eq 'msys';
|
||||||
return $contents;
|
return $contents;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user