From 67bd8fbf906111b7d172777bcea88d6653b35085 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilmari@ilmari.org>
Date: Wed, 22 Jan 2025 14:53:16 +0000
Subject: [PATCH 3/3] TAP tests: consistently specify the pg_ctl action before
 options

Most pg_ctl invocations in the tests are this way, this brings the
rest into line.
---
 src/bin/pg_ctl/t/002_status.pl              |  4 ++--
 src/bin/pg_ctl/t/003_promote.pl             | 14 +++++++-------
 src/test/recovery/t/003_recovery_targets.pl |  6 ++----
 src/test/recovery/t/024_archive_recovery.pl |  3 +--
 4 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/src/bin/pg_ctl/t/002_status.pl b/src/bin/pg_ctl/t/002_status.pl
index 346f6919ac6..ba8db118aa4 100644
--- a/src/bin/pg_ctl/t/002_status.pl
+++ b/src/bin/pg_ctl/t/002_status.pl
@@ -20,10 +20,10 @@
 	3, 'pg_ctl status with server not running');
 
 system_or_bail(
-	'pg_ctl',
+	'pg_ctl', 'start',
 	'--log' => "$tempdir/logfile",
 	'--pgdata' => $node->data_dir,
-	'--wait', 'start');
+	'--wait');
 command_exit_is([ 'pg_ctl', 'status', '--pgdata' => $node->data_dir ],
 	0, 'pg_ctl status with server running');
 
diff --git a/src/bin/pg_ctl/t/003_promote.pl b/src/bin/pg_ctl/t/003_promote.pl
index 43a9bbac2ac..20948a558cd 100644
--- a/src/bin/pg_ctl/t/003_promote.pl
+++ b/src/bin/pg_ctl/t/003_promote.pl
@@ -11,7 +11,7 @@
 my $tempdir = PostgreSQL::Test::Utils::tempdir;
 
 command_fails_like(
-	[ 'pg_ctl', '--pgdata' => "$tempdir/nonexistent", 'promote' ],
+	[ 'pg_ctl', 'promote', '--pgdata' => "$tempdir/nonexistent" ],
 	qr/directory .* does not exist/,
 	'pg_ctl promote with nonexistent directory');
 
@@ -19,14 +19,14 @@
 $node_primary->init(allows_streaming => 1);
 
 command_fails_like(
-	[ 'pg_ctl', '--pgdata' => $node_primary->data_dir, 'promote' ],
+	[ 'pg_ctl', 'promote', '--pgdata' => $node_primary->data_dir ],
 	qr/PID file .* does not exist/,
 	'pg_ctl promote of not running instance fails');
 
 $node_primary->start;
 
 command_fails_like(
-	[ 'pg_ctl', '--pgdata' => $node_primary->data_dir, 'promote' ],
+	[ 'pg_ctl', 'promote', '--pgdata' => $node_primary->data_dir ],
 	qr/not in standby mode/,
 	'pg_ctl promote of primary instance fails');
 
@@ -41,11 +41,11 @@
 
 command_ok(
 	[
-		'pg_ctl',
+		'pg_ctl', 'promote',
 		'--pgdata' => $node_standby->data_dir,
-		'--no-wait', 'promote'
+		'--no-wait',
 	],
-	'pg_ctl --no-wait promote of standby runs');
+	'pg_ctl promote --no-wait of standby runs');
 
 ok( $node_standby->poll_query_until(
 		'postgres', 'SELECT NOT pg_is_in_recovery()'),
@@ -60,7 +60,7 @@
 is($node_standby->safe_psql('postgres', 'SELECT pg_is_in_recovery()'),
 	't', 'standby is in recovery');
 
-command_ok([ 'pg_ctl', '--pgdata' => $node_standby->data_dir, 'promote' ],
+command_ok([ 'pg_ctl', 'promote', '--pgdata' => $node_standby->data_dir ],
 	'pg_ctl promote of standby runs');
 
 # no wait here
diff --git a/src/test/recovery/t/003_recovery_targets.pl b/src/test/recovery/t/003_recovery_targets.pl
index 0ae2e982727..65dcb6ce04a 100644
--- a/src/test/recovery/t/003_recovery_targets.pl
+++ b/src/test/recovery/t/003_recovery_targets.pl
@@ -147,10 +147,9 @@ sub test_recovery_standby
 
 my $res = run_log(
 	[
-		'pg_ctl',
+		'pg_ctl', 'start',
 		'--pgdata' => $node_standby->data_dir,
 		'--log' => $node_standby->logfile,
-		'start',
 	]);
 ok(!$res, 'invalid recovery startup fails');
 
@@ -170,10 +169,9 @@ sub test_recovery_standby
 
 run_log(
 	[
-		'pg_ctl',
+		'pg_ctl', 'start',
 		'--pgdata' => $node_standby->data_dir,
 		'--log' => $node_standby->logfile,
-		'start',
 	]);
 
 # wait for postgres to terminate
diff --git a/src/test/recovery/t/024_archive_recovery.pl b/src/test/recovery/t/024_archive_recovery.pl
index b4527ec0843..fb4ba980743 100644
--- a/src/test/recovery/t/024_archive_recovery.pl
+++ b/src/test/recovery/t/024_archive_recovery.pl
@@ -76,10 +76,9 @@ sub test_recovery_wal_level_minimal
 	# that the server ends with an error during recovery.
 	run_log(
 		[
-			'pg_ctl',
+			'pg_ctl', 'start',
 			'--pgdata' => $recovery_node->data_dir,
 			'--log' => $recovery_node->logfile,
-			'start',
 		]);
 
 	# wait for postgres to terminate
-- 
2.48.1

