summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-12-08 16:58:05 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2015-12-08 16:58:05 -0500
commit56a79a5ae9fe1426b07f8ad986777829f19b4437 (patch)
tree39f975aaf1b4dda31a6e3768eb6b79e946944031
parent0901d68babc324cc09077131fa966f15225e1fab (diff)
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.
-rw-r--r--src/test/perl/TestLib.pm7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm
index 478f855462f..8eb27df796f 100644
--- a/src/test/perl/TestLib.pm
+++ b/src/test/perl/TestLib.pm
@@ -242,9 +242,12 @@ sub slurp_dir
sub slurp_file
{
+ my ($filename) = @_;
local $/;
- local @ARGV = @_;
- my $contents = <>;
+ open(my $in, '<', $filename)
+ or die "could not read \"$filename\": $!";
+ my $contents = <$in>;
+ close $in;
$contents =~ s/\r//g if $Config{osname} eq 'msys';
return $contents;
}