From 03d25df987029da7511ff5a6f4ce69d1aef16ea9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilmari@ilmari.org>
Date: Tue, 25 Feb 2025 22:56:12 +0000
Subject: [PATCH 2/2] pg_upgrade: use command_checks_all() to check for errors

pg_upgrade prints its error messages on stdout, so we can't use
command_fails_like() to check that it fails for the right reason.
Instead, we have to use command_checks_all(), which this patch does.
---
 src/bin/pg_upgrade/t/002_pg_upgrade.pl   | 5 ++++-
 src/bin/pg_upgrade/t/004_subscription.pl | 8 +++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/bin/pg_upgrade/t/002_pg_upgrade.pl b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
index 45ea94c84bb..cccba9dc3db 100644
--- a/src/bin/pg_upgrade/t/002_pg_upgrade.pl
+++ b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
@@ -396,7 +396,7 @@ $oldnode->stop;
 # Cause a failure at the start of pg_upgrade, this should create the logging
 # directory pg_upgrade_output.d but leave it around.  Keep --check for an
 # early exit.
-command_fails(
+command_checks_all(
 	[
 		'pg_upgrade', '--no-sync',
 		'-d', $oldnode->data_dir,
@@ -408,6 +408,9 @@ command_fails(
 		'-P', $newnode->port,
 		$mode, '--check',
 	],
+	1,
+	[qr{check for ".*?does.not.exist" failed:}],
+	[],
 	'run of pg_upgrade --check for new instance with incorrect binary path');
 ok(-d $newnode->data_dir . "/pg_upgrade_output.d",
 	"pg_upgrade_output.d/ not removed after pg_upgrade failure");
diff --git a/src/bin/pg_upgrade/t/004_subscription.pl b/src/bin/pg_upgrade/t/004_subscription.pl
index 13773316e1d..3f9734f7b3f 100644
--- a/src/bin/pg_upgrade/t/004_subscription.pl
+++ b/src/bin/pg_upgrade/t/004_subscription.pl
@@ -130,7 +130,7 @@ $old_sub->safe_psql('postgres',
 
 $old_sub->stop;
 
-command_fails(
+command_checks_all(
 	[
 		'pg_upgrade',
 		'--no-sync',
@@ -144,6 +144,12 @@ command_fails(
 		$mode,
 		'--check',
 	],
+	1,
+	[
+		qr{\QYour installation contains subscriptions without origin},
+		qr{\Qrelations not in i (initialize) or r (ready) state},
+	],
+	[],
 	'run of pg_upgrade --check for old instance with relation in \'d\' datasync(invalid) state and missing replication origin'
 );
 
-- 
2.43.0

