From 3ecd11576b7cc3bc5f80b9dc9722068a074fc412 Mon Sep 17 00:00:00 2001
From: Daniel Gustafsson <daniel@yesql.se>
Date: Wed, 2 Feb 2022 17:25:37 +0100
Subject: [PATCH] Replace Test::More plans with done_testing

Rather than doing book keeping to plan the number of tests to run in
each TAP suite, conclude each run with done_testing() which sums up
the number of tests that ran.
---
 contrib/amcheck/t/001_verify_heapam.pl        |  4 +-
 contrib/amcheck/t/002_cic.pl                  |  2 +-
 contrib/amcheck/t/003_cic_2pc.pl              |  2 +-
 contrib/auto_explain/t/001_auto_explain.pl    |  4 +-
 contrib/bloom/t/001_wal.pl                    |  4 +-
 contrib/oid2name/t/001_basic.pl               |  4 +-
 contrib/test_decoding/t/001_repl_stats.pl     |  4 +-
 contrib/vacuumlo/t/001_basic.pl               |  4 +-
 src/bin/initdb/t/001_initdb.pl                |  4 +-
 src/bin/pg_amcheck/t/001_basic.pl             |  4 +-
 src/bin/pg_amcheck/t/002_nonesuch.pl          |  4 +-
 src/bin/pg_amcheck/t/003_check.pl             |  4 +-
 src/bin/pg_amcheck/t/004_verify_heapam.pl     |  3 +-
 src/bin/pg_amcheck/t/005_opclass_damage.pl    |  4 +-
 .../t/010_pg_archivecleanup.pl                |  4 +-
 src/bin/pg_basebackup/t/020_pg_receivewal.pl  |  4 +-
 src/bin/pg_basebackup/t/030_pg_recvlogical.pl |  4 +-
 src/bin/pg_checksums/t/001_basic.pl           |  4 +-
 src/bin/pg_checksums/t/002_actions.pl         |  4 +-
 src/bin/pg_config/t/001_pg_config.pl          |  4 +-
 .../pg_controldata/t/001_pg_controldata.pl    |  4 +-
 src/bin/pg_ctl/t/001_start_stop.pl            |  4 +-
 src/bin/pg_ctl/t/002_status.pl                |  4 +-
 src/bin/pg_ctl/t/003_promote.pl               |  4 +-
 src/bin/pg_ctl/t/004_logrotate.pl             |  4 +-
 src/bin/pg_dump/t/001_basic.pl                |  4 +-
 src/bin/pg_dump/t/002_pg_dump.pl              | 78 +------------------
 src/bin/pg_dump/t/003_pg_dump_with_server.pl  |  4 +-
 src/bin/pg_dump/t/010_dump_connstr.pl         |  6 +-
 src/bin/pg_resetwal/t/001_basic.pl            |  4 +-
 src/bin/pg_resetwal/t/002_corrupted.pl        |  4 +-
 src/bin/pg_rewind/t/001_basic.pl              |  4 +-
 src/bin/pg_rewind/t/002_databases.pl          |  4 +-
 src/bin/pg_rewind/t/003_extrafiles.pl         |  4 +-
 src/bin/pg_rewind/t/004_pg_xlog_symlink.pl    |  4 +-
 src/bin/pg_rewind/t/005_same_timeline.pl      |  5 +-
 src/bin/pg_rewind/t/006_options.pl            |  4 +-
 src/bin/pg_rewind/t/007_standby_source.pl     |  4 +-
 src/bin/pg_rewind/t/008_min_recovery_point.pl |  4 +-
 src/bin/pg_test_fsync/t/001_basic.pl          |  4 +-
 src/bin/pg_test_timing/t/001_basic.pl         |  4 +-
 src/bin/pg_verifybackup/t/001_basic.pl        |  4 +-
 src/bin/pg_verifybackup/t/002_algorithm.pl    |  4 +-
 src/bin/pg_verifybackup/t/003_corruption.pl   |  4 +-
 src/bin/pg_verifybackup/t/004_options.pl      |  4 +-
 src/bin/pg_verifybackup/t/005_bad_manifest.pl |  4 +-
 src/bin/pg_verifybackup/t/006_encoding.pl     |  4 +-
 src/bin/pg_verifybackup/t/007_wal.pl          |  4 +-
 src/bin/pg_verifybackup/t/008_untar.pl        |  4 +-
 src/bin/pg_verifybackup/t/009_extract.pl      |  4 +-
 src/bin/pg_waldump/t/001_basic.pl             |  4 +-
 src/bin/psql/t/001_basic.pl                   |  4 +-
 src/bin/psql/t/020_cancel.pl                  |  4 +-
 src/bin/scripts/t/010_clusterdb.pl            |  4 +-
 src/bin/scripts/t/011_clusterdb_all.pl        |  4 +-
 src/bin/scripts/t/020_createdb.pl             |  4 +-
 src/bin/scripts/t/040_createuser.pl           |  4 +-
 src/bin/scripts/t/050_dropdb.pl               |  4 +-
 src/bin/scripts/t/070_dropuser.pl             |  4 +-
 src/bin/scripts/t/080_pg_isready.pl           |  4 +-
 src/bin/scripts/t/090_reindexdb.pl            |  4 +-
 src/bin/scripts/t/091_reindexdb_all.pl        |  4 +-
 src/bin/scripts/t/100_vacuumdb.pl             |  4 +-
 src/bin/scripts/t/101_vacuumdb_all.pl         |  4 +-
 src/bin/scripts/t/102_vacuumdb_stages.pl      |  4 +-
 src/bin/scripts/t/200_connstr.pl              |  4 +-
 src/test/authentication/t/001_password.pl     |  7 +-
 src/test/authentication/t/002_saslprep.pl     |  6 +-
 src/test/kerberos/t/001_auth.pl               |  8 +-
 src/test/ldap/t/001_auth.pl                   |  8 +-
 src/test/modules/brin/t/01_workitems.pl       |  4 +-
 src/test/modules/commit_ts/t/001_base.pl      |  4 +-
 src/test/modules/commit_ts/t/002_standby.pl   |  4 +-
 src/test/modules/commit_ts/t/003_standby_2.pl |  4 +-
 src/test/modules/commit_ts/t/004_restart.pl   |  4 +-
 .../test_misc/t/001_constraint_validation.pl  |  4 +-
 .../modules/test_misc/t/002_tablespace.pl     |  4 +-
 src/test/modules/test_pg_dump/t/001_base.pl   | 40 +---------
 src/test/perl/README                          |  7 +-
 src/test/recovery/t/001_stream_rep.pl         |  4 +-
 src/test/recovery/t/002_archiving.pl          |  4 +-
 src/test/recovery/t/003_recovery_targets.pl   |  4 +-
 src/test/recovery/t/004_timeline_switch.pl    |  4 +-
 src/test/recovery/t/005_replay_delay.pl       |  4 +-
 src/test/recovery/t/006_logical_decoding.pl   |  4 +-
 src/test/recovery/t/007_sync_rep.pl           |  4 +-
 src/test/recovery/t/008_fsm_truncation.pl     |  4 +-
 src/test/recovery/t/009_twophase.pl           |  4 +-
 .../t/010_logical_decoding_timelines.pl       |  4 +-
 src/test/recovery/t/011_crash_recovery.pl     |  4 +-
 src/test/recovery/t/012_subtransactions.pl    |  4 +-
 src/test/recovery/t/013_crash_restart.pl      |  5 +-
 src/test/recovery/t/014_unlogged_reinit.pl    |  4 +-
 src/test/recovery/t/015_promotion_pages.pl    |  4 +-
 src/test/recovery/t/016_min_consistency.pl    |  4 +-
 src/test/recovery/t/017_shm.pl                |  6 +-
 src/test/recovery/t/018_wal_optimize.pl       |  4 +-
 src/test/recovery/t/019_replslot_limit.pl     |  4 +-
 src/test/recovery/t/020_archive_status.pl     |  4 +-
 src/test/recovery/t/021_row_visibility.pl     |  4 +-
 src/test/recovery/t/022_crash_temp_files.pl   |  7 +-
 src/test/recovery/t/023_pitr_prepared_xact.pl |  4 +-
 src/test/recovery/t/024_archive_recovery.pl   |  4 +-
 .../recovery/t/025_stuck_on_old_timeline.pl   |  4 +-
 .../recovery/t/026_overwrite_contrecord.pl    |  4 +-
 src/test/recovery/t/027_stream_regress.pl     |  6 +-
 src/test/ssl/t/001_ssltests.pl                |  6 +-
 src/test/ssl/t/002_scram.pl                   |  4 +-
 src/test/ssl/t/003_sslinfo.pl                 |  6 +-
 src/test/subscription/t/001_rep_changes.pl    |  4 +-
 src/test/subscription/t/002_types.pl          |  4 +-
 src/test/subscription/t/003_constraints.pl    |  4 +-
 src/test/subscription/t/004_sync.pl           |  4 +-
 src/test/subscription/t/005_encoding.pl       |  4 +-
 src/test/subscription/t/006_rewrite.pl        |  4 +-
 src/test/subscription/t/007_ddl.pl            |  4 +-
 src/test/subscription/t/008_diff_schema.pl    |  4 +-
 src/test/subscription/t/009_matviews.pl       |  4 +-
 src/test/subscription/t/010_truncate.pl       |  4 +-
 src/test/subscription/t/011_generated.pl      |  4 +-
 src/test/subscription/t/012_collation.pl      |  8 +-
 src/test/subscription/t/013_partition.pl      |  4 +-
 src/test/subscription/t/014_binary.pl         |  4 +-
 src/test/subscription/t/015_stream.pl         |  4 +-
 src/test/subscription/t/016_stream_subxact.pl |  4 +-
 src/test/subscription/t/017_stream_ddl.pl     |  4 +-
 .../t/018_stream_subxact_abort.pl             |  4 +-
 .../t/019_stream_subxact_ddl_abort.pl         |  4 +-
 src/test/subscription/t/020_messages.pl       |  4 +-
 src/test/subscription/t/021_twophase.pl       |  4 +-
 .../subscription/t/022_twophase_cascade.pl    |  4 +-
 .../subscription/t/023_twophase_stream.pl     |  4 +-
 src/test/subscription/t/024_add_drop_pub.pl   |  4 +-
 .../t/025_rep_changes_for_schema.pl           |  4 +-
 src/test/subscription/t/026_worker_stats.pl   |  4 +-
 src/test/subscription/t/027_nosuperuser.pl    |  4 +-
 src/test/subscription/t/100_bugs.pl           |  4 +-
 137 files changed, 388 insertions(+), 300 deletions(-)

diff --git a/contrib/amcheck/t/001_verify_heapam.pl b/contrib/amcheck/t/001_verify_heapam.pl
index 39c11634b8..bb0997cd5d 100644
--- a/contrib/amcheck/t/001_verify_heapam.pl
+++ b/contrib/amcheck/t/001_verify_heapam.pl
@@ -8,7 +8,7 @@ use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
 
 use Fcntl qw(:seek);
-use Test::More tests => 272;
+use Test::More;
 
 my ($node, $result);
 
@@ -283,3 +283,5 @@ sub check_all_options_uncorrupted
 		}
 	}
 }
+
+done_testing();
diff --git a/contrib/amcheck/t/002_cic.pl b/contrib/amcheck/t/002_cic.pl
index f6b91e89ad..d604def0d0 100644
--- a/contrib/amcheck/t/002_cic.pl
+++ b/contrib/amcheck/t/002_cic.pl
@@ -9,7 +9,7 @@ use Config;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
 
-use Test::More tests => 3;
+use Test::More;
 
 my ($node, $result);
 
diff --git a/contrib/amcheck/t/003_cic_2pc.pl b/contrib/amcheck/t/003_cic_2pc.pl
index 2f804efb84..6d871e2795 100644
--- a/contrib/amcheck/t/003_cic_2pc.pl
+++ b/contrib/amcheck/t/003_cic_2pc.pl
@@ -9,7 +9,7 @@ use Config;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
 
-use Test::More tests => 5;
+use Test::More;
 
 local $TODO = 'filesystem bug' if PostgreSQL::Test::Utils::has_wal_read_bug;
 
diff --git a/contrib/auto_explain/t/001_auto_explain.pl b/contrib/auto_explain/t/001_auto_explain.pl
index 1fbfd6d1dd..82e4d9d15c 100644
--- a/contrib/auto_explain/t/001_auto_explain.pl
+++ b/contrib/auto_explain/t/001_auto_explain.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 4;
+use Test::More;
 
 my $node = PostgreSQL::Test::Cluster->new('main');
 $node->init;
@@ -53,3 +53,5 @@ like(
 	$log_contents,
 	qr/"Node Type": "Index Scan"[^}]*"Index Name": "pg_class_relname_nsp_index"/s,
 	"index scan logged, json mode");
+
+done_testing();
diff --git a/contrib/bloom/t/001_wal.pl b/contrib/bloom/t/001_wal.pl
index 06e664688a..9416a64dbd 100644
--- a/contrib/bloom/t/001_wal.pl
+++ b/contrib/bloom/t/001_wal.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 31;
+use Test::More;
 
 my $node_primary;
 my $node_standby;
@@ -80,3 +80,5 @@ for my $i (1 .. 10)
 	);
 	test_index_replay("insert $i");
 }
+
+done_testing();
diff --git a/contrib/oid2name/t/001_basic.pl b/contrib/oid2name/t/001_basic.pl
index e38d893b9b..671bdbde14 100644
--- a/contrib/oid2name/t/001_basic.pl
+++ b/contrib/oid2name/t/001_basic.pl
@@ -5,7 +5,7 @@ use strict;
 use warnings;
 
 use PostgreSQL::Test::Utils;
-use Test::More tests => 8;
+use Test::More;
 
 #########################################
 # Basic checks
@@ -13,3 +13,5 @@ use Test::More tests => 8;
 program_help_ok('oid2name');
 program_version_ok('oid2name');
 program_options_handling_ok('oid2name');
+
+done_testing();
diff --git a/contrib/test_decoding/t/001_repl_stats.pl b/contrib/test_decoding/t/001_repl_stats.pl
index 36fb36e665..fd82244a15 100644
--- a/contrib/test_decoding/t/001_repl_stats.pl
+++ b/contrib/test_decoding/t/001_repl_stats.pl
@@ -8,7 +8,7 @@ use warnings;
 use File::Path qw(rmtree);
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 2;
+use Test::More;
 
 # Test set-up
 my $node = PostgreSQL::Test::Cluster->new('test');
@@ -118,3 +118,5 @@ $node->safe_psql('postgres',
 
 # shutdown
 $node->stop;
+
+done_testing();
diff --git a/contrib/vacuumlo/t/001_basic.pl b/contrib/vacuumlo/t/001_basic.pl
index b7a84cf92e..f4bfb2a1c3 100644
--- a/contrib/vacuumlo/t/001_basic.pl
+++ b/contrib/vacuumlo/t/001_basic.pl
@@ -5,8 +5,10 @@ use strict;
 use warnings;
 
 use PostgreSQL::Test::Utils;
-use Test::More tests => 8;
+use Test::More;
 
 program_help_ok('vacuumlo');
 program_version_ok('vacuumlo');
 program_options_handling_ok('vacuumlo');
+
+done_testing();
diff --git a/src/bin/initdb/t/001_initdb.pl b/src/bin/initdb/t/001_initdb.pl
index 02bc688a3b..7dc8cdd855 100644
--- a/src/bin/initdb/t/001_initdb.pl
+++ b/src/bin/initdb/t/001_initdb.pl
@@ -11,7 +11,7 @@ use Fcntl ':mode';
 use File::stat qw{lstat};
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 22;
+use Test::More;
 
 my $tempdir = PostgreSQL::Test::Utils::tempdir;
 my $xlogdir = "$tempdir/pgxlog";
@@ -92,3 +92,5 @@ SKIP:
 	ok(check_mode_recursive($datadir_group, 0750, 0640),
 		'check PGDATA permissions');
 }
+
+done_testing();
diff --git a/src/bin/pg_amcheck/t/001_basic.pl b/src/bin/pg_amcheck/t/001_basic.pl
index 4bb9d91dfb..e27312862e 100644
--- a/src/bin/pg_amcheck/t/001_basic.pl
+++ b/src/bin/pg_amcheck/t/001_basic.pl
@@ -5,8 +5,10 @@ use strict;
 use warnings;
 
 use PostgreSQL::Test::Utils;
-use Test::More tests => 8;
+use Test::More;
 
 program_help_ok('pg_amcheck');
 program_version_ok('pg_amcheck');
 program_options_handling_ok('pg_amcheck');
+
+done_testing();
diff --git a/src/bin/pg_amcheck/t/002_nonesuch.pl b/src/bin/pg_amcheck/t/002_nonesuch.pl
index 8d7bd7ebcc..56d55199f8 100644
--- a/src/bin/pg_amcheck/t/002_nonesuch.pl
+++ b/src/bin/pg_amcheck/t/002_nonesuch.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 76;
+use Test::More;
 
 # Test set-up
 my ($node, $port);
@@ -268,3 +268,5 @@ $node->command_checks_all(
 		qr/pg_amcheck: error: no relations to check/
 	],
 	'schema exclusion pattern overrides all inclusion patterns');
+
+done_testing();
diff --git a/src/bin/pg_amcheck/t/003_check.pl b/src/bin/pg_amcheck/t/003_check.pl
index 9df027b37f..d984eacb24 100644
--- a/src/bin/pg_amcheck/t/003_check.pl
+++ b/src/bin/pg_amcheck/t/003_check.pl
@@ -8,7 +8,7 @@ use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
 
 use Fcntl qw(:seek);
-use Test::More tests => 63;
+use Test::More;
 
 my ($node, $port, %corrupt_page, %remove_relation);
 
@@ -517,3 +517,5 @@ $node->command_checks_all(
 	[ @cmd, '-d', 'db1', '-d', 'db2', '-d', 'db3', '-S', 's*' ],
 	0, [$no_output_re], [$no_output_re],
 	'pg_amcheck excluding all corrupt schemas');
+
+done_testing();
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index 84e7586276..94d691a614 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -297,7 +297,6 @@ close($file)
 $node->start;
 
 # Ok, Xids and page layout look ok.  We can run corruption tests.
-plan tests => 19;
 
 # Check that pg_amcheck runs against the uncorrupted table without error.
 $node->command_ok(
@@ -528,3 +527,5 @@ $node->command_checks_all(
 
 $node->teardown_node;
 $node->clean_node;
+
+done_testing();
diff --git a/src/bin/pg_amcheck/t/005_opclass_damage.pl b/src/bin/pg_amcheck/t/005_opclass_damage.pl
index d81c9583de..a5e8208270 100644
--- a/src/bin/pg_amcheck/t/005_opclass_damage.pl
+++ b/src/bin/pg_amcheck/t/005_opclass_damage.pl
@@ -8,7 +8,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 5;
+use Test::More;
 
 my $node = PostgreSQL::Test::Cluster->new('test');
 $node->init;
@@ -57,3 +57,5 @@ $node->command_checks_all(
 	[],
 	'pg_amcheck all schemas, tables and indexes reports fickleidx corruption'
 );
+
+done_testing();
diff --git a/src/bin/pg_archivecleanup/t/010_pg_archivecleanup.pl b/src/bin/pg_archivecleanup/t/010_pg_archivecleanup.pl
index 60331e0a17..4894a2e483 100644
--- a/src/bin/pg_archivecleanup/t/010_pg_archivecleanup.pl
+++ b/src/bin/pg_archivecleanup/t/010_pg_archivecleanup.pl
@@ -4,7 +4,7 @@
 use strict;
 use warnings;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 42;
+use Test::More;
 
 program_help_ok('pg_archivecleanup');
 program_version_ok('pg_archivecleanup');
@@ -101,3 +101,5 @@ sub run_check
 run_check('',                 'pg_archivecleanup');
 run_check('.partial',         'pg_archivecleanup with .partial file');
 run_check('.00000020.backup', 'pg_archivecleanup with .backup file');
+
+done_testing();
diff --git a/src/bin/pg_basebackup/t/020_pg_receivewal.pl b/src/bin/pg_basebackup/t/020_pg_receivewal.pl
index 98dbdab595..0e6e685aa6 100644
--- a/src/bin/pg_basebackup/t/020_pg_receivewal.pl
+++ b/src/bin/pg_basebackup/t/020_pg_receivewal.pl
@@ -5,7 +5,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Utils;
 use PostgreSQL::Test::Cluster;
-use Test::More tests => 42;
+use Test::More;
 
 program_help_ok('pg_receivewal');
 program_version_ok('pg_receivewal');
@@ -334,3 +334,5 @@ ok(-e "$timeline_dir/$walfile_after_promotion",
 	"WAL segment $walfile_after_promotion archived after timeline jump");
 ok(-e "$timeline_dir/00000002.history",
 	"timeline history file archived after timeline jump");
+
+done_testing();
diff --git a/src/bin/pg_basebackup/t/030_pg_recvlogical.pl b/src/bin/pg_basebackup/t/030_pg_recvlogical.pl
index 64f2f571fd..201196f957 100644
--- a/src/bin/pg_basebackup/t/030_pg_recvlogical.pl
+++ b/src/bin/pg_basebackup/t/030_pg_recvlogical.pl
@@ -5,7 +5,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Utils;
 use PostgreSQL::Test::Cluster;
-use Test::More tests => 20;
+use Test::More;
 
 program_help_ok('pg_recvlogical');
 program_version_ok('pg_recvlogical');
@@ -106,3 +106,5 @@ $node->command_ok(
 		'--start', '--endpos', "$nextlsn", '--no-loop', '-f', '-'
 	],
 	'replayed a two-phase transaction');
+
+done_testing();
diff --git a/src/bin/pg_checksums/t/001_basic.pl b/src/bin/pg_checksums/t/001_basic.pl
index fd03e8df0f..d7cede111e 100644
--- a/src/bin/pg_checksums/t/001_basic.pl
+++ b/src/bin/pg_checksums/t/001_basic.pl
@@ -4,8 +4,10 @@
 use strict;
 use warnings;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 8;
+use Test::More;
 
 program_help_ok('pg_checksums');
 program_version_ok('pg_checksums');
 program_options_handling_ok('pg_checksums');
+
+done_testing();
diff --git a/src/bin/pg_checksums/t/002_actions.pl b/src/bin/pg_checksums/t/002_actions.pl
index 7b515dfc6d..5563244f11 100644
--- a/src/bin/pg_checksums/t/002_actions.pl
+++ b/src/bin/pg_checksums/t/002_actions.pl
@@ -11,7 +11,7 @@ use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
 
 use Fcntl qw(:seek);
-use Test::More tests => 66;
+use Test::More;
 
 
 # Utility routine to create and check a table with corrupted checksums
@@ -257,3 +257,5 @@ fail_corrupt($node, "99990_vm");
 fail_corrupt($node, "99990_init.123");
 fail_corrupt($node, "99990_fsm.123");
 fail_corrupt($node, "99990_vm.123");
+
+done_testing();
diff --git a/src/bin/pg_config/t/001_pg_config.pl b/src/bin/pg_config/t/001_pg_config.pl
index cff4d6ebc9..9a89109068 100644
--- a/src/bin/pg_config/t/001_pg_config.pl
+++ b/src/bin/pg_config/t/001_pg_config.pl
@@ -4,7 +4,7 @@
 use strict;
 use warnings;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 20;
+use Test::More;
 
 program_help_ok('pg_config');
 program_version_ok('pg_config');
@@ -17,3 +17,5 @@ command_like([ 'pg_config', '--libdir', '--bindir' ],
 	qr/lib.*\n.*bin/, 'pg_config two options different order');
 command_like(['pg_config'], qr/.*\n.*\n.*/,
 	'pg_config without options prints many lines');
+
+done_testing();
diff --git a/src/bin/pg_controldata/t/001_pg_controldata.pl b/src/bin/pg_controldata/t/001_pg_controldata.pl
index 2f02966bf4..adb9af4e93 100644
--- a/src/bin/pg_controldata/t/001_pg_controldata.pl
+++ b/src/bin/pg_controldata/t/001_pg_controldata.pl
@@ -5,7 +5,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 17;
+use Test::More;
 
 program_help_ok('pg_controldata');
 program_version_ok('pg_controldata');
@@ -42,3 +42,5 @@ command_checks_all(
 	],
 	[qr/^$/],
 	'pg_controldata with corrupted pg_control');
+
+done_testing();
diff --git a/src/bin/pg_ctl/t/001_start_stop.pl b/src/bin/pg_ctl/t/001_start_stop.pl
index a084d09cd4..7d3fbc3f6a 100644
--- a/src/bin/pg_ctl/t/001_start_stop.pl
+++ b/src/bin/pg_ctl/t/001_start_stop.pl
@@ -9,7 +9,7 @@ use Fcntl ':mode';
 use File::stat qw{lstat};
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 24;
+use Test::More;
 
 my $tempdir       = PostgreSQL::Test::Utils::tempdir;
 my $tempdir_short = PostgreSQL::Test::Utils::tempdir_short;
@@ -111,3 +111,5 @@ command_ok([ 'pg_ctl', 'restart', '-D', "$tempdir/data" ],
 	'pg_ctl restart with server running');
 
 system_or_bail 'pg_ctl', 'stop', '-D', "$tempdir/data";
+
+done_testing();
diff --git a/src/bin/pg_ctl/t/002_status.pl b/src/bin/pg_ctl/t/002_status.pl
index 38c901f88a..2503d74a76 100644
--- a/src/bin/pg_ctl/t/002_status.pl
+++ b/src/bin/pg_ctl/t/002_status.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 3;
+use Test::More;
 
 my $tempdir       = PostgreSQL::Test::Utils::tempdir;
 
@@ -25,3 +25,5 @@ command_exit_is([ 'pg_ctl', 'status', '-D', $node->data_dir ],
 	0, 'pg_ctl status with server running');
 
 system_or_bail 'pg_ctl', 'stop', '-D', $node->data_dir;
+
+done_testing();
diff --git a/src/bin/pg_ctl/t/003_promote.pl b/src/bin/pg_ctl/t/003_promote.pl
index b14bf1d7b0..84d28f4c77 100644
--- a/src/bin/pg_ctl/t/003_promote.pl
+++ b/src/bin/pg_ctl/t/003_promote.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 12;
+use Test::More;
 
 my $tempdir = PostgreSQL::Test::Utils::tempdir;
 
@@ -62,3 +62,5 @@ command_ok([ 'pg_ctl', '-D', $node_standby->data_dir, 'promote' ],
 
 is($node_standby->safe_psql('postgres', 'SELECT pg_is_in_recovery()'),
 	'f', 'promoted standby is not in recovery');
+
+done_testing();
diff --git a/src/bin/pg_ctl/t/004_logrotate.pl b/src/bin/pg_ctl/t/004_logrotate.pl
index de6028760d..d290452100 100644
--- a/src/bin/pg_ctl/t/004_logrotate.pl
+++ b/src/bin/pg_ctl/t/004_logrotate.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 14;
+use Test::More;
 use Time::HiRes qw(usleep);
 
 # Extract the file name of a $format from the contents of
@@ -136,3 +136,5 @@ check_log_pattern('csvlog',  $new_current_logfiles, 'syntax error', $node);
 check_log_pattern('jsonlog', $new_current_logfiles, 'syntax error', $node);
 
 $node->stop();
+
+done_testing();
diff --git a/src/bin/pg_dump/t/001_basic.pl b/src/bin/pg_dump/t/001_basic.pl
index d53bef9aa7..48faeb4371 100644
--- a/src/bin/pg_dump/t/001_basic.pl
+++ b/src/bin/pg_dump/t/001_basic.pl
@@ -7,7 +7,7 @@ use warnings;
 use Config;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 82;
+use Test::More;
 
 my $tempdir       = PostgreSQL::Test::Utils::tempdir;
 
@@ -188,3 +188,5 @@ command_fails_like(
 	qr/\Qpg_dumpall: error: option --exclude-database cannot be used together with -g\/--globals-only\E/,
 	'pg_dumpall: option --exclude-database cannot be used together with -g/--globals-only'
 );
+
+done_testing();
diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl
index 39fa1952e7..dd065c758f 100644
--- a/src/bin/pg_dump/t/002_pg_dump.pl
+++ b/src/bin/pg_dump/t/002_pg_dump.pl
@@ -3714,82 +3714,6 @@ my $supports_lz4 = check_pg_config("#define HAVE_LIBLZ4 1");
 $node->psql('postgres', 'create database regress_pg_dump_test;');
 $node->psql('postgres', 'create database regress_public_owner;');
 
-# Start with number of command_fails_like()*2 tests below (each
-# command_fails_like is actually 2 tests)
-my $num_tests = 12;
-
-foreach my $run (sort keys %pgdump_runs)
-{
-	my $test_key = $run;
-	my $run_db   = 'postgres';
-
-	if (defined($pgdump_runs{$run}->{database}))
-	{
-		$run_db = $pgdump_runs{$run}->{database};
-	}
-
-	# Each run of pg_dump is a test itself
-	$num_tests++;
-
-	# If there is a restore cmd, that's another test
-	if ($pgdump_runs{$run}->{restore_cmd})
-	{
-		$num_tests++;
-	}
-
-	if ($pgdump_runs{$run}->{test_key})
-	{
-		$test_key = $pgdump_runs{$run}->{test_key};
-	}
-
-	# Then count all the tests run against each run
-	foreach my $test (sort keys %tests)
-	{
-
-		# postgres is the default database, if it isn't overridden
-		my $test_db = 'postgres';
-
-		# Specific tests can override the database to use
-		if (defined($tests{$test}->{database}))
-		{
-			$test_db = $tests{$test}->{database};
-		}
-
-		# The database to test against needs to match the database the run is
-		# for, so skip combinations where they don't match up.
-		if ($run_db ne $test_db)
-		{
-			next;
-		}
-
-		# Skip any collation-related commands if there is no collation support
-		if (!$collation_support && defined($tests{$test}->{collation}))
-		{
-			next;
-		}
-
-		# Skip tests specific to LZ4 if this build does not support
-		# this option.
-		if (!$supports_lz4 && defined($tests{$test}->{lz4}))
-		{
-			next;
-		}
-
-		# If there is a like entry, but no unlike entry, then we will test the like case
-		if ($tests{$test}->{like}->{$test_key}
-			&& !defined($tests{$test}->{unlike}->{$test_key}))
-		{
-			$num_tests++;
-		}
-		else
-		{
-			# We will test everything that isn't a 'like'
-			$num_tests++;
-		}
-	}
-}
-plan tests => $num_tests;
-
 #########################################
 # Set up schemas, tables, etc, to be dumped.
 
@@ -3975,3 +3899,5 @@ foreach my $run (sort keys %pgdump_runs)
 # Stop the database instance, which will be removed at the end of the tests.
 
 $node->stop('fast');
+
+done_testing();
diff --git a/src/bin/pg_dump/t/003_pg_dump_with_server.pl b/src/bin/pg_dump/t/003_pg_dump_with_server.pl
index 43c9a9fbf8..528db179cb 100644
--- a/src/bin/pg_dump/t/003_pg_dump_with_server.pl
+++ b/src/bin/pg_dump/t/003_pg_dump_with_server.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 3;
+use Test::More;
 
 my $tempdir       = PostgreSQL::Test::Utils::tempdir;
 
@@ -36,3 +36,5 @@ command_fails_like(
 command_ok(
 	[ "pg_dump", '-p', $port, '-a', '--include-foreign-data=s2', 'postgres' ],
 	"dump foreign server with no tables");
+
+done_testing();
diff --git a/src/bin/pg_dump/t/010_dump_connstr.pl b/src/bin/pg_dump/t/010_dump_connstr.pl
index 2f7919a4b3..7a745ade0f 100644
--- a/src/bin/pg_dump/t/010_dump_connstr.pl
+++ b/src/bin/pg_dump/t/010_dump_connstr.pl
@@ -12,10 +12,6 @@ if ($PostgreSQL::Test::Utils::is_msys2)
 {
 	plan skip_all => 'High bit name tests fail on Msys2';
 }
-else
-{
-	plan tests => 14;
-}
 
 # We're going to use byte sequences that aren't valid UTF-8 strings.  Use
 # LATIN1, which accepts any byte and has a conversion from each byte to UTF-8.
@@ -229,3 +225,5 @@ $cmdline_node->run_log(
 ok($result,
 	'restore full dump with command-line options for connection parameters');
 is($stderr, '', 'no dump errors');
+
+done_testing();
diff --git a/src/bin/pg_resetwal/t/001_basic.pl b/src/bin/pg_resetwal/t/001_basic.pl
index f9a5e02db2..b4b192c86c 100644
--- a/src/bin/pg_resetwal/t/001_basic.pl
+++ b/src/bin/pg_resetwal/t/001_basic.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 12;
+use Test::More;
 
 program_help_ok('pg_resetwal');
 program_version_ok('pg_resetwal');
@@ -28,3 +28,5 @@ SKIP:
 	ok(check_mode_recursive($node->data_dir, 0700, 0600),
 		'check PGDATA permissions');
 }
+
+done_testing();
diff --git a/src/bin/pg_resetwal/t/002_corrupted.pl b/src/bin/pg_resetwal/t/002_corrupted.pl
index 52678428b5..cb4f451d25 100644
--- a/src/bin/pg_resetwal/t/002_corrupted.pl
+++ b/src/bin/pg_resetwal/t/002_corrupted.pl
@@ -8,7 +8,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 6;
+use Test::More;
 
 my $node = PostgreSQL::Test::Cluster->new('main');
 $node->init;
@@ -54,3 +54,5 @@ command_checks_all(
 		qr/\Qpg_resetwal: warning: pg_control specifies invalid WAL segment size (0 bytes); proceed with caution\E/
 	],
 	'processes zero WAL segment size');
+
+done_testing();
diff --git a/src/bin/pg_rewind/t/001_basic.pl b/src/bin/pg_rewind/t/001_basic.pl
index a20ebda345..db9201f38e 100644
--- a/src/bin/pg_rewind/t/001_basic.pl
+++ b/src/bin/pg_rewind/t/001_basic.pl
@@ -4,7 +4,7 @@
 use strict;
 use warnings;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 23;
+use Test::More;
 
 use FindBin;
 use lib $FindBin::RealBin;
@@ -191,4 +191,4 @@ run_test('local');
 run_test('remote');
 run_test('archive');
 
-exit(0);
+done_testing();
diff --git a/src/bin/pg_rewind/t/002_databases.pl b/src/bin/pg_rewind/t/002_databases.pl
index 5fac050e4b..8d6c0c0b28 100644
--- a/src/bin/pg_rewind/t/002_databases.pl
+++ b/src/bin/pg_rewind/t/002_databases.pl
@@ -4,7 +4,7 @@
 use strict;
 use warnings;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 7;
+use Test::More;
 
 use FindBin;
 use lib $FindBin::RealBin;
@@ -74,4 +74,4 @@ template1
 run_test('local');
 run_test('remote');
 
-exit(0);
+done_testing();
diff --git a/src/bin/pg_rewind/t/003_extrafiles.pl b/src/bin/pg_rewind/t/003_extrafiles.pl
index 0d140342f2..b1c47ea451 100644
--- a/src/bin/pg_rewind/t/003_extrafiles.pl
+++ b/src/bin/pg_rewind/t/003_extrafiles.pl
@@ -6,7 +6,7 @@
 use strict;
 use warnings;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 5;
+use Test::More;
 
 use File::Find;
 
@@ -103,4 +103,4 @@ sub run_test
 run_test('local');
 run_test('remote');
 
-exit(0);
+done_testing();
diff --git a/src/bin/pg_rewind/t/004_pg_xlog_symlink.pl b/src/bin/pg_rewind/t/004_pg_xlog_symlink.pl
index 9754fa7665..805935c6fd 100644
--- a/src/bin/pg_rewind/t/004_pg_xlog_symlink.pl
+++ b/src/bin/pg_rewind/t/004_pg_xlog_symlink.pl
@@ -9,7 +9,7 @@ use warnings;
 use File::Copy;
 use File::Path qw(rmtree);
 use PostgreSQL::Test::Utils;
-use Test::More tests => 5;
+use Test::More;
 
 use FindBin;
 use lib $FindBin::RealBin;
@@ -76,4 +76,4 @@ in standby, after promotion
 run_test('local');
 run_test('remote');
 
-exit(0);
+done_testing();
diff --git a/src/bin/pg_rewind/t/005_same_timeline.pl b/src/bin/pg_rewind/t/005_same_timeline.pl
index 2249694d9a..ffb62f9b05 100644
--- a/src/bin/pg_rewind/t/005_same_timeline.pl
+++ b/src/bin/pg_rewind/t/005_same_timeline.pl
@@ -8,7 +8,7 @@
 use strict;
 use warnings;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 1;
+use Test::More;
 
 use FindBin;
 use lib $FindBin::RealBin;
@@ -20,4 +20,5 @@ RewindTest::start_primary();
 RewindTest::create_standby();
 RewindTest::run_pg_rewind('local');
 RewindTest::clean_rewind_test();
-exit(0);
+
+done_testing();
diff --git a/src/bin/pg_rewind/t/006_options.pl b/src/bin/pg_rewind/t/006_options.pl
index b5f502350f..c3c27e9894 100644
--- a/src/bin/pg_rewind/t/006_options.pl
+++ b/src/bin/pg_rewind/t/006_options.pl
@@ -7,7 +7,7 @@
 use strict;
 use warnings;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 12;
+use Test::More;
 
 program_help_ok('pg_rewind');
 program_version_ok('pg_rewind');
@@ -41,3 +41,5 @@ command_fails(
 		'--write-recovery-conf'
 	],
 	'no local source with --write-recovery-conf');
+
+done_testing();
diff --git a/src/bin/pg_rewind/t/007_standby_source.pl b/src/bin/pg_rewind/t/007_standby_source.pl
index df2e72912b..47320ea5a6 100644
--- a/src/bin/pg_rewind/t/007_standby_source.pl
+++ b/src/bin/pg_rewind/t/007_standby_source.pl
@@ -27,7 +27,7 @@
 use strict;
 use warnings;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 3;
+use Test::More;
 
 use FindBin;
 use lib $FindBin::RealBin;
@@ -176,4 +176,4 @@ $node_a->teardown_node;
 $node_b->teardown_node;
 $node_c->teardown_node;
 
-exit(0);
+done_testing();
diff --git a/src/bin/pg_rewind/t/008_min_recovery_point.pl b/src/bin/pg_rewind/t/008_min_recovery_point.pl
index 8240229230..e6a7177fb7 100644
--- a/src/bin/pg_rewind/t/008_min_recovery_point.pl
+++ b/src/bin/pg_rewind/t/008_min_recovery_point.pl
@@ -34,7 +34,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 3;
+use Test::More;
 
 use File::Copy;
 
@@ -173,3 +173,5 @@ and this too), 'table foo after rewind');
 
 $result = $node_2->safe_psql('postgres', 'SELECT * FROM public.bar');
 is($result, qq(in both), 'table bar after rewind');
+
+done_testing();
diff --git a/src/bin/pg_test_fsync/t/001_basic.pl b/src/bin/pg_test_fsync/t/001_basic.pl
index ecfe89a9f2..0b579dde9d 100644
--- a/src/bin/pg_test_fsync/t/001_basic.pl
+++ b/src/bin/pg_test_fsync/t/001_basic.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use Config;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 12;
+use Test::More;
 
 #########################################
 # Basic checks
@@ -26,3 +26,5 @@ command_fails_like(
 	[ 'pg_test_fsync', '--secs-per-test', '0' ],
 	qr/\Qpg_test_fsync: error: --secs-per-test must be in range 1..4294967295\E/,
 	'pg_test_fsync: --secs-per-test must be in range');
+
+done_testing();
diff --git a/src/bin/pg_test_timing/t/001_basic.pl b/src/bin/pg_test_timing/t/001_basic.pl
index e2c4307075..ef9f6d6746 100644
--- a/src/bin/pg_test_timing/t/001_basic.pl
+++ b/src/bin/pg_test_timing/t/001_basic.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use Config;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 12;
+use Test::More;
 
 #########################################
 # Basic checks
@@ -26,3 +26,5 @@ command_fails_like(
 	[ 'pg_test_timing', '--duration', '0' ],
 	qr/\Qpg_test_timing: --duration must be in range 1..4294967295\E/,
 	'pg_test_timing: --duration must be in range');
+
+done_testing();
diff --git a/src/bin/pg_verifybackup/t/001_basic.pl b/src/bin/pg_verifybackup/t/001_basic.pl
index 452f753ab3..16febf9764 100644
--- a/src/bin/pg_verifybackup/t/001_basic.pl
+++ b/src/bin/pg_verifybackup/t/001_basic.pl
@@ -4,7 +4,7 @@
 use strict;
 use warnings;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 16;
+use Test::More;
 
 my $tempdir = PostgreSQL::Test::Utils::tempdir;
 
@@ -34,3 +34,5 @@ command_fails_like(
 	[ 'pg_verifybackup', '-m', "$tempdir/not_the_manifest", $tempdir ],
 	qr/could not open file.*\/not_the_manifest\"/,
 	'pg_verifybackup respects -m flag');
+
+done_testing();
diff --git a/src/bin/pg_verifybackup/t/002_algorithm.pl b/src/bin/pg_verifybackup/t/002_algorithm.pl
index 5d9965ba8f..20e3ca587a 100644
--- a/src/bin/pg_verifybackup/t/002_algorithm.pl
+++ b/src/bin/pg_verifybackup/t/002_algorithm.pl
@@ -10,7 +10,7 @@ use Config;
 use File::Path qw(rmtree);
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 19;
+use Test::More;
 
 my $primary = PostgreSQL::Test::Cluster->new('primary');
 $primary->init(allows_streaming => 1);
@@ -59,3 +59,5 @@ for my $algorithm (qw(bogus none crc32c sha224 sha256 sha384 sha512))
 	# Remove backup immediately to save disk space.
 	rmtree($backup_path);
 }
+
+done_testing();
diff --git a/src/bin/pg_verifybackup/t/003_corruption.pl b/src/bin/pg_verifybackup/t/003_corruption.pl
index 53be2efd87..f402d301ac 100644
--- a/src/bin/pg_verifybackup/t/003_corruption.pl
+++ b/src/bin/pg_verifybackup/t/003_corruption.pl
@@ -10,7 +10,7 @@ use Config;
 use File::Path qw(rmtree);
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 44;
+use Test::More;
 
 my $primary = PostgreSQL::Test::Cluster->new('primary');
 $primary->init(allows_streaming => 1);
@@ -290,3 +290,5 @@ sub cleanup_search_directory_fails
 	chmod(0700, $pathname) || die "chmod $pathname: $!";
 	return;
 }
+
+done_testing();
diff --git a/src/bin/pg_verifybackup/t/004_options.pl b/src/bin/pg_verifybackup/t/004_options.pl
index 5a8fd9b0ec..7461dee03f 100644
--- a/src/bin/pg_verifybackup/t/004_options.pl
+++ b/src/bin/pg_verifybackup/t/004_options.pl
@@ -10,7 +10,7 @@ use Config;
 use File::Path qw(rmtree);
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 25;
+use Test::More;
 
 # Start up the server and take a backup.
 my $primary = PostgreSQL::Test::Cluster->new('primary');
@@ -105,3 +105,5 @@ command_fails_like(
 	],
 	qr/could not open directory/,
 	'nonexistent backup directory');
+
+done_testing();
diff --git a/src/bin/pg_verifybackup/t/005_bad_manifest.pl b/src/bin/pg_verifybackup/t/005_bad_manifest.pl
index ced516877d..118beb53d7 100644
--- a/src/bin/pg_verifybackup/t/005_bad_manifest.pl
+++ b/src/bin/pg_verifybackup/t/005_bad_manifest.pl
@@ -10,7 +10,7 @@ use Cwd;
 use Config;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 58;
+use Test::More;
 
 my $tempdir = PostgreSQL::Test::Utils::tempdir;
 
@@ -209,3 +209,5 @@ sub test_bad_manifest
 	command_fails_like([ 'pg_verifybackup', $tempdir ], $regexp, $test_name);
 	return;
 }
+
+done_testing();
diff --git a/src/bin/pg_verifybackup/t/006_encoding.pl b/src/bin/pg_verifybackup/t/006_encoding.pl
index b869cd8fe6..ce45c919a8 100644
--- a/src/bin/pg_verifybackup/t/006_encoding.pl
+++ b/src/bin/pg_verifybackup/t/006_encoding.pl
@@ -9,7 +9,7 @@ use Cwd;
 use Config;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 5;
+use Test::More;
 
 my $primary = PostgreSQL::Test::Cluster->new('primary');
 $primary->init(allows_streaming => 1);
@@ -32,3 +32,5 @@ command_like(
 	[ 'pg_verifybackup', '-s', $backup_path ],
 	qr/backup successfully verified/,
 	'backup with forced encoding verified');
+
+done_testing();
diff --git a/src/bin/pg_verifybackup/t/007_wal.pl b/src/bin/pg_verifybackup/t/007_wal.pl
index 4723047d73..56fcd84bec 100644
--- a/src/bin/pg_verifybackup/t/007_wal.pl
+++ b/src/bin/pg_verifybackup/t/007_wal.pl
@@ -10,7 +10,7 @@ use Config;
 use File::Path qw(rmtree);
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 9;
+use Test::More;
 
 # Start up the server and take a backup.
 my $primary = PostgreSQL::Test::Cluster->new('primary');
@@ -76,3 +76,5 @@ $primary->command_ok([ 'pg_basebackup', '-D', $backup_path2, '--no-sync', '-cfas
 command_ok(
 	[ 'pg_verifybackup', $backup_path2 ],
 	'valid base backup with timeline > 1');
+
+done_testing();
diff --git a/src/bin/pg_verifybackup/t/008_untar.pl b/src/bin/pg_verifybackup/t/008_untar.pl
index d32c86e92e..5c5aab89b0 100644
--- a/src/bin/pg_verifybackup/t/008_untar.pl
+++ b/src/bin/pg_verifybackup/t/008_untar.pl
@@ -11,7 +11,7 @@ use Config;
 use File::Path qw(rmtree);
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 6;
+use Test::More;
 
 my $primary = PostgreSQL::Test::Cluster->new('primary');
 $primary->init(allows_streaming => 1);
@@ -102,3 +102,5 @@ for my $tc (@test_configuration)
 		rmtree($extract_path);
 	}
 }
+
+done_testing();
diff --git a/src/bin/pg_verifybackup/t/009_extract.pl b/src/bin/pg_verifybackup/t/009_extract.pl
index 51b77e4bfe..d4edc737e0 100644
--- a/src/bin/pg_verifybackup/t/009_extract.pl
+++ b/src/bin/pg_verifybackup/t/009_extract.pl
@@ -11,7 +11,7 @@ use Config;
 use File::Path qw(rmtree);
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 4;
+use Test::More;
 
 my $primary = PostgreSQL::Test::Cluster->new('primary');
 $primary->init(allows_streaming => 1);
@@ -59,3 +59,5 @@ for my $tc (@test_configuration)
 	# Remove backup immediately to save disk space.
 	rmtree($backup_path);
 }
+
+done_testing();
diff --git a/src/bin/pg_waldump/t/001_basic.pl b/src/bin/pg_waldump/t/001_basic.pl
index 987d3eb614..883adff8fa 100644
--- a/src/bin/pg_waldump/t/001_basic.pl
+++ b/src/bin/pg_waldump/t/001_basic.pl
@@ -4,8 +4,10 @@
 use strict;
 use warnings;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 8;
+use Test::More;
 
 program_help_ok('pg_waldump');
 program_version_ok('pg_waldump');
 program_options_handling_ok('pg_waldump');
+
+done_testing();
diff --git a/src/bin/psql/t/001_basic.pl b/src/bin/psql/t/001_basic.pl
index 9e14dc71ff..ba3dd846ba 100644
--- a/src/bin/psql/t/001_basic.pl
+++ b/src/bin/psql/t/001_basic.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 25;
+use Test::More;
 
 program_help_ok('psql');
 program_version_ok('psql');
@@ -80,3 +80,5 @@ psql_like(
 	'handling of unexpected PQresultStatus',
 	'START_REPLICATION 0/0',
 	undef, qr/unexpected PQresultStatus: 8$/);
+
+done_testing();
diff --git a/src/bin/psql/t/020_cancel.pl b/src/bin/psql/t/020_cancel.pl
index f445fce67a..3224f8e26a 100644
--- a/src/bin/psql/t/020_cancel.pl
+++ b/src/bin/psql/t/020_cancel.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 2;
+use Test::More;
 use Time::HiRes qw(usleep);
 
 my $tempdir = PostgreSQL::Test::Utils::tempdir;
@@ -64,3 +64,5 @@ SKIP: {
 	ok(!$result, 'query failed as expected');
 	like($stderr, qr/canceling statement due to user request/, 'query was canceled');
 }
+
+done_testing();
diff --git a/src/bin/scripts/t/010_clusterdb.pl b/src/bin/scripts/t/010_clusterdb.pl
index 0878d9fcbb..3d9abbbcc3 100644
--- a/src/bin/scripts/t/010_clusterdb.pl
+++ b/src/bin/scripts/t/010_clusterdb.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 14;
+use Test::More;
 
 program_help_ok('clusterdb');
 program_version_ok('clusterdb');
@@ -34,3 +34,5 @@ $node->issues_sql_like(
 
 $node->command_ok([qw(clusterdb --echo --verbose dbname=template1)],
 	'clusterdb with connection string');
+
+done_testing();
diff --git a/src/bin/scripts/t/011_clusterdb_all.pl b/src/bin/scripts/t/011_clusterdb_all.pl
index 81e03a20d0..7818988976 100644
--- a/src/bin/scripts/t/011_clusterdb_all.pl
+++ b/src/bin/scripts/t/011_clusterdb_all.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 2;
+use Test::More;
 
 my $node = PostgreSQL::Test::Cluster->new('main');
 $node->init;
@@ -20,3 +20,5 @@ $node->issues_sql_like(
 	[ 'clusterdb', '-a' ],
 	qr/statement: CLUSTER.*statement: CLUSTER/s,
 	'cluster all databases');
+
+done_testing();
diff --git a/src/bin/scripts/t/020_createdb.pl b/src/bin/scripts/t/020_createdb.pl
index c54c291b7a..639245466e 100644
--- a/src/bin/scripts/t/020_createdb.pl
+++ b/src/bin/scripts/t/020_createdb.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 25;
+use Test::More;
 
 program_help_ok('createdb');
 program_version_ok('createdb');
@@ -75,3 +75,5 @@ $node->command_checks_all(
 		qr/^createdb: error: database creation failed: ERROR:  invalid locale name|^createdb: error: database creation failed: ERROR:  new LC_CTYPE \(foo'; SELECT '1\) is incompatible with the LC_CTYPE of the template database/s
 	],
 	'createdb with incorrect --lc-ctype');
+
+done_testing();
diff --git a/src/bin/scripts/t/040_createuser.pl b/src/bin/scripts/t/040_createuser.pl
index e31e5b0c62..2a34be81cf 100644
--- a/src/bin/scripts/t/040_createuser.pl
+++ b/src/bin/scripts/t/040_createuser.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 17;
+use Test::More;
 
 program_help_ok('createuser');
 program_version_ok('createuser');
@@ -35,3 +35,5 @@ $node->issues_sql_like(
 
 $node->command_fails([ 'createuser', 'regress_user1' ],
 	'fails if role already exists');
+
+done_testing();
diff --git a/src/bin/scripts/t/050_dropdb.pl b/src/bin/scripts/t/050_dropdb.pl
index 1e08cbbf7f..4e946667d5 100644
--- a/src/bin/scripts/t/050_dropdb.pl
+++ b/src/bin/scripts/t/050_dropdb.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 13;
+use Test::More;
 
 program_help_ok('dropdb');
 program_version_ok('dropdb');
@@ -30,3 +30,5 @@ $node->issues_sql_like(
 
 $node->command_fails([ 'dropdb', 'nonexistent' ],
 	'fails with nonexistent database');
+
+done_testing();
diff --git a/src/bin/scripts/t/070_dropuser.pl b/src/bin/scripts/t/070_dropuser.pl
index c4fb6329ba..e4eac2186d 100644
--- a/src/bin/scripts/t/070_dropuser.pl
+++ b/src/bin/scripts/t/070_dropuser.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 11;
+use Test::More;
 
 program_help_ok('dropuser');
 program_version_ok('dropuser');
@@ -24,3 +24,5 @@ $node->issues_sql_like(
 
 $node->command_fails([ 'dropuser', 'regress_nonexistent' ],
 	'fails with nonexistent user');
+
+done_testing();
diff --git a/src/bin/scripts/t/080_pg_isready.pl b/src/bin/scripts/t/080_pg_isready.pl
index 951c0e069c..e8436dc7e8 100644
--- a/src/bin/scripts/t/080_pg_isready.pl
+++ b/src/bin/scripts/t/080_pg_isready.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 10;
+use Test::More;
 
 program_help_ok('pg_isready');
 program_version_ok('pg_isready');
@@ -21,3 +21,5 @@ $node->start;
 # use a long timeout for the benefit of very slow buildfarm machines
 $node->command_ok([qw(pg_isready --timeout=60)],
 	'succeeds with server running');
+
+done_testing();
diff --git a/src/bin/scripts/t/090_reindexdb.pl b/src/bin/scripts/t/090_reindexdb.pl
index 1306fb1234..70cd7606dd 100644
--- a/src/bin/scripts/t/090_reindexdb.pl
+++ b/src/bin/scripts/t/090_reindexdb.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 58;
+use Test::More;
 
 program_help_ok('reindexdb');
 program_version_ok('reindexdb');
@@ -199,3 +199,5 @@ $node->command_checks_all(
 		qr/^reindexdb: warning: cannot reindex system catalogs concurrently, skipping all/s
 	],
 	'parallel reindexdb for system with --concurrently skips catalogs');
+
+done_testing();
diff --git a/src/bin/scripts/t/091_reindexdb_all.pl b/src/bin/scripts/t/091_reindexdb_all.pl
index 47e8341de3..378bf9060e 100644
--- a/src/bin/scripts/t/091_reindexdb_all.pl
+++ b/src/bin/scripts/t/091_reindexdb_all.pl
@@ -5,7 +5,7 @@ use strict;
 use warnings;
 
 use PostgreSQL::Test::Cluster;
-use Test::More tests => 2;
+use Test::More;
 
 my $node = PostgreSQL::Test::Cluster->new('main');
 $node->init;
@@ -17,3 +17,5 @@ $node->issues_sql_like(
 	[ 'reindexdb', '-a' ],
 	qr/statement: REINDEX.*statement: REINDEX/s,
 	'reindex all databases');
+
+done_testing();
diff --git a/src/bin/scripts/t/100_vacuumdb.pl b/src/bin/scripts/t/100_vacuumdb.pl
index ee3bfdb6d0..96a818a3c1 100644
--- a/src/bin/scripts/t/100_vacuumdb.pl
+++ b/src/bin/scripts/t/100_vacuumdb.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 58;
+use Test::More;
 
 program_help_ok('vacuumdb');
 program_version_ok('vacuumdb');
@@ -146,3 +146,5 @@ $node->issues_sql_like(
 	[ 'vacuumdb', '--min-xid-age', '2147483001', 'postgres' ],
 	qr/GREATEST.*relfrozenxid.*2147483001/,
 	'vacuumdb --table --min-xid-age');
+
+done_testing();
diff --git a/src/bin/scripts/t/101_vacuumdb_all.pl b/src/bin/scripts/t/101_vacuumdb_all.pl
index 6e8962154c..1dcf411767 100644
--- a/src/bin/scripts/t/101_vacuumdb_all.pl
+++ b/src/bin/scripts/t/101_vacuumdb_all.pl
@@ -5,7 +5,7 @@ use strict;
 use warnings;
 
 use PostgreSQL::Test::Cluster;
-use Test::More tests => 2;
+use Test::More;
 
 my $node = PostgreSQL::Test::Cluster->new('main');
 $node->init;
@@ -15,3 +15,5 @@ $node->issues_sql_like(
 	[ 'vacuumdb', '-a' ],
 	qr/statement: VACUUM.*statement: VACUUM/s,
 	'vacuum all databases');
+
+done_testing();
diff --git a/src/bin/scripts/t/102_vacuumdb_stages.pl b/src/bin/scripts/t/102_vacuumdb_stages.pl
index c94e9e1d64..caff3a3a0d 100644
--- a/src/bin/scripts/t/102_vacuumdb_stages.pl
+++ b/src/bin/scripts/t/102_vacuumdb_stages.pl
@@ -5,7 +5,7 @@ use strict;
 use warnings;
 
 use PostgreSQL::Test::Cluster;
-use Test::More tests => 4;
+use Test::More;
 
 my $node = PostgreSQL::Test::Cluster->new('main');
 $node->init;
@@ -36,3 +36,5 @@ $node->issues_sql_like(
                    .*statement:\ RESET\ default_statistics_target;
                    .*statement:\ ANALYZE/sx,
 	'analyze more than one database in stages');
+
+done_testing();
diff --git a/src/bin/scripts/t/200_connstr.pl b/src/bin/scripts/t/200_connstr.pl
index 6d75af1d6c..c865146a6f 100644
--- a/src/bin/scripts/t/200_connstr.pl
+++ b/src/bin/scripts/t/200_connstr.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 3;
+use Test::More;
 
 # Tests to check connection string handling in utilities
 
@@ -40,3 +40,5 @@ $node->command_ok([qw(reindexdb --all --echo)],
 $node->command_ok(
 	[qw(clusterdb --all --echo --verbose)],
 	'clusterdb --all with unusual database names');
+
+done_testing();
diff --git a/src/test/authentication/t/001_password.pl b/src/test/authentication/t/001_password.pl
index 5d56455857..3e3079c824 100644
--- a/src/test/authentication/t/001_password.pl
+++ b/src/test/authentication/t/001_password.pl
@@ -18,11 +18,6 @@ if (!$use_unix_sockets)
 	plan skip_all =>
 	  "authentication tests cannot run without Unix-domain sockets";
 }
-else
-{
-	plan tests => 23;
-}
-
 
 # Delete pg_hba.conf from the given node, add a new entry to it
 # and then execute a reload to refresh it.
@@ -160,3 +155,5 @@ append_to_file(
 !);
 
 test_role($node, 'md5_role', 'password from pgpass', 0);
+
+done_testing();
diff --git a/src/test/authentication/t/002_saslprep.pl b/src/test/authentication/t/002_saslprep.pl
index d8995b1ae5..5e87e21ee9 100644
--- a/src/test/authentication/t/002_saslprep.pl
+++ b/src/test/authentication/t/002_saslprep.pl
@@ -15,10 +15,6 @@ if (!$use_unix_sockets)
 	plan skip_all =>
 	  "authentication tests cannot run without Unix-domain sockets";
 }
-else
-{
-	plan tests => 12;
-}
 
 # Delete pg_hba.conf from the given node, add a new entry to it
 # and then execute a reload to refresh it.
@@ -117,3 +113,5 @@ test_login($node, 'saslpreptest6_role', "foobar",     2);
 test_login($node, 'saslpreptest7_role', "foo\xd8\xa71bar", 0);
 test_login($node, 'saslpreptest7_role', "foo1\xd8\xa7bar", 2);
 test_login($node, 'saslpreptest7_role', "foobar",          2);
+
+done_testing();
diff --git a/src/test/kerberos/t/001_auth.pl b/src/test/kerberos/t/001_auth.pl
index 2b539d2402..62e0542639 100644
--- a/src/test/kerberos/t/001_auth.pl
+++ b/src/test/kerberos/t/001_auth.pl
@@ -21,11 +21,7 @@ use PostgreSQL::Test::Cluster;
 use Test::More;
 use Time::HiRes qw(usleep);
 
-if ($ENV{with_gssapi} eq 'yes')
-{
-	plan tests => 44;
-}
-else
+if ($ENV{with_gssapi} ne 'yes')
 {
 	plan skip_all => 'GSSAPI/Kerberos not supported by this build';
 }
@@ -399,3 +395,5 @@ test_access(
 	'',
 	'fails with wrong krb_realm, but still authenticates',
 	"connection authenticated: identity=\"test1\@$realm\" method=gss");
+
+done_testing();
diff --git a/src/test/ldap/t/001_auth.pl b/src/test/ldap/t/001_auth.pl
index cdc4e1e5c8..094270cb5d 100644
--- a/src/test/ldap/t/001_auth.pl
+++ b/src/test/ldap/t/001_auth.pl
@@ -7,11 +7,7 @@ use PostgreSQL::Test::Utils;
 use PostgreSQL::Test::Cluster;
 use Test::More;
 
-if ($ENV{with_ldap} eq 'yes')
-{
-	plan tests => 28;
-}
-else
+if ($ENV{with_ldap} ne 'yes')
 {
 	plan skip_all => 'LDAP not supported by this build';
 }
@@ -367,3 +363,5 @@ $node->restart;
 
 $ENV{"PGPASSWORD"} = 'secret1';
 test_access($node, 'test1', 2, 'bad combination of LDAPS and StartTLS');
+
+done_testing();
diff --git a/src/test/modules/brin/t/01_workitems.pl b/src/test/modules/brin/t/01_workitems.pl
index 2c9a206ae5..3108c02cf4 100644
--- a/src/test/modules/brin/t/01_workitems.pl
+++ b/src/test/modules/brin/t/01_workitems.pl
@@ -7,7 +7,7 @@ use strict;
 use warnings;
 
 use PostgreSQL::Test::Utils;
-use Test::More tests => 2;
+use Test::More;
 use PostgreSQL::Test::Cluster;
 
 my $node = PostgreSQL::Test::Cluster->new('tango');
@@ -42,3 +42,5 @@ $count = $node->safe_psql('postgres',
 );
 is($count, 't', "index got summarized");
 $node->stop;
+
+done_testing();
diff --git a/src/test/modules/commit_ts/t/001_base.pl b/src/test/modules/commit_ts/t/001_base.pl
index 52fca03ddb..3f0bb9e858 100644
--- a/src/test/modules/commit_ts/t/001_base.pl
+++ b/src/test/modules/commit_ts/t/001_base.pl
@@ -7,7 +7,7 @@ use strict;
 use warnings;
 
 use PostgreSQL::Test::Utils;
-use Test::More tests => 2;
+use Test::More;
 use PostgreSQL::Test::Cluster;
 
 my $node = PostgreSQL::Test::Cluster->new('foxtrot');
@@ -34,3 +34,5 @@ my $recovered_ts = $node->safe_psql('postgres',
 	'select ts.* from pg_class, pg_xact_commit_timestamp(xmin) ts where relname = \'t\''
 );
 is($recovered_ts, $ts, 'commit TS remains after crash recovery');
+
+done_testing();
diff --git a/src/test/modules/commit_ts/t/002_standby.pl b/src/test/modules/commit_ts/t/002_standby.pl
index c8791f5b0e..ace31405e6 100644
--- a/src/test/modules/commit_ts/t/002_standby.pl
+++ b/src/test/modules/commit_ts/t/002_standby.pl
@@ -7,7 +7,7 @@ use strict;
 use warnings;
 
 use PostgreSQL::Test::Utils;
-use Test::More tests => 4;
+use Test::More;
 use PostgreSQL::Test::Cluster;
 
 my $bkplabel = 'backup';
@@ -64,3 +64,5 @@ like(
 	$standby_ts_stderr,
 	qr/could not get commit timestamp data/,
 	'expected error when primary turned feature off');
+
+done_testing();
diff --git a/src/test/modules/commit_ts/t/003_standby_2.pl b/src/test/modules/commit_ts/t/003_standby_2.pl
index b53ca4f8de..16d5f13009 100644
--- a/src/test/modules/commit_ts/t/003_standby_2.pl
+++ b/src/test/modules/commit_ts/t/003_standby_2.pl
@@ -7,7 +7,7 @@ use strict;
 use warnings;
 
 use PostgreSQL::Test::Utils;
-use Test::More tests => 4;
+use Test::More;
 use PostgreSQL::Test::Cluster;
 
 my $bkplabel = 'backup';
@@ -65,3 +65,5 @@ my $standby_ts = $standby->safe_psql('postgres',
 );
 isnt($standby_ts, '',
 	"standby gives valid value ($standby_ts) after promotion");
+
+done_testing();
diff --git a/src/test/modules/commit_ts/t/004_restart.pl b/src/test/modules/commit_ts/t/004_restart.pl
index 40d1b1a945..808164c34d 100644
--- a/src/test/modules/commit_ts/t/004_restart.pl
+++ b/src/test/modules/commit_ts/t/004_restart.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 16;
+use Test::More;
 
 my $node_primary = PostgreSQL::Test::Cluster->new('primary');
 $node_primary->init(allows_streaming => 1);
@@ -150,3 +150,5 @@ is($after_enable_disabled_ts, '',
 	'timestamp of disabled tx null after re-enable');
 
 $node_primary->stop;
+
+done_testing();
diff --git a/src/test/modules/test_misc/t/001_constraint_validation.pl b/src/test/modules/test_misc/t/001_constraint_validation.pl
index 7bd6022035..3b9fc66b8e 100644
--- a/src/test/modules/test_misc/t/001_constraint_validation.pl
+++ b/src/test/modules/test_misc/t/001_constraint_validation.pl
@@ -7,7 +7,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 42;
+use Test::More;
 
 # Initialize a test cluster
 my $node = PostgreSQL::Test::Cluster->new('primary');
@@ -311,3 +311,5 @@ ok( $output =~
 run_sql_command('DROP TABLE quuux;');
 
 $node->stop('fast');
+
+done_testing();
diff --git a/src/test/modules/test_misc/t/002_tablespace.pl b/src/test/modules/test_misc/t/002_tablespace.pl
index 4e4c35b4f2..6fea419bb8 100644
--- a/src/test/modules/test_misc/t/002_tablespace.pl
+++ b/src/test/modules/test_misc/t/002_tablespace.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 20;
+use Test::More;
 
 my $node = PostgreSQL::Test::Cluster->new('main');
 $node->init;
@@ -97,3 +97,5 @@ $result = $node->psql('postgres', "DROP TABLESPACE regress_ts4");
 ok($result == 0, 'drop tablespace 4');
 
 $node->stop;
+
+done_testing();
diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl
index a906f8f03d..c73bd37835 100644
--- a/src/test/modules/test_pg_dump/t/001_base.pl
+++ b/src/test/modules/test_pg_dump/t/001_base.pl
@@ -718,44 +718,6 @@ $node->start;
 
 my $port = $node->port;
 
-my $num_tests = 0;
-
-foreach my $run (sort keys %pgdump_runs)
-{
-	my $test_key = $run;
-
-	# Each run of pg_dump is a test itself
-	$num_tests++;
-
-	# If there is a restore cmd, that's another test
-	if ($pgdump_runs{$run}->{restore_cmd})
-	{
-		$num_tests++;
-	}
-
-	if ($pgdump_runs{$run}->{test_key})
-	{
-		$test_key = $pgdump_runs{$run}->{test_key};
-	}
-
-	# Then count all the tests run against each run
-	foreach my $test (sort keys %tests)
-	{
-		# If there is a like entry, but no unlike entry, then we will test the like case
-		if ($tests{$test}->{like}->{$test_key}
-			&& !defined($tests{$test}->{unlike}->{$test_key}))
-		{
-			$num_tests++;
-		}
-		else
-		{
-			# We will test everything that isn't a 'like'
-			$num_tests++;
-		}
-	}
-}
-plan tests => $num_tests;
-
 #########################################
 # Set up schemas, tables, etc, to be dumped.
 
@@ -847,3 +809,5 @@ foreach my $run (sort keys %pgdump_runs)
 # Stop the database instance, which will be removed at the end of the tests.
 
 $node->stop('fast');
+
+done_testing();
diff --git a/src/test/perl/README b/src/test/perl/README
index 9e870830cf..0511c55e9a 100644
--- a/src/test/perl/README
+++ b/src/test/perl/README
@@ -54,8 +54,7 @@ Each test script should begin with:
     use warnings;
     use PostgreSQL::Test::Cluster;
     use PostgreSQL::Test::Utils;
-    # Replace with the number of tests to execute:
-    use Test::More tests => 1;
+    use Test::More;
 
 then it will generally need to set up one or more nodes, run commands
 against them and evaluate the results. For example:
@@ -69,6 +68,10 @@ against them and evaluate the results. For example:
 
     $node->stop('fast');
 
+Each test script should end with:
+
+	done_testing();
+
 Test::More::like entails use of the qr// operator.  Avoid Perl 5.8.8 bug
 #39185 by not using the "$" regular expression metacharacter in qr// when also
 using the "/m" modifier.  Instead of "$", use "\n" or "(?=\n|\z)".
diff --git a/src/test/recovery/t/001_stream_rep.pl b/src/test/recovery/t/001_stream_rep.pl
index ca760c7210..583ee87da8 100644
--- a/src/test/recovery/t/001_stream_rep.pl
+++ b/src/test/recovery/t/001_stream_rep.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 55;
+use Test::More;
 
 # Initialize primary node
 my $node_primary = PostgreSQL::Test::Cluster->new('primary');
@@ -529,3 +529,5 @@ ok( ($phys_restart_lsn_pre cmp $phys_restart_lsn_post) == 0,
 my $primary_data = $node_primary->data_dir;
 ok(!-f "$primary_data/pg_wal/$segment_removed",
 	"WAL segment $segment_removed recycled after physical slot advancing");
+
+done_testing();
diff --git a/src/test/recovery/t/002_archiving.pl b/src/test/recovery/t/002_archiving.pl
index 9a0451b8e4..c8f5ffbaf0 100644
--- a/src/test/recovery/t/002_archiving.pl
+++ b/src/test/recovery/t/002_archiving.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 7;
+use Test::More;
 use File::Copy;
 
 # Initialize primary node, doing archives
@@ -120,3 +120,5 @@ like(
 	$log_contents,
 	qr/WARNING:.*recovery_end_command/s,
 	"recovery_end_command failure detected in logs after promotion");
+
+done_testing();
diff --git a/src/test/recovery/t/003_recovery_targets.pl b/src/test/recovery/t/003_recovery_targets.pl
index 24da78c0bc..25dd5ee7ec 100644
--- a/src/test/recovery/t/003_recovery_targets.pl
+++ b/src/test/recovery/t/003_recovery_targets.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 9;
+use Test::More;
 use Time::HiRes qw(usleep);
 
 # Create and test a standby from given backup, with a certain recovery target.
@@ -182,3 +182,5 @@ $logfile = slurp_file($node_standby->logfile());
 ok( $logfile =~
 	  qr/FATAL: .* recovery ended before configured recovery target was reached/,
 	'recovery end before target reached is a fatal error');
+
+done_testing();
diff --git a/src/test/recovery/t/004_timeline_switch.pl b/src/test/recovery/t/004_timeline_switch.pl
index 05b7931668..3203d93701 100644
--- a/src/test/recovery/t/004_timeline_switch.pl
+++ b/src/test/recovery/t/004_timeline_switch.pl
@@ -7,7 +7,7 @@ use warnings;
 use File::Path qw(rmtree);
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 3;
+use Test::More;
 
 $ENV{PGDATABASE} = 'postgres';
 
@@ -106,3 +106,5 @@ $node_primary_2->wait_for_catchup($node_standby_3);
 my $result_2 =
   $node_standby_3->safe_psql('postgres', "SELECT count(*) FROM tab_int");
 is($result_2, qq(1), 'check content of standby 3');
+
+done_testing();
diff --git a/src/test/recovery/t/005_replay_delay.pl b/src/test/recovery/t/005_replay_delay.pl
index 39c5675cc9..370fc9eace 100644
--- a/src/test/recovery/t/005_replay_delay.pl
+++ b/src/test/recovery/t/005_replay_delay.pl
@@ -7,7 +7,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 3;
+use Test::More;
 
 # Initialize primary node
 my $node_primary = PostgreSQL::Test::Cluster->new('primary');
@@ -110,3 +110,5 @@ $node_standby2->poll_query_until('postgres',
 $node_standby2->promote;
 $node_standby2->poll_query_until('postgres', "SELECT NOT pg_is_in_recovery()")
   or die "Timed out while waiting for promotion to finish";
+
+done_testing();
diff --git a/src/test/recovery/t/006_logical_decoding.pl b/src/test/recovery/t/006_logical_decoding.pl
index 29b68a7f85..fa6bd45332 100644
--- a/src/test/recovery/t/006_logical_decoding.pl
+++ b/src/test/recovery/t/006_logical_decoding.pl
@@ -10,7 +10,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 15;
+use Test::More;
 use Config;
 
 # Initialize primary node
@@ -200,3 +200,5 @@ ok(($logical_restart_lsn_pre cmp $logical_restart_lsn_post) == 0,
 
 # done with the node
 $node_primary->stop;
+
+done_testing();
diff --git a/src/test/recovery/t/007_sync_rep.pl b/src/test/recovery/t/007_sync_rep.pl
index cebd590111..86f89c63e2 100644
--- a/src/test/recovery/t/007_sync_rep.pl
+++ b/src/test/recovery/t/007_sync_rep.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 11;
+use Test::More;
 
 # Query checking sync_priority and sync_state of each standby
 my $check_sql =
@@ -217,3 +217,5 @@ standby3|1|quorum
 standby4|1|quorum),
 	'all standbys are considered as candidates for quorum sync standbys',
 	'ANY 2(*)');
+
+done_testing();
diff --git a/src/test/recovery/t/008_fsm_truncation.pl b/src/test/recovery/t/008_fsm_truncation.pl
index ee48c217cf..5be2153c33 100644
--- a/src/test/recovery/t/008_fsm_truncation.pl
+++ b/src/test/recovery/t/008_fsm_truncation.pl
@@ -10,7 +10,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 1;
+use Test::More;
 
 my $node_primary = PostgreSQL::Test::Cluster->new('primary');
 $node_primary->init(allows_streaming => 1);
@@ -96,3 +96,5 @@ is( $node_standby->psql(
 		qq{insert into testtab select generate_series(1,1000), 'foo';}),
 	0,
 	'INSERT succeeds with truncated relation FSM');
+
+done_testing();
diff --git a/src/test/recovery/t/009_twophase.pl b/src/test/recovery/t/009_twophase.pl
index 2d0b3b0873..3e25b8c4eb 100644
--- a/src/test/recovery/t/009_twophase.pl
+++ b/src/test/recovery/t/009_twophase.pl
@@ -7,7 +7,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 24;
+use Test::More;
 
 my $psql_out = '';
 my $psql_rc  = '';
@@ -480,3 +480,5 @@ $cur_standby->psql(
 is( $psql_out,
 	qq{27|issued to paris},
 	"Check expected t_009_tbl2 data on standby");
+
+done_testing();
diff --git a/src/test/recovery/t/010_logical_decoding_timelines.pl b/src/test/recovery/t/010_logical_decoding_timelines.pl
index 672cd74f3b..6e8b0b1b96 100644
--- a/src/test/recovery/t/010_logical_decoding_timelines.pl
+++ b/src/test/recovery/t/010_logical_decoding_timelines.pl
@@ -26,7 +26,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 13;
+use Test::More;
 use File::Copy;
 use IPC::Run ();
 use Scalar::Util qw(blessed);
@@ -196,3 +196,5 @@ is($stdout, $final_expected_output_bb,
 	'got same output from walsender via pg_recvlogical on before_basebackup');
 
 $node_replica->teardown_node();
+
+done_testing();
diff --git a/src/test/recovery/t/011_crash_recovery.pl b/src/test/recovery/t/011_crash_recovery.pl
index 3892aba3e5..14154d1ce0 100644
--- a/src/test/recovery/t/011_crash_recovery.pl
+++ b/src/test/recovery/t/011_crash_recovery.pl
@@ -11,8 +11,6 @@ use PostgreSQL::Test::Utils;
 use Test::More;
 use Config;
 
-plan tests => 3;
-
 my $node = PostgreSQL::Test::Cluster->new('primary');
 $node->init(allows_streaming => 1);
 $node->start;
@@ -62,3 +60,5 @@ is($node->safe_psql('postgres', qq[SELECT pg_xact_status('$xid');]),
 
 $stdin .= "\\q\n";
 $tx->finish;    # wait for psql to quit gracefully
+
+done_testing();
diff --git a/src/test/recovery/t/012_subtransactions.pl b/src/test/recovery/t/012_subtransactions.pl
index 2a558b2301..f8075097a9 100644
--- a/src/test/recovery/t/012_subtransactions.pl
+++ b/src/test/recovery/t/012_subtransactions.pl
@@ -7,7 +7,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 12;
+use Test::More;
 
 # Setup primary node
 my $node_primary = PostgreSQL::Test::Cluster->new("primary");
@@ -214,3 +214,5 @@ $node_primary->psql(
 	"SELECT coalesce(sum(id),-1) FROM t_012_tbl",
 	stdout => \$psql_out);
 is($psql_out, '-1', "Not visible");
+
+done_testing();
diff --git a/src/test/recovery/t/013_crash_restart.pl b/src/test/recovery/t/013_crash_restart.pl
index 44c6ac8a00..3b740eb6f3 100644
--- a/src/test/recovery/t/013_crash_restart.pl
+++ b/src/test/recovery/t/013_crash_restart.pl
@@ -18,9 +18,6 @@ use PostgreSQL::Test::Utils;
 use Test::More;
 use Config;
 
-plan tests => 18;
-
-
 # To avoid hanging while expecting some specific input from a psql
 # instance being driven by us, add a timeout high enough that it
 # should never trigger even on very slow machines, unless something
@@ -272,3 +269,5 @@ sub pump_until
 	return 1;
 
 }
+
+done_testing();
diff --git a/src/test/recovery/t/014_unlogged_reinit.pl b/src/test/recovery/t/014_unlogged_reinit.pl
index c1bb89176b..da77c1211f 100644
--- a/src/test/recovery/t/014_unlogged_reinit.pl
+++ b/src/test/recovery/t/014_unlogged_reinit.pl
@@ -10,7 +10,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 12;
+use Test::More;
 
 my $node = PostgreSQL::Test::Cluster->new('main');
 
@@ -82,3 +82,5 @@ ok( !-f "$pgdata/${ts1UnloggedPath}_vm",
 	'vm fork in tablespace removed at startup');
 ok( !-f "$pgdata/${ts1UnloggedPath}_fsm",
 	'fsm fork in tablespace removed at startup');
+
+done_testing();
diff --git a/src/test/recovery/t/015_promotion_pages.pl b/src/test/recovery/t/015_promotion_pages.pl
index 65443df5fe..8d57b1b3d6 100644
--- a/src/test/recovery/t/015_promotion_pages.pl
+++ b/src/test/recovery/t/015_promotion_pages.pl
@@ -9,7 +9,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 1;
+use Test::More;
 
 # Initialize primary node
 my $alpha = PostgreSQL::Test::Cluster->new('alpha');
@@ -85,3 +85,5 @@ $bravo->start;
 my $psql_out;
 $bravo->psql('postgres', "SELECT count(*) FROM test1", stdout => \$psql_out);
 is($psql_out, '1000', "Check that table state is correct");
+
+done_testing();
diff --git a/src/test/recovery/t/016_min_consistency.pl b/src/test/recovery/t/016_min_consistency.pl
index 86fd6f5546..5e0655c2a9 100644
--- a/src/test/recovery/t/016_min_consistency.pl
+++ b/src/test/recovery/t/016_min_consistency.pl
@@ -11,7 +11,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 1;
+use Test::More;
 
 # Find the largest LSN in the set of pages part of the given relation
 # file.  This is used for offline checks of page consistency.  The LSN
@@ -139,3 +139,5 @@ die "No minRecoveryPoint in control file found\n"
 # the pages on disk.
 ok($offline_recovery_lsn ge $offline_max_lsn,
 	"Check offline that table data is consistent with minRecoveryPoint");
+
+done_testing();
diff --git a/src/test/recovery/t/017_shm.pl b/src/test/recovery/t/017_shm.pl
index d57679b531..678a252165 100644
--- a/src/test/recovery/t/017_shm.pl
+++ b/src/test/recovery/t/017_shm.pl
@@ -25,10 +25,6 @@ if ($@ || $windows_os)
 {
 	plan skip_all => 'SysV shared memory not supported by this platform';
 }
-else
-{
-	plan tests => 4;
-}
 
 my $tempdir = PostgreSQL::Test::Utils::tempdir;
 
@@ -218,3 +214,5 @@ sub poll_start
 	$node->start && return 1;
 	return 0;
 }
+
+done_testing();
diff --git a/src/test/recovery/t/018_wal_optimize.pl b/src/test/recovery/t/018_wal_optimize.pl
index 2bc7b9aa3d..1410e2f03b 100644
--- a/src/test/recovery/t/018_wal_optimize.pl
+++ b/src/test/recovery/t/018_wal_optimize.pl
@@ -14,7 +14,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 38;
+use Test::More;
 
 sub check_orphan_relfilenodes
 {
@@ -399,3 +399,5 @@ wal_skip_threshold = 0
 # Run same test suite for multiple wal_level values.
 run_wal_optimize("minimal");
 run_wal_optimize("replica");
+
+done_testing();
diff --git a/src/test/recovery/t/019_replslot_limit.pl b/src/test/recovery/t/019_replslot_limit.pl
index 76b6ba1987..4257bd4d35 100644
--- a/src/test/recovery/t/019_replslot_limit.pl
+++ b/src/test/recovery/t/019_replslot_limit.pl
@@ -11,7 +11,7 @@ use PostgreSQL::Test::Utils;
 use PostgreSQL::Test::Cluster;
 
 use File::Path qw(rmtree);
-use Test::More tests => $PostgreSQL::Test::Utils::windows_os ? 16 : 20;
+use Test::More;
 use Time::HiRes qw(usleep);
 
 $ENV{PGDATABASE} = 'postgres';
@@ -421,3 +421,5 @@ sub find_in_log
 
 	return $log =~ m/$pat/;
 }
+
+done_testing();
diff --git a/src/test/recovery/t/020_archive_status.pl b/src/test/recovery/t/020_archive_status.pl
index 06c2b69ef4..cbff26e122 100644
--- a/src/test/recovery/t/020_archive_status.pl
+++ b/src/test/recovery/t/020_archive_status.pl
@@ -8,7 +8,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 16;
+use Test::More;
 use Config;
 
 my $primary = PostgreSQL::Test::Cluster->new('primary');
@@ -234,3 +234,5 @@ ok( -f "$standby2_data/$segment_path_1_done"
 	  && -f "$standby2_data/$segment_path_2_done",
 	".done files created after archive success with archive_mode=always on standby"
 );
+
+done_testing();
diff --git a/src/test/recovery/t/021_row_visibility.pl b/src/test/recovery/t/021_row_visibility.pl
index 1ceb032750..e2743518de 100644
--- a/src/test/recovery/t/021_row_visibility.pl
+++ b/src/test/recovery/t/021_row_visibility.pl
@@ -8,7 +8,7 @@ use warnings;
 
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 10;
+use Test::More;
 use Config;
 
 # Initialize primary node
@@ -208,3 +208,5 @@ sub send_query_and_wait
 
 	return 1;
 }
+
+done_testing();
diff --git a/src/test/recovery/t/022_crash_temp_files.pl b/src/test/recovery/t/022_crash_temp_files.pl
index 2000f51731..6ab3092874 100644
--- a/src/test/recovery/t/022_crash_temp_files.pl
+++ b/src/test/recovery/t/022_crash_temp_files.pl
@@ -14,11 +14,6 @@ if ($Config{osname} eq 'MSWin32')
 	plan skip_all => 'tests hang on Windows';
 	exit;
 }
-else
-{
-	plan tests => 9;
-}
-
 
 # To avoid hanging while expecting some specific input from a psql
 # instance being driven by us, add a timeout high enough that it
@@ -275,3 +270,5 @@ sub pump_until
 	}
 	return 1;
 }
+
+done_testing();
diff --git a/src/test/recovery/t/023_pitr_prepared_xact.pl b/src/test/recovery/t/023_pitr_prepared_xact.pl
index da13e1d0f3..39e8a8fa17 100644
--- a/src/test/recovery/t/023_pitr_prepared_xact.pl
+++ b/src/test/recovery/t/023_pitr_prepared_xact.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 1;
+use Test::More;
 use File::Compare;
 
 # Initialize and start primary node with WAL archiving
@@ -87,3 +87,5 @@ CHECKPOINT;
 # still be found.
 $node_pitr->stop('immediate');
 $node_pitr->start;
+
+done_testing();
diff --git a/src/test/recovery/t/024_archive_recovery.pl b/src/test/recovery/t/024_archive_recovery.pl
index dccdbd5879..c10bb5bf70 100644
--- a/src/test/recovery/t/024_archive_recovery.pl
+++ b/src/test/recovery/t/024_archive_recovery.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 2;
+use Test::More;
 use Time::HiRes qw(usleep);
 
 # Initialize and start node with wal_level = replica and WAL archiving
@@ -101,3 +101,5 @@ test_recovery_wal_level_minimal('archive_recovery', 'archive recovery', 0);
 
 # Test for standby server
 test_recovery_wal_level_minimal('standby', 'standby', 1);
+
+done_testing();
diff --git a/src/test/recovery/t/025_stuck_on_old_timeline.pl b/src/test/recovery/t/025_stuck_on_old_timeline.pl
index dc48f909c4..d113c8cc9c 100644
--- a/src/test/recovery/t/025_stuck_on_old_timeline.pl
+++ b/src/test/recovery/t/025_stuck_on_old_timeline.pl
@@ -13,7 +13,7 @@ use PostgreSQL::Test::Utils;
 
 use File::Basename;
 use FindBin;
-use Test::More tests => 1;
+use Test::More;
 
 # Initialize primary node
 my $node_primary = PostgreSQL::Test::Cluster->new('primary');
@@ -108,3 +108,5 @@ my $result =
   $node_cascade->safe_psql('postgres', "SELECT count(*) FROM tab_int");
 print "cascade: $result\n";
 is($result, 1, 'check streamed content on cascade standby');
+
+done_testing();
diff --git a/src/test/recovery/t/026_overwrite_contrecord.pl b/src/test/recovery/t/026_overwrite_contrecord.pl
index e9aadad1b2..0fd907f152 100644
--- a/src/test/recovery/t/026_overwrite_contrecord.pl
+++ b/src/test/recovery/t/026_overwrite_contrecord.pl
@@ -10,8 +10,6 @@ use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
 use Test::More;
 
-plan tests => 3;
-
 # Test: Create a physical replica that's missing the last WAL file,
 # then restart the primary to create a divergent WAL file and observe
 # that the replica replays the "overwrite contrecord" from that new
@@ -104,3 +102,5 @@ like(
 
 $node->stop;
 $node_standby->stop;
+
+done_testing();
diff --git a/src/test/recovery/t/027_stream_regress.pl b/src/test/recovery/t/027_stream_regress.pl
index cd8163a4b5..53b3a75d14 100644
--- a/src/test/recovery/t/027_stream_regress.pl
+++ b/src/test/recovery/t/027_stream_regress.pl
@@ -12,10 +12,6 @@ if (PostgreSQL::Test::Utils::has_wal_read_bug)
 	# die(), not merely to fail.
 	plan skip_all => 'filesystem bug';
 }
-else
-{
-	plan tests => 4;
-}
 
 # Initialize primary node
 my $node_primary = PostgreSQL::Test::Cluster->new('primary');
@@ -91,3 +87,5 @@ command_ok(
 
 $node_standby_1->stop;
 $node_primary->stop;
+
+done_testing();
diff --git a/src/test/ssl/t/001_ssltests.pl b/src/test/ssl/t/001_ssltests.pl
index b1fb15ce80..495a66a6e6 100644
--- a/src/test/ssl/t/001_ssltests.pl
+++ b/src/test/ssl/t/001_ssltests.pl
@@ -19,10 +19,6 @@ if ($ENV{with_ssl} ne 'openssl')
 {
 	plan skip_all => 'OpenSSL not supported by this build';
 }
-else
-{
-	plan tests => 110;
-}
 
 #### Some configuration
 
@@ -619,3 +615,5 @@ $node->connect_fails(
 	"$common_connstr user=ssltestuser sslcert=ssl/client-revoked.crt sslkey=$key{'client-revoked.key'}",
 	"certificate authorization fails with revoked client cert with server-side CRL directory",
 	expected_stderr => qr/SSL error: sslv3 alert certificate revoked/);
+
+done_testing();
diff --git a/src/test/ssl/t/002_scram.pl b/src/test/ssl/t/002_scram.pl
index 86312be88c..74e9e693f6 100644
--- a/src/test/ssl/t/002_scram.pl
+++ b/src/test/ssl/t/002_scram.pl
@@ -30,8 +30,6 @@ my $SERVERHOSTCIDR = '127.0.0.1/32';
 my $supports_tls_server_end_point =
   check_pg_config("#define HAVE_X509_GET_SIGNATURE_NID 1");
 
-my $number_of_tests = $supports_tls_server_end_point ? 11 : 12;
-
 # Allocation of base connection string shared among multiple tests.
 my $common_connstr;
 
@@ -118,4 +116,4 @@ $node->connect_ok(
 		qr/connection authenticated: identity="ssltestuser" method=scram-sha-256/
 	]);
 
-done_testing($number_of_tests);
+done_testing();
diff --git a/src/test/ssl/t/003_sslinfo.pl b/src/test/ssl/t/003_sslinfo.pl
index 8c760b39db..1560829fa2 100644
--- a/src/test/ssl/t/003_sslinfo.pl
+++ b/src/test/ssl/t/003_sslinfo.pl
@@ -18,10 +18,6 @@ if ($ENV{with_ssl} ne 'openssl')
 {
 	plan skip_all => 'OpenSSL not supported by this build';
 }
-else
-{
-	plan tests => 13;
-}
 
 #### Some configuration
 
@@ -135,3 +131,5 @@ $result = $node->safe_psql("certdb",
   "SELECT value, critical FROM ssl_extension_info() WHERE name = 'basicConstraints';",
   connstr => $common_connstr);
 is($result, 'CA:FALSE|t', 'extract extension from cert');
+
+done_testing();
diff --git a/src/test/subscription/t/001_rep_changes.pl b/src/test/subscription/t/001_rep_changes.pl
index b7953c0931..af0cff6a30 100644
--- a/src/test/subscription/t/001_rep_changes.pl
+++ b/src/test/subscription/t/001_rep_changes.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 32;
+use Test::More;
 
 # Initialize publisher node
 my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
@@ -537,3 +537,5 @@ ROLLBACK;
 ok( $reterr =~
 	  m/WARNING:  wal_level is insufficient to publish logical changes/,
 	'CREATE PUBLICATION while wal_level=minimal');
+
+done_testing();
diff --git a/src/test/subscription/t/002_types.pl b/src/test/subscription/t/002_types.pl
index 3f0792ed84..3f1f00f7c8 100644
--- a/src/test/subscription/t/002_types.pl
+++ b/src/test/subscription/t/002_types.pl
@@ -7,7 +7,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 4;
+use Test::More;
 
 # Initialize publisher node
 my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
@@ -566,3 +566,5 @@ is($result, '21', 'sql-function constraint on domain');
 
 $node_subscriber->stop('fast');
 $node_publisher->stop('fast');
+
+done_testing();
diff --git a/src/test/subscription/t/003_constraints.pl b/src/test/subscription/t/003_constraints.pl
index 6f3ebd6781..63c22699c0 100644
--- a/src/test/subscription/t/003_constraints.pl
+++ b/src/test/subscription/t/003_constraints.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 6;
+use Test::More;
 
 # Initialize publisher node
 my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
@@ -137,3 +137,5 @@ is($result, qq(2|1|2),
 
 $node_subscriber->stop('fast');
 $node_publisher->stop('fast');
+
+done_testing();
diff --git a/src/test/subscription/t/004_sync.pl b/src/test/subscription/t/004_sync.pl
index 1e0e64c0d7..cf61fc1e0f 100644
--- a/src/test/subscription/t/004_sync.pl
+++ b/src/test/subscription/t/004_sync.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 8;
+use Test::More;
 
 # Initialize publisher node
 my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
@@ -178,3 +178,5 @@ is($result, qq(0),
 
 $node_subscriber->stop('fast');
 $node_publisher->stop('fast');
+
+done_testing();
diff --git a/src/test/subscription/t/005_encoding.pl b/src/test/subscription/t/005_encoding.pl
index d7513b1c61..38a74a897f 100644
--- a/src/test/subscription/t/005_encoding.pl
+++ b/src/test/subscription/t/005_encoding.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 1;
+use Test::More;
 
 my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
 $node_publisher->init(
@@ -53,3 +53,5 @@ is( $node_subscriber->safe_psql(
 
 $node_subscriber->stop;
 $node_publisher->stop;
+
+done_testing();
diff --git a/src/test/subscription/t/006_rewrite.pl b/src/test/subscription/t/006_rewrite.pl
index 7a86ae2d16..c924ff35f7 100644
--- a/src/test/subscription/t/006_rewrite.pl
+++ b/src/test/subscription/t/006_rewrite.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 2;
+use Test::More;
 
 my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
 $node_publisher->init(allows_streaming => 'logical');
@@ -66,3 +66,5 @@ is( $node_subscriber->safe_psql('postgres', q{SELECT a, b, c FROM test1}),
 
 $node_subscriber->stop;
 $node_publisher->stop;
+
+done_testing();
diff --git a/src/test/subscription/t/007_ddl.pl b/src/test/subscription/t/007_ddl.pl
index d1e8db3150..1144b005f6 100644
--- a/src/test/subscription/t/007_ddl.pl
+++ b/src/test/subscription/t/007_ddl.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 1;
+use Test::More;
 
 my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
 $node_publisher->init(allows_streaming => 'logical');
@@ -43,3 +43,5 @@ pass "subscription disable and drop in same transaction did not hang";
 
 $node_subscriber->stop;
 $node_publisher->stop;
+
+done_testing();
diff --git a/src/test/subscription/t/008_diff_schema.pl b/src/test/subscription/t/008_diff_schema.pl
index c1a88911f4..67b4026afa 100644
--- a/src/test/subscription/t/008_diff_schema.pl
+++ b/src/test/subscription/t/008_diff_schema.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 5;
+use Test::More;
 
 # Create publisher node
 my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
@@ -126,3 +126,5 @@ is( $node_subscriber->safe_psql(
 
 $node_subscriber->stop;
 $node_publisher->stop;
+
+done_testing();
diff --git a/src/test/subscription/t/009_matviews.pl b/src/test/subscription/t/009_matviews.pl
index 8acbbce0a3..1ce696d4a4 100644
--- a/src/test/subscription/t/009_matviews.pl
+++ b/src/test/subscription/t/009_matviews.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 1;
+use Test::More;
 
 my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
 $node_publisher->init(allows_streaming => 'logical');
@@ -50,3 +50,5 @@ pass "materialized view data not replicated";
 
 $node_subscriber->stop;
 $node_publisher->stop;
+
+done_testing();
diff --git a/src/test/subscription/t/010_truncate.pl b/src/test/subscription/t/010_truncate.pl
index 16f0031b03..d519249431 100644
--- a/src/test/subscription/t/010_truncate.pl
+++ b/src/test/subscription/t/010_truncate.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 14;
+use Test::More;
 
 # setup
 
@@ -239,3 +239,5 @@ is($result, qq(0||), 'truncate replicated for multiple subscriptions');
 $result = $node_subscriber->safe_psql('postgres',
 	"SELECT deadlocks FROM pg_stat_database WHERE datname='postgres'");
 is($result, qq(0), 'no deadlocks detected');
+
+done_testing();
diff --git a/src/test/subscription/t/011_generated.pl b/src/test/subscription/t/011_generated.pl
index d2900f648d..e991a08032 100644
--- a/src/test/subscription/t/011_generated.pl
+++ b/src/test/subscription/t/011_generated.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 2;
+use Test::More;
 
 # setup
 
@@ -64,3 +64,5 @@ is( $result, qq(1|22
 3|66
 4|88
 6|132), 'generated columns replicated');
+
+done_testing();
diff --git a/src/test/subscription/t/012_collation.pl b/src/test/subscription/t/012_collation.pl
index 8eb245712e..2182f7948e 100644
--- a/src/test/subscription/t/012_collation.pl
+++ b/src/test/subscription/t/012_collation.pl
@@ -9,11 +9,7 @@ use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
 use Test::More;
 
-if ($ENV{with_icu} eq 'yes')
-{
-	plan tests => 2;
-}
-else
+if ($ENV{with_icu} ne 'yes')
 {
 	plan skip_all => 'ICU not supported by this build';
 }
@@ -108,3 +104,5 @@ $node_publisher->wait_for_catchup('sub1');
 is($node_subscriber->safe_psql('postgres', q{SELECT b FROM tab2}),
 	qq(bar),
 	'update with replica identity full with nondeterministic collation');
+
+done_testing();
diff --git a/src/test/subscription/t/013_partition.pl b/src/test/subscription/t/013_partition.pl
index 85db48ff0a..5266471a7a 100644
--- a/src/test/subscription/t/013_partition.pl
+++ b/src/test/subscription/t/013_partition.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 63;
+use Test::More;
 
 # setup
 
@@ -740,3 +740,5 @@ ok( $logfile =~
 # $node_subscriber1->append_conf('postgresql.conf',
 # 	"log_min_messages = warning");
 # $node_subscriber1->reload;
+
+done_testing();
diff --git a/src/test/subscription/t/014_binary.pl b/src/test/subscription/t/014_binary.pl
index f3cfcbb00e..a1f03e7adc 100644
--- a/src/test/subscription/t/014_binary.pl
+++ b/src/test/subscription/t/014_binary.pl
@@ -7,7 +7,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 5;
+use Test::More;
 
 # Create and initialize a publisher node
 my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
@@ -135,3 +135,5 @@ is( $result, '{1,2,3}|{42,1.2,1.3}|
 
 $node_subscriber->stop('fast');
 $node_publisher->stop('fast');
+
+done_testing();
diff --git a/src/test/subscription/t/015_stream.pl b/src/test/subscription/t/015_stream.pl
index 2385803c18..9f221fc78c 100644
--- a/src/test/subscription/t/015_stream.pl
+++ b/src/test/subscription/t/015_stream.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 4;
+use Test::More;
 
 # Create publisher node
 my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
@@ -133,3 +133,5 @@ is($result, qq(6667|6667|6667),
 
 $node_subscriber->stop;
 $node_publisher->stop;
+
+done_testing();
diff --git a/src/test/subscription/t/016_stream_subxact.pl b/src/test/subscription/t/016_stream_subxact.pl
index c00b6bcc47..f27f1694f2 100644
--- a/src/test/subscription/t/016_stream_subxact.pl
+++ b/src/test/subscription/t/016_stream_subxact.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 2;
+use Test::More;
 
 # Create publisher node
 my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
@@ -91,3 +91,5 @@ is($result, qq(1667|1667|1667),
 
 $node_subscriber->stop;
 $node_publisher->stop;
+
+done_testing();
diff --git a/src/test/subscription/t/017_stream_ddl.pl b/src/test/subscription/t/017_stream_ddl.pl
index fabe033cc2..0bce63b716 100644
--- a/src/test/subscription/t/017_stream_ddl.pl
+++ b/src/test/subscription/t/017_stream_ddl.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 3;
+use Test::More;
 
 # Create publisher node
 my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
@@ -127,3 +127,5 @@ is($result, qq(5005|5002|4005|3004|5),
 
 $node_subscriber->stop;
 $node_publisher->stop;
+
+done_testing();
diff --git a/src/test/subscription/t/018_stream_subxact_abort.pl b/src/test/subscription/t/018_stream_subxact_abort.pl
index 6810895711..7155442e76 100644
--- a/src/test/subscription/t/018_stream_subxact_abort.pl
+++ b/src/test/subscription/t/018_stream_subxact_abort.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 4;
+use Test::More;
 
 # Create publisher node
 my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
@@ -131,3 +131,5 @@ is($result, qq(2500|0), 'check rollback was reflected on subscriber');
 
 $node_subscriber->stop;
 $node_publisher->stop;
+
+done_testing();
diff --git a/src/test/subscription/t/019_stream_subxact_ddl_abort.pl b/src/test/subscription/t/019_stream_subxact_ddl_abort.pl
index 83e2b7ba61..dbd0fca4d1 100644
--- a/src/test/subscription/t/019_stream_subxact_ddl_abort.pl
+++ b/src/test/subscription/t/019_stream_subxact_ddl_abort.pl
@@ -7,7 +7,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 2;
+use Test::More;
 
 # Create publisher node
 my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
@@ -85,3 +85,5 @@ is($result, qq(1000|500),
 
 $node_subscriber->stop;
 $node_publisher->stop;
+
+done_testing();
diff --git a/src/test/subscription/t/020_messages.pl b/src/test/subscription/t/020_messages.pl
index 9bb31ce9e8..b5045ff3c4 100644
--- a/src/test/subscription/t/020_messages.pl
+++ b/src/test/subscription/t/020_messages.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 5;
+use Test::More;
 
 # Create publisher node
 my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
@@ -146,3 +146,5 @@ is( $result, qq(77|0
 
 $node_subscriber->stop('fast');
 $node_publisher->stop('fast');
+
+done_testing();
diff --git a/src/test/subscription/t/021_twophase.pl b/src/test/subscription/t/021_twophase.pl
index 88ef341825..aacc0fcf46 100644
--- a/src/test/subscription/t/021_twophase.pl
+++ b/src/test/subscription/t/021_twophase.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 24;
+use Test::More;
 
 ###############################
 # Setup
@@ -359,3 +359,5 @@ is($result, qq(0), 'check replication origin was dropped on subscriber');
 
 $node_subscriber->stop('fast');
 $node_publisher->stop('fast');
+
+done_testing();
diff --git a/src/test/subscription/t/022_twophase_cascade.pl b/src/test/subscription/t/022_twophase_cascade.pl
index 80680f06a0..900c25d5ce 100644
--- a/src/test/subscription/t/022_twophase_cascade.pl
+++ b/src/test/subscription/t/022_twophase_cascade.pl
@@ -9,7 +9,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 41;
+use Test::More;
 
 ###############################
 # Setup a cascade of pub/sub nodes.
@@ -394,3 +394,5 @@ is($result, qq(0), 'check replication slot was dropped on publisher node A');
 $node_C->stop('fast');
 $node_B->stop('fast');
 $node_A->stop('fast');
+
+done_testing();
diff --git a/src/test/subscription/t/023_twophase_stream.pl b/src/test/subscription/t/023_twophase_stream.pl
index 250fdd550d..93ce3ef132 100644
--- a/src/test/subscription/t/023_twophase_stream.pl
+++ b/src/test/subscription/t/023_twophase_stream.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 18;
+use Test::More;
 
 ###############################
 # Setup
@@ -282,3 +282,5 @@ is($result, qq(0), 'check replication origin was dropped on subscriber');
 
 $node_subscriber->stop('fast');
 $node_publisher->stop('fast');
+
+done_testing();
diff --git a/src/test/subscription/t/024_add_drop_pub.pl b/src/test/subscription/t/024_add_drop_pub.pl
index 015cabf906..561ddde421 100644
--- a/src/test/subscription/t/024_add_drop_pub.pl
+++ b/src/test/subscription/t/024_add_drop_pub.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 3;
+use Test::More;
 
 # Initialize publisher node
 my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
@@ -96,3 +96,5 @@ is($result, qq(20|1|10), 'check initial data is copied to subscriber');
 # shutdown
 $node_subscriber->stop('fast');
 $node_publisher->stop('fast');
+
+done_testing();
diff --git a/src/test/subscription/t/025_rep_changes_for_schema.pl b/src/test/subscription/t/025_rep_changes_for_schema.pl
index 197d68aafd..2a6ba5403d 100644
--- a/src/test/subscription/t/025_rep_changes_for_schema.pl
+++ b/src/test/subscription/t/025_rep_changes_for_schema.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 13;
+use Test::More;
 
 # Initialize publisher node
 my $node_publisher = PostgreSQL::Test::Cluster->new('publisher');
@@ -203,3 +203,5 @@ is($result, qq(21|1|21), 'check replicated inserts on subscriber');
 
 $node_subscriber->stop('fast');
 $node_publisher->stop('fast');
+
+done_testing();
diff --git a/src/test/subscription/t/026_worker_stats.pl b/src/test/subscription/t/026_worker_stats.pl
index 6cf21c8fee..f72e4766e8 100644
--- a/src/test/subscription/t/026_worker_stats.pl
+++ b/src/test/subscription/t/026_worker_stats.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 3;
+use Test::More;
 
 # Test if the error reported on pg_stat_subscription_workers view is expected.
 sub test_subscription_error
@@ -161,3 +161,5 @@ is($result, q(0), 'no error after dropping subscription');
 
 $node_subscriber->stop('fast');
 $node_publisher->stop('fast');
+
+done_testing();
diff --git a/src/test/subscription/t/027_nosuperuser.pl b/src/test/subscription/t/027_nosuperuser.pl
index 4902542b5e..4815e6ccff 100644
--- a/src/test/subscription/t/027_nosuperuser.pl
+++ b/src/test/subscription/t/027_nosuperuser.pl
@@ -5,7 +5,7 @@
 use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
-use Test::More tests => 14;
+use Test::More;
 
 my ($node_publisher, $node_subscriber, $publisher_connstr, $result, $offset);
 $offset = 0;
@@ -278,3 +278,5 @@ publish_delete("alice.unpartitioned", 17);
 expect_replication(
     "alice.unpartitioned", 2, 23, 25,
     "nosuperuser nobypassrls table owner can replicate delete into unpartitioned despite rls");
+
+done_testing();
diff --git a/src/test/subscription/t/100_bugs.pl b/src/test/subscription/t/100_bugs.pl
index dc361756cc..11ba473715 100644
--- a/src/test/subscription/t/100_bugs.pl
+++ b/src/test/subscription/t/100_bugs.pl
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
-use Test::More tests => 7;
+use Test::More;
 
 # Bug #15114
 
@@ -306,3 +306,5 @@ is( $node_subscriber->safe_psql(
 
 $node_publisher->stop('fast');
 $node_subscriber->stop('fast');
+
+done_testing();
-- 
2.24.3 (Apple Git-128)

