From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Weird portability issue in TestLib.pm's slurp_file |
Date: | 2015-12-08 17:31:25 |
Message-ID: | 12485.1449595885@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
For grins I tried running the TAP tests on my ancient HPUX box that
hosts pademelon and gaur. At first they showed a lot of failures,
which I eventually determined were happening because slurp_file was
only retrieving part of the postmaster logfile, causing issues_sql_like
to mistakenly report a failure. I don't know exactly why slurp_file
is misbehaving; it may well be a bug in perl 5.8.9. But anyway,
rewriting it like this makes the problem go away:
diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm
index da67f33c7e38929067350c7cf0da8fd8c5c1e43d..3940891e5d0533af93bacf3ff4af5a6fb5f10117 100644
*** a/src/test/perl/TestLib.pm
--- b/src/test/perl/TestLib.pm
*************** sub slurp_dir
*** 158,166 ****
sub slurp_file
{
local $/;
! local @ARGV = @_;
! my $contents = <>;
$contents =~ s/\r//g if $Config{osname} eq 'msys';
return $contents;
}
--- 158,169 ----
sub slurp_file
{
+ my ($filename) = @_;
local $/;
! 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;
}
To my admittedly-no-perl-expert eye, the existing coding is too cute
by half anyway, eg what it will do in error situations is documented
nowhere that I can find in man perlop.
Any objections to pushing this?
regards, tom lane
PS: I'm not planning to turn on TAP testing on pademelon/gaur; looks like
that would add about 40 minutes to what's already an hour and a half per
buildfarm run. But it might be good to check it manually every so often.
From | Date | Subject | |
---|---|---|---|
Next Message | Oleksii Kliukin | 2015-12-08 17:35:09 | Re: pg_rewind test race condition..? |
Previous Message | Andrew Dunstan | 2015-12-08 17:24:09 | Re: Include ppc64le build type for back branches |