From 278496a655d425313af785a8153d9010044bc4b2 Mon Sep 17 00:00:00 2001
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date: Fri, 9 Aug 2024 14:13:24 +0300
Subject: [PATCH 1/4] If a command dies in a command_checks_all() test, print
 output

I noticed while writing a test case for an assertion failure in
pg_rewind. On assertion failure, it prints out the assertion to
stderr, but command_checks_all() swallowed it.
---
 src/test/perl/PostgreSQL/Test/Utils.pm | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/test/perl/PostgreSQL/Test/Utils.pm b/src/test/perl/PostgreSQL/Test/Utils.pm
index 022b44ba22..64e6d50621 100644
--- a/src/test/perl/PostgreSQL/Test/Utils.pm
+++ b/src/test/perl/PostgreSQL/Test/Utils.pm
@@ -1056,8 +1056,12 @@ sub command_checks_all
 
 	# See http://perldoc.perl.org/perlvar.html#%24CHILD_ERROR
 	my $ret = $?;
-	die "command exited with signal " . ($ret & 127)
-	  if $ret & 127;
+	if ($ret & 127)
+	{
+		diag "stdout: $stdout";
+		diag "stderr: $stderr";
+		die "command exited with signal " . ($ret & 127);
+	}
 	$ret = $ret >> 8;
 
 	# check status
-- 
2.39.2

