mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
Add much-more-extensive TAP tests for pgbench.
Fabien Coelho, reviewed by Nikolay Shaplov and myself Discussion: https://postgr.es/m/alpine.DEB.2.20.1704171422500.4025@lancre
This commit is contained in:
@ -39,6 +39,7 @@ our @EXPORT = qw(
|
||||
command_like
|
||||
command_like_safe
|
||||
command_fails_like
|
||||
command_checks_all
|
||||
|
||||
$windows_os
|
||||
);
|
||||
@ -330,4 +331,41 @@ sub command_fails_like
|
||||
like($stderr, $expected_stderr, "$test_name: matches");
|
||||
}
|
||||
|
||||
# Run a command and check its status and outputs.
|
||||
# The 5 arguments are:
|
||||
# - cmd: ref to list for command, options and arguments to run
|
||||
# - ret: expected exit status
|
||||
# - out: ref to list of re to be checked against stdout (all must match)
|
||||
# - err: ref to list of re to be checked against stderr (all must match)
|
||||
# - test_name: name of test
|
||||
sub command_checks_all
|
||||
{
|
||||
my ($cmd, $ret, $out, $err, $test_name) = @_;
|
||||
|
||||
# run command
|
||||
my ($stdout, $stderr);
|
||||
print("# Running: " . join(" ", @{$cmd}) . "\n");
|
||||
IPC::Run::run($cmd, '>', \$stdout, '2>', \$stderr);
|
||||
|
||||
# On Windows, the exit status of the process is returned directly as the
|
||||
# process's exit code, while on Unix, it's returned in the high bits
|
||||
# of the exit code.
|
||||
my $status = $windows_os ? $? : $? >> 8;
|
||||
|
||||
# check status
|
||||
ok($ret == $status, "$test_name status (got $status vs expected $ret)");
|
||||
|
||||
# check stdout
|
||||
for my $re (@$out)
|
||||
{
|
||||
like($stdout, $re, "$test_name stdout /$re/");
|
||||
}
|
||||
|
||||
# check stderr
|
||||
for my $re (@$err)
|
||||
{
|
||||
like($stderr, $re, "$test_name stderr /$re/");
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
Reference in New Issue
Block a user