Skip to content

Commit 38ff135

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 3af1094 commit 38ff135

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

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

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,28 +1193,27 @@ sub check_pgbench_logs
11931193
my $log_number = 0;
11941194
for my $log (sort @logs)
11951195
{
1196-
eval {
1197-
open my $fh, '<', $log or die "$@";
1198-
my @contents = <$fh>;
1199-
my $clen = @contents;
1200-
ok( $min <= $clen && $clen <= $max,
1201-
"transaction count for $log ($clen)");
1202-
my $clen_match = grep(/$re/, @contents);
1203-
ok($clen_match == $clen, "transaction format for $prefix");
1204-
# Show more information if some logs don't match
1205-
# to help with debugging.
1206-
if ($clen_match != $clen)
1196+
# Check the contents of each log file.
1197+
my $contents_raw = slurp_file($log);
1198+
1199+
my @contents = split(/\n/, $contents_raw);
1200+
my $clen = @contents;
1201+
ok( $min <= $clen && $clen <= $max,
1202+
"transaction count for $log ($clen)");
1203+
my $clen_match = grep(/$re/, @contents);
1204+
ok($clen_match == $clen, "transaction format for $prefix");
1205+
1206+
# Show more information if some logs don't match
1207+
# to help with debugging.
1208+
if ($clen_match != $clen)
1209+
{
1210+
foreach my $log (@contents)
12071211
{
1208-
foreach my $log (@contents)
1209-
{
1210-
print "# Log entry not matching: $log\n"
1211-
unless $log =~ /$re/;
1212-
}
1212+
print "# Log entry not matching: $log\n"
1213+
unless $log =~ /$re/;
12131214
}
1214-
close $fh or die "$@";
1215-
};
1215+
}
12161216
}
1217-
ok(unlink(@logs), "remove log files");
12181217
return;
12191218
}
12201219

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy