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.
pull/14/head
Peter Eisentraut 11 years ago
parent e0722d9cb5
commit 7912f9b7dc
  1. 2
      src/bin/initdb/t/001_initdb.pl
  2. 2
      src/bin/pg_basebackup/t/010_pg_basebackup.pl
  3. 2
      src/bin/pg_basebackup/t/020_pg_receivexlog.pl
  4. 2
      src/bin/pg_config/t/001_pg_config.pl
  5. 2
      src/bin/pg_controldata/t/001_pg_controldata.pl
  6. 2
      src/bin/pg_ctl/t/001_start_stop.pl
  7. 2
      src/bin/scripts/t/010_clusterdb.pl
  8. 2
      src/bin/scripts/t/011_clusterdb_all.pl
  9. 2
      src/bin/scripts/t/020_createdb.pl
  10. 2
      src/bin/scripts/t/030_createlang.pl
  11. 2
      src/bin/scripts/t/040_createuser.pl
  12. 2
      src/bin/scripts/t/050_dropdb.pl
  13. 2
      src/bin/scripts/t/060_droplang.pl
  14. 2
      src/bin/scripts/t/070_dropuser.pl
  15. 2
      src/bin/scripts/t/080_pg_isready.pl
  16. 2
      src/bin/scripts/t/090_reindexdb.pl
  17. 2
      src/bin/scripts/t/091_reindexdb_all.pl
  18. 2
      src/bin/scripts/t/100_vacuumdb.pl
  19. 2
      src/bin/scripts/t/101_vacuumdb_all.pl
  20. 2
      src/bin/scripts/t/102_vacuumdb_stages.pl
  21. 81
      src/test/perl/TestLib.pm

@ -1,7 +1,7 @@
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');

@ -1,7 +1,7 @@
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');

@ -1,7 +1,7 @@
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');

@ -1,7 +1,7 @@
use strict;
use warnings;
use TestLib;
use Test::More tests => 6;
use Test::More tests => 13;
my $tempdir = TestLib::tempdir;

@ -1,7 +1,7 @@
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;

@ -1,7 +1,7 @@
use strict;
use warnings;
use TestLib;
use Test::More tests => 6;
use Test::More tests => 13;
program_help_ok('clusterdb');
program_version_ok('clusterdb');

@ -1,7 +1,7 @@
use strict;
use warnings;
use TestLib;
use Test::More tests => 1;
use Test::More tests => 2;
my $tempdir = tempdir;
start_test_server $tempdir;

@ -1,7 +1,7 @@
use strict;
use warnings;
use TestLib;
use Test::More tests => 6;
use Test::More tests => 13;
program_help_ok('createdb');
program_version_ok('createdb');

@ -1,7 +1,7 @@
use strict;
use warnings;
use TestLib;
use Test::More tests => 6;
use Test::More tests => 14;
program_help_ok('createlang');
program_version_ok('createlang');

@ -1,7 +1,7 @@
use strict;
use warnings;
use TestLib;
use Test::More tests => 8;
use Test::More tests => 17;
program_help_ok('createuser');
program_version_ok('createuser');

@ -1,7 +1,7 @@
use strict;
use warnings;
use TestLib;
use Test::More tests => 5;
use Test::More tests => 11;
program_help_ok('dropdb');
program_version_ok('dropdb');

@ -1,7 +1,7 @@
use strict;
use warnings;
use TestLib;
use Test::More tests => 5;
use Test::More tests => 11;
program_help_ok('droplang');
program_version_ok('droplang');

@ -1,7 +1,7 @@
use strict;
use warnings;
use TestLib;
use Test::More tests => 5;
use Test::More tests => 11;
program_help_ok('dropuser');
program_version_ok('dropuser');

@ -1,7 +1,7 @@
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');

@ -1,7 +1,7 @@
use strict;
use warnings;
use TestLib;
use Test::More tests => 7;
use Test::More tests => 16;
program_help_ok('reindexdb');
program_version_ok('reindexdb');

@ -1,7 +1,7 @@
use strict;
use warnings;
use TestLib;
use Test::More tests => 1;
use Test::More tests => 2;
my $tempdir = tempdir;
start_test_server $tempdir;

@ -1,7 +1,7 @@
use strict;
use warnings;
use TestLib;
use Test::More tests => 8;
use Test::More tests => 18;
program_help_ok('vacuumdb');
program_version_ok('vacuumdb');

@ -1,7 +1,7 @@
use strict;
use warnings;
use TestLib;
use Test::More tests => 1;
use Test::More tests => 2;
my $tempdir = tempdir;
start_test_server $tempdir;

@ -1,7 +1,7 @@
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;

Loading…
Cancel
Save