Commit 7912f9b7 authored by Peter Eisentraut's avatar Peter Eisentraut

Remove use of TAP subtests

They turned out to be too much of a portability headache, because they
need a fairly new version of Test::More to work properly.
parent e0722d9c
use strict;
use warnings;
use TestLib;
use Test::More tests => 14;
use Test::More tests => 19;
my $tempdir = TestLib::tempdir;
......
......@@ -2,7 +2,7 @@ use strict;
use warnings;
use Cwd;
use TestLib;
use Test::More tests => 28;
use Test::More tests => 33;
program_help_ok('pg_basebackup');
program_version_ok('pg_basebackup');
......
use strict;
use warnings;
use TestLib;
use Test::More tests => 3;
use Test::More tests => 8;
program_help_ok('pg_receivexlog');
program_version_ok('pg_receivexlog');
......
use strict;
use warnings;
use TestLib;
use Test::More tests => 7;
use Test::More tests => 20;
program_help_ok('pg_config');
program_version_ok('pg_config');
......
use strict;
use warnings;
use TestLib;
use Test::More tests => 6;
use Test::More tests => 13;
my $tempdir = TestLib::tempdir;
......
use strict;
use warnings;
use TestLib;
use Test::More tests => 11;
use Test::More tests => 16;
my $tempdir = TestLib::tempdir;
my $tempdir_short = TestLib::tempdir_short;
......
use strict;
use warnings;
use TestLib;
use Test::More tests => 6;
use Test::More tests => 13;
program_help_ok('clusterdb');
program_version_ok('clusterdb');
......
use strict;
use warnings;
use TestLib;
use Test::More tests => 1;
use Test::More tests => 2;
my $tempdir = tempdir;
start_test_server $tempdir;
......
use strict;
use warnings;
use TestLib;
use Test::More tests => 6;
use Test::More tests => 13;
program_help_ok('createdb');
program_version_ok('createdb');
......
use strict;
use warnings;
use TestLib;
use Test::More tests => 6;
use Test::More tests => 14;
program_help_ok('createlang');
program_version_ok('createlang');
......
use strict;
use warnings;
use TestLib;
use Test::More tests => 8;
use Test::More tests => 17;
program_help_ok('createuser');
program_version_ok('createuser');
......
use strict;
use warnings;
use TestLib;
use Test::More tests => 5;
use Test::More tests => 11;
program_help_ok('dropdb');
program_version_ok('dropdb');
......
use strict;
use warnings;
use TestLib;
use Test::More tests => 5;
use Test::More tests => 11;
program_help_ok('droplang');
program_version_ok('droplang');
......
use strict;
use warnings;
use TestLib;
use Test::More tests => 5;
use Test::More tests => 11;
program_help_ok('dropuser');
program_version_ok('dropuser');
......
use strict;
use warnings;
use TestLib;
use Test::More tests => 5;
use Test::More tests => 10;
program_help_ok('pg_isready');
program_version_ok('pg_isready');
......
use strict;
use warnings;
use TestLib;
use Test::More tests => 7;
use Test::More tests => 16;
program_help_ok('reindexdb');
program_version_ok('reindexdb');
......
use strict;
use warnings;
use TestLib;
use Test::More tests => 1;
use Test::More tests => 2;
my $tempdir = tempdir;
start_test_server $tempdir;
......
use strict;
use warnings;
use TestLib;
use Test::More tests => 8;
use Test::More tests => 18;
program_help_ok('vacuumdb');
program_version_ok('vacuumdb');
......
use strict;
use warnings;
use TestLib;
use Test::More tests => 1;
use Test::More tests => 2;
my $tempdir = tempdir;
start_test_server $tempdir;
......
use strict;
use warnings;
use TestLib;
use Test::More tests => 2;
use Test::More tests => 4;
my $tempdir = tempdir;
start_test_server $tempdir;
......
......@@ -37,21 +37,6 @@ BEGIN
{
plan skip_all => "IPC::Run not available";
};
eval {
Test::More->VERSION('0.93_01');
} or do
{
plan skip_all => "version of Test::More is too old to support subplans";
};
eval {
require Test::Simple;
Test::Simple->VERSION('0.98');
} or do
{
plan skip_all => "version of Test::Simple is too old to support subplans properly";
};
}
# Set to untranslated messages, to be able to compare program output
......@@ -180,67 +165,51 @@ sub command_exit_is
sub program_help_ok
{
my ($cmd) = @_;
subtest "$cmd --help" => sub {
plan tests => 3;
my ($stdout, $stderr);
my $result = run [ $cmd, '--help' ], '>', \$stdout, '2>', \$stderr;
ok($result, "$cmd --help exit code 0");
isnt($stdout, '', "$cmd --help goes to stdout");
is($stderr, '', "$cmd --help nothing to stderr");
};
my ($stdout, $stderr);
my $result = run [ $cmd, '--help' ], '>', \$stdout, '2>', \$stderr;
ok($result, "$cmd --help exit code 0");
isnt($stdout, '', "$cmd --help goes to stdout");
is($stderr, '', "$cmd --help nothing to stderr");
}
sub program_version_ok
{
my ($cmd) = @_;
subtest "$cmd --version" => sub {
plan tests => 3;
my ($stdout, $stderr);
my $result = run [ $cmd, '--version' ], '>', \$stdout, '2>', \$stderr;
ok($result, "$cmd --version exit code 0");
isnt($stdout, '', "$cmd --version goes to stdout");
is($stderr, '', "$cmd --version nothing to stderr");
};
my ($stdout, $stderr);
my $result = run [ $cmd, '--version' ], '>', \$stdout, '2>', \$stderr;
ok($result, "$cmd --version exit code 0");
isnt($stdout, '', "$cmd --version goes to stdout");
is($stderr, '', "$cmd --version nothing to stderr");
}
sub program_options_handling_ok
{
my ($cmd) = @_;
subtest "$cmd options handling" => sub {
plan tests => 2;
my ($stdout, $stderr);
my $result = run [ $cmd, '--not-a-valid-option' ], '>', \$stdout,
'2>', \$stderr;
ok(!$result, "$cmd with invalid option nonzero exit code");
isnt($stderr, '', "$cmd with invalid option prints error message");
};
my ($stdout, $stderr);
my $result = run [ $cmd, '--not-a-valid-option' ], '>', \$stdout, '2>', \$stderr;
ok(!$result, "$cmd with invalid option nonzero exit code");
isnt($stderr, '', "$cmd with invalid option prints error message");
}
sub command_like
{
my ($cmd, $expected_stdout, $test_name) = @_;
subtest $test_name => sub {
plan tests => 3;
my ($stdout, $stderr);
my $result = run $cmd, '>', \$stdout, '2>', \$stderr;
ok($result, "@$cmd exit code 0");
is($stderr, '', "@$cmd no stderr");
like($stdout, $expected_stdout, "$test_name: matches");
};
my ($stdout, $stderr);
my $result = run $cmd, '>', \$stdout, '2>', \$stderr;
ok($result, "@$cmd exit code 0");
is($stderr, '', "@$cmd no stderr");
like($stdout, $expected_stdout, "$test_name: matches");
}
sub issues_sql_like
{
my ($cmd, $expected_sql, $test_name) = @_;
subtest $test_name => sub {
plan tests => 2;
my ($stdout, $stderr);
truncate $test_server_logfile, 0;
my $result = run $cmd, '>', \$stdout, '2>', \$stderr;
ok($result, "@$cmd exit code 0");
my $log = `cat '$test_server_logfile'`;
like($log, $expected_sql, "$test_name: SQL found in server log");
};
my ($stdout, $stderr);
truncate $test_server_logfile, 0;
my $result = run $cmd, '>', \$stdout, '2>', \$stderr;
ok($result, "@$cmd exit code 0");
my $log = `cat '$test_server_logfile'`;
like($log, $expected_sql, "$test_name: SQL found in server log");
}
1;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment