mirror of
https://github.com/postgres/postgres.git
synced 2025-05-09 18:21:05 +03:00
Use $Test::Builder::Level in TAP test functions
In TAP test functions, that is, those that produce test results, locally increment $Test::Builder::Level. This has the effect that test failures are reported at the callers location rather than somewhere in the test support libraries. Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
This commit is contained in:
parent
65782346a4
commit
c4309f4aee
@ -87,6 +87,8 @@ sub standby_psql
|
|||||||
# expected
|
# expected
|
||||||
sub check_query
|
sub check_query
|
||||||
{
|
{
|
||||||
|
local $Test::Builder::Level = $Test::Builder::Level + 1;
|
||||||
|
|
||||||
my ($query, $expected_stdout, $test_name) = @_;
|
my ($query, $expected_stdout, $test_name) = @_;
|
||||||
my ($stdout, $stderr);
|
my ($stdout, $stderr);
|
||||||
|
|
||||||
|
@ -1366,6 +1366,8 @@ PostgresNode.
|
|||||||
|
|
||||||
sub command_ok
|
sub command_ok
|
||||||
{
|
{
|
||||||
|
local $Test::Builder::Level = $Test::Builder::Level + 1;
|
||||||
|
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
local $ENV{PGPORT} = $self->port;
|
local $ENV{PGPORT} = $self->port;
|
||||||
@ -1384,6 +1386,8 @@ TestLib::command_fails with our PGPORT. See command_ok(...)
|
|||||||
|
|
||||||
sub command_fails
|
sub command_fails
|
||||||
{
|
{
|
||||||
|
local $Test::Builder::Level = $Test::Builder::Level + 1;
|
||||||
|
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
local $ENV{PGPORT} = $self->port;
|
local $ENV{PGPORT} = $self->port;
|
||||||
@ -1402,6 +1406,8 @@ TestLib::command_like with our PGPORT. See command_ok(...)
|
|||||||
|
|
||||||
sub command_like
|
sub command_like
|
||||||
{
|
{
|
||||||
|
local $Test::Builder::Level = $Test::Builder::Level + 1;
|
||||||
|
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
local $ENV{PGPORT} = $self->port;
|
local $ENV{PGPORT} = $self->port;
|
||||||
@ -1420,6 +1426,8 @@ TestLib::command_checks_all with our PGPORT. See command_ok(...)
|
|||||||
|
|
||||||
sub command_checks_all
|
sub command_checks_all
|
||||||
{
|
{
|
||||||
|
local $Test::Builder::Level = $Test::Builder::Level + 1;
|
||||||
|
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
local $ENV{PGPORT} = $self->port;
|
local $ENV{PGPORT} = $self->port;
|
||||||
@ -1442,6 +1450,8 @@ The log file is truncated prior to running the command, however.
|
|||||||
|
|
||||||
sub issues_sql_like
|
sub issues_sql_like
|
||||||
{
|
{
|
||||||
|
local $Test::Builder::Level = $Test::Builder::Level + 1;
|
||||||
|
|
||||||
my ($self, $cmd, $expected_sql, $test_name) = @_;
|
my ($self, $cmd, $expected_sql, $test_name) = @_;
|
||||||
|
|
||||||
local $ENV{PGPORT} = $self->port;
|
local $ENV{PGPORT} = $self->port;
|
||||||
|
@ -366,6 +366,7 @@ sub check_pg_config
|
|||||||
#
|
#
|
||||||
sub command_ok
|
sub command_ok
|
||||||
{
|
{
|
||||||
|
local $Test::Builder::Level = $Test::Builder::Level + 1;
|
||||||
my ($cmd, $test_name) = @_;
|
my ($cmd, $test_name) = @_;
|
||||||
my $result = run_log($cmd);
|
my $result = run_log($cmd);
|
||||||
ok($result, $test_name);
|
ok($result, $test_name);
|
||||||
@ -374,6 +375,7 @@ sub command_ok
|
|||||||
|
|
||||||
sub command_fails
|
sub command_fails
|
||||||
{
|
{
|
||||||
|
local $Test::Builder::Level = $Test::Builder::Level + 1;
|
||||||
my ($cmd, $test_name) = @_;
|
my ($cmd, $test_name) = @_;
|
||||||
my $result = run_log($cmd);
|
my $result = run_log($cmd);
|
||||||
ok(!$result, $test_name);
|
ok(!$result, $test_name);
|
||||||
@ -382,6 +384,7 @@ sub command_fails
|
|||||||
|
|
||||||
sub command_exit_is
|
sub command_exit_is
|
||||||
{
|
{
|
||||||
|
local $Test::Builder::Level = $Test::Builder::Level + 1;
|
||||||
my ($cmd, $expected, $test_name) = @_;
|
my ($cmd, $expected, $test_name) = @_;
|
||||||
print("# Running: " . join(" ", @{$cmd}) . "\n");
|
print("# Running: " . join(" ", @{$cmd}) . "\n");
|
||||||
my $h = IPC::Run::start $cmd;
|
my $h = IPC::Run::start $cmd;
|
||||||
@ -404,6 +407,7 @@ sub command_exit_is
|
|||||||
|
|
||||||
sub program_help_ok
|
sub program_help_ok
|
||||||
{
|
{
|
||||||
|
local $Test::Builder::Level = $Test::Builder::Level + 1;
|
||||||
my ($cmd) = @_;
|
my ($cmd) = @_;
|
||||||
my ($stdout, $stderr);
|
my ($stdout, $stderr);
|
||||||
print("# Running: $cmd --help\n");
|
print("# Running: $cmd --help\n");
|
||||||
@ -417,6 +421,7 @@ sub program_help_ok
|
|||||||
|
|
||||||
sub program_version_ok
|
sub program_version_ok
|
||||||
{
|
{
|
||||||
|
local $Test::Builder::Level = $Test::Builder::Level + 1;
|
||||||
my ($cmd) = @_;
|
my ($cmd) = @_;
|
||||||
my ($stdout, $stderr);
|
my ($stdout, $stderr);
|
||||||
print("# Running: $cmd --version\n");
|
print("# Running: $cmd --version\n");
|
||||||
@ -430,6 +435,7 @@ sub program_version_ok
|
|||||||
|
|
||||||
sub program_options_handling_ok
|
sub program_options_handling_ok
|
||||||
{
|
{
|
||||||
|
local $Test::Builder::Level = $Test::Builder::Level + 1;
|
||||||
my ($cmd) = @_;
|
my ($cmd) = @_;
|
||||||
my ($stdout, $stderr);
|
my ($stdout, $stderr);
|
||||||
print("# Running: $cmd --not-a-valid-option\n");
|
print("# Running: $cmd --not-a-valid-option\n");
|
||||||
@ -443,6 +449,7 @@ sub program_options_handling_ok
|
|||||||
|
|
||||||
sub command_like
|
sub command_like
|
||||||
{
|
{
|
||||||
|
local $Test::Builder::Level = $Test::Builder::Level + 1;
|
||||||
my ($cmd, $expected_stdout, $test_name) = @_;
|
my ($cmd, $expected_stdout, $test_name) = @_;
|
||||||
my ($stdout, $stderr);
|
my ($stdout, $stderr);
|
||||||
print("# Running: " . join(" ", @{$cmd}) . "\n");
|
print("# Running: " . join(" ", @{$cmd}) . "\n");
|
||||||
@ -455,6 +462,7 @@ sub command_like
|
|||||||
|
|
||||||
sub command_like_safe
|
sub command_like_safe
|
||||||
{
|
{
|
||||||
|
local $Test::Builder::Level = $Test::Builder::Level + 1;
|
||||||
|
|
||||||
# Doesn't rely on detecting end of file on the file descriptors,
|
# Doesn't rely on detecting end of file on the file descriptors,
|
||||||
# which can fail, causing the process to hang, notably on Msys
|
# which can fail, causing the process to hang, notably on Msys
|
||||||
@ -475,6 +483,7 @@ sub command_like_safe
|
|||||||
|
|
||||||
sub command_fails_like
|
sub command_fails_like
|
||||||
{
|
{
|
||||||
|
local $Test::Builder::Level = $Test::Builder::Level + 1;
|
||||||
my ($cmd, $expected_stderr, $test_name) = @_;
|
my ($cmd, $expected_stderr, $test_name) = @_;
|
||||||
my ($stdout, $stderr);
|
my ($stdout, $stderr);
|
||||||
print("# Running: " . join(" ", @{$cmd}) . "\n");
|
print("# Running: " . join(" ", @{$cmd}) . "\n");
|
||||||
@ -493,6 +502,8 @@ sub command_fails_like
|
|||||||
# - test_name: name of test
|
# - test_name: name of test
|
||||||
sub command_checks_all
|
sub command_checks_all
|
||||||
{
|
{
|
||||||
|
local $Test::Builder::Level = $Test::Builder::Level + 1;
|
||||||
|
|
||||||
my ($cmd, $expected_ret, $out, $err, $test_name) = @_;
|
my ($cmd, $expected_ret, $out, $err, $test_name) = @_;
|
||||||
|
|
||||||
# run command
|
# run command
|
||||||
|
@ -38,6 +38,8 @@ our @EXPORT = qw(
|
|||||||
# The second argument is a complementary connection string.
|
# The second argument is a complementary connection string.
|
||||||
sub test_connect_ok
|
sub test_connect_ok
|
||||||
{
|
{
|
||||||
|
local $Test::Builder::Level = $Test::Builder::Level + 1;
|
||||||
|
|
||||||
my ($common_connstr, $connstr, $test_name) = @_;
|
my ($common_connstr, $connstr, $test_name) = @_;
|
||||||
|
|
||||||
my $cmd = [
|
my $cmd = [
|
||||||
@ -52,6 +54,8 @@ sub test_connect_ok
|
|||||||
|
|
||||||
sub test_connect_fails
|
sub test_connect_fails
|
||||||
{
|
{
|
||||||
|
local $Test::Builder::Level = $Test::Builder::Level + 1;
|
||||||
|
|
||||||
my ($common_connstr, $connstr, $expected_stderr, $test_name) = @_;
|
my ($common_connstr, $connstr, $expected_stderr, $test_name) = @_;
|
||||||
|
|
||||||
my $cmd = [
|
my $cmd = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user