From a05a7ec1fa3d7daaea91ef61a76fb4105289363b Mon Sep 17 00:00:00 2001
From: Daniel Gustafsson <daniel@yesql.se>
Date: Wed, 2 Feb 2022 14:44:21 +0100
Subject: [PATCH v2] Ensure that STDERR is empty in connect_ok tests

Connections performed via connect_ok() in TAP tests should not write
anything to STDERR. Ensure that in connect_ok, and adjust the number
of planned tests accordingly.

Author: Jacob Champion <pchampion@vmware.com>
Discussion: https://postgr.es/m/<tbd>
Discussion: https://postgr.es/m/ec146256e31afa0542f9fa970ec258c5f1a5f98.camel@vmware.com
---
 src/test/perl/PostgreSQL/Test/Cluster.pm | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm
index 265f3ae657..da549e5428 100644
--- a/src/test/perl/PostgreSQL/Test/Cluster.pm
+++ b/src/test/perl/PostgreSQL/Test/Cluster.pm
@@ -2185,12 +2185,19 @@ sub connect_ok
 		connstr       => "$connstr",
 		on_error_stop => 0);
 
-	is($ret, 0, $test_name);
-
-	if (defined($params{expected_stdout}))
+	subtest "connect_ok_tests" => sub
 	{
-		like($stdout, $params{expected_stdout}, "$test_name: matches");
-	}
+		is($ret, 0, $test_name);
+
+		if (defined($params{expected_stdout}))
+		{
+			like($stdout, $params{expected_stdout}, "$test_name: stdout matches");
+		}
+
+		is($stderr, "", "$test_name: no stderr");
+		done_testing();
+	};
+
 	if (@log_like or @log_unlike)
 	{
 		my $log_contents = PostgreSQL::Test::Utils::slurp_file($self->logfile, $log_location);
-- 
2.24.3 (Apple Git-128)

