Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 79c24a0

Browse files
committed
Cleanup some code related to pgbench log checks in TAP tests
This fixes a couple of problems within the so-said code of this commit subject: - Replace the use of open() with slurp_file(), fixing an issue reported by buildfarm member fairywren whose perl installation keep around CRLF characters, causing the matching patterns for the logs to fail. - Remove the eval block, which is not really necessary. This set of issues has come into light after fixing a different issue with c13585f, and this is wrong since this code has been introduced. Reported-by: Andrew Dunstan, and buildfarm member fairywren Author: Michael Paquier Reviewed-by: Andrew Dunstan Discussion: https://postgr.es/m/0f49303e-7784-b3ee-200b-cbf67be2eb9e@dunslane.net Backpatch-through: 11
1 parent 47d2264 commit 79c24a0

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

src/bin/pgbench/t/001_pgbench_with_server.pl

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -875,18 +875,27 @@ sub check_pgbench_logs
875875
my $log_number = 0;
876876
for my $log (sort @logs)
877877
{
878-
eval {
879-
open my $fh, '<', $log or die "$@";
880-
my @contents = <$fh>;
881-
my $clen = @contents;
882-
ok( $min <= $clen && $clen <= $max,
883-
"transaction count for $log ($clen)");
884-
ok( grep(/$re/, @contents) == $clen,
885-
"transaction format for $prefix");
886-
close $fh or die "$@";
887-
};
878+
# Check the contents of each log file.
879+
my $contents_raw = slurp_file($log);
880+
881+
my @contents = split(/\n/, $contents_raw);
882+
my $clen = @contents;
883+
ok( $min <= $clen && $clen <= $max,
884+
"transaction count for $log ($clen)");
885+
my $clen_match = grep(/$re/, @contents);
886+
ok($clen_match == $clen, "transaction format for $prefix");
887+
888+
# Show more information if some logs don't match
889+
# to help with debugging.
890+
if ($clen_match != $clen)
891+
{
892+
foreach my $log (@contents)
893+
{
894+
print "# Log entry not matching: $log\n"
895+
unless $log =~ /$re/;
896+
}
897+
}
888898
}
889-
ok(unlink(@logs), "remove log files");
890899
return;
891900
}
892901

0 commit comments

Comments
 (0)