postgres.git / summary / log / commit / refs

commit    59f10ffa5bc1f39a5ce00806b394feb8f207bb33
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Tue Dec 08 21:58:05 2015 +0000

    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.


src/test/perl/TestLib.pm | 7 +++++-- 1 file 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; } [parent: 325b357bc255]