From: Peter Eisentraut Date: Wed, 29 Oct 2014 23:41:19 +0000 (-0400) Subject: Remove use of TAP subtests X-Git-Tag: REL9_5_ALPHA1~1289 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7912f9b7dc9e2d3f6cd81892ef6aa797578e9f06;p=postgresql 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. --- diff --git a/src/bin/initdb/t/001_initdb.pl b/src/bin/initdb/t/001_initdb.pl index db92a88a4e..149b3d1bb3 100644 --- a/src/bin/initdb/t/001_initdb.pl +++ b/src/bin/initdb/t/001_initdb.pl @@ -1,7 +1,7 @@ use strict; use warnings; use TestLib; -use Test::More tests => 14; +use Test::More tests => 19; my $tempdir = TestLib::tempdir; diff --git a/src/bin/pg_basebackup/t/010_pg_basebackup.pl b/src/bin/pg_basebackup/t/010_pg_basebackup.pl index 597fb60a52..fa2627b267 100644 --- a/src/bin/pg_basebackup/t/010_pg_basebackup.pl +++ b/src/bin/pg_basebackup/t/010_pg_basebackup.pl @@ -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'); diff --git a/src/bin/pg_basebackup/t/020_pg_receivexlog.pl b/src/bin/pg_basebackup/t/020_pg_receivexlog.pl index 700ae045a1..c68e86d912 100644 --- a/src/bin/pg_basebackup/t/020_pg_receivexlog.pl +++ b/src/bin/pg_basebackup/t/020_pg_receivexlog.pl @@ -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'); diff --git a/src/bin/pg_config/t/001_pg_config.pl b/src/bin/pg_config/t/001_pg_config.pl index c911798dbc..ccca190bb1 100644 --- a/src/bin/pg_config/t/001_pg_config.pl +++ b/src/bin/pg_config/t/001_pg_config.pl @@ -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'); diff --git a/src/bin/pg_controldata/t/001_pg_controldata.pl b/src/bin/pg_controldata/t/001_pg_controldata.pl index 35ad10a25c..a4180e7ed1 100644 --- a/src/bin/pg_controldata/t/001_pg_controldata.pl +++ b/src/bin/pg_controldata/t/001_pg_controldata.pl @@ -1,7 +1,7 @@ use strict; use warnings; use TestLib; -use Test::More tests => 6; +use Test::More tests => 13; my $tempdir = TestLib::tempdir; diff --git a/src/bin/pg_ctl/t/001_start_stop.pl b/src/bin/pg_ctl/t/001_start_stop.pl index 66ff06e3c4..5a95ebda08 100644 --- a/src/bin/pg_ctl/t/001_start_stop.pl +++ b/src/bin/pg_ctl/t/001_start_stop.pl @@ -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; diff --git a/src/bin/scripts/t/010_clusterdb.pl b/src/bin/scripts/t/010_clusterdb.pl index fe22cdbb4e..cb9d04b0fe 100644 --- a/src/bin/scripts/t/010_clusterdb.pl +++ b/src/bin/scripts/t/010_clusterdb.pl @@ -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'); diff --git a/src/bin/scripts/t/011_clusterdb_all.pl b/src/bin/scripts/t/011_clusterdb_all.pl index eb2016497e..7769f70bb1 100644 --- a/src/bin/scripts/t/011_clusterdb_all.pl +++ b/src/bin/scripts/t/011_clusterdb_all.pl @@ -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; diff --git a/src/bin/scripts/t/020_createdb.pl b/src/bin/scripts/t/020_createdb.pl index a8e8f3b4d1..40fbc9278d 100644 --- a/src/bin/scripts/t/020_createdb.pl +++ b/src/bin/scripts/t/020_createdb.pl @@ -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'); diff --git a/src/bin/scripts/t/030_createlang.pl b/src/bin/scripts/t/030_createlang.pl index 292021611b..7ff0a3ed38 100644 --- a/src/bin/scripts/t/030_createlang.pl +++ b/src/bin/scripts/t/030_createlang.pl @@ -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'); diff --git a/src/bin/scripts/t/040_createuser.pl b/src/bin/scripts/t/040_createuser.pl index 8837c2b6e9..4d44e14b7c 100644 --- a/src/bin/scripts/t/040_createuser.pl +++ b/src/bin/scripts/t/040_createuser.pl @@ -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'); diff --git a/src/bin/scripts/t/050_dropdb.pl b/src/bin/scripts/t/050_dropdb.pl index 04a8789d88..3065e5051d 100644 --- a/src/bin/scripts/t/050_dropdb.pl +++ b/src/bin/scripts/t/050_dropdb.pl @@ -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'); diff --git a/src/bin/scripts/t/060_droplang.pl b/src/bin/scripts/t/060_droplang.pl index 09fb2f3b07..6a21d7e33d 100644 --- a/src/bin/scripts/t/060_droplang.pl +++ b/src/bin/scripts/t/060_droplang.pl @@ -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'); diff --git a/src/bin/scripts/t/070_dropuser.pl b/src/bin/scripts/t/070_dropuser.pl index 9e0587d68f..bbb3b7922a 100644 --- a/src/bin/scripts/t/070_dropuser.pl +++ b/src/bin/scripts/t/070_dropuser.pl @@ -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'); diff --git a/src/bin/scripts/t/080_pg_isready.pl b/src/bin/scripts/t/080_pg_isready.pl index 03c3657153..f432505d5c 100644 --- a/src/bin/scripts/t/080_pg_isready.pl +++ b/src/bin/scripts/t/080_pg_isready.pl @@ -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'); diff --git a/src/bin/scripts/t/090_reindexdb.pl b/src/bin/scripts/t/090_reindexdb.pl index 24b927ce22..d5b42dee03 100644 --- a/src/bin/scripts/t/090_reindexdb.pl +++ b/src/bin/scripts/t/090_reindexdb.pl @@ -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'); diff --git a/src/bin/scripts/t/091_reindexdb_all.pl b/src/bin/scripts/t/091_reindexdb_all.pl index 6c5c59e749..ffadf29bc6 100644 --- a/src/bin/scripts/t/091_reindexdb_all.pl +++ b/src/bin/scripts/t/091_reindexdb_all.pl @@ -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; diff --git a/src/bin/scripts/t/100_vacuumdb.pl b/src/bin/scripts/t/100_vacuumdb.pl index 78a40fa791..d6555f5fef 100644 --- a/src/bin/scripts/t/100_vacuumdb.pl +++ b/src/bin/scripts/t/100_vacuumdb.pl @@ -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'); diff --git a/src/bin/scripts/t/101_vacuumdb_all.pl b/src/bin/scripts/t/101_vacuumdb_all.pl index f2120e0bff..e90f321d1e 100644 --- a/src/bin/scripts/t/101_vacuumdb_all.pl +++ b/src/bin/scripts/t/101_vacuumdb_all.pl @@ -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; diff --git a/src/bin/scripts/t/102_vacuumdb_stages.pl b/src/bin/scripts/t/102_vacuumdb_stages.pl index 18d596ea54..1ff05e3c27 100644 --- a/src/bin/scripts/t/102_vacuumdb_stages.pl +++ b/src/bin/scripts/t/102_vacuumdb_stages.pl @@ -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; diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm index fa8e67d004..cdb5e31c36 100644 --- a/src/test/perl/TestLib.pm +++ b/src/test/perl/TestLib.pm @@ -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;