Skip to content

Commit 19c6e92

Browse files
committed
Apply more consistent style for command options in TAP tests
This commit reshapes the grammar of some commands to apply a more consistent style across the board, following rules similar to ce1b0f9: - Elimination of some pointless used-once variables. - Use of long options, to self-document better the options used. - Use of fat commas to link option names and their assigned values, including redirections, so as perltidy can be tricked to put them together. Author: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> Discussion: https://postgr.es/m/87jz8rzf3h.fsf@wibble.ilmari.org
1 parent 5721e54 commit 19c6e92

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+522
-399
lines changed

contrib/auto_explain/t/001_auto_explain.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ sub query_log
2828
}
2929

3030
my $node = PostgreSQL::Test::Cluster->new('main');
31-
$node->init('auth_extra' => [ '--create-role', 'regress_user1' ]);
31+
$node->init('auth_extra' => [ '--create-role' => 'regress_user1' ]);
3232
$node->append_conf('postgresql.conf',
3333
"session_preload_libraries = 'auto_explain'");
3434
$node->append_conf('postgresql.conf', "auto_explain.log_min_duration = 0");

contrib/basebackup_to_shell/t/001_basic.pl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,10 @@ sub verify_backup
131131

132132
# Untar.
133133
my $extract_path = PostgreSQL::Test::Utils::tempdir;
134-
system_or_bail($tar, 'xf', $backup_dir . '/' . $prefix . 'base.tar',
135-
'-C', $extract_path);
134+
system_or_bail(
135+
$tar,
136+
'xf' => $backup_dir . '/' . $prefix . 'base.tar',
137+
'-C' => $extract_path);
136138

137139
# Verify.
138140
$node->command_ok(

contrib/sepgsql/t/001_sepgsql.pl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,7 @@
216216
'-D' => $node->data_dir,
217217
'template0'
218218
],
219-
'<',
220-
$ENV{share_contrib_dir} . '/sepgsql.sql');
219+
'<' => $ENV{share_contrib_dir} . '/sepgsql.sql');
221220
ok($result, 'sepgsql installation script');
222221
}
223222

src/bin/pg_archivecleanup/t/010_pg_archivecleanup.pl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,11 @@ sub remove_files
8585

8686
my $stderr;
8787
my $oldestkeptwalfile = '00000001000000370000000E';
88-
my $result =
89-
IPC::Run::run [ 'pg_archivecleanup', '-d', '-n', $tempdir,
90-
$oldestkeptwalfile ],
91-
'2>', \$stderr;
88+
my $result = IPC::Run::run [
89+
'pg_archivecleanup', '--debug', '--dry-run', $tempdir,
90+
$oldestkeptwalfile
91+
],
92+
'2>' => \$stderr;
9293
ok($result, "pg_archivecleanup dry run: exit code 0");
9394

9495
for my $walpair (@walfiles_verbose)

src/bin/pg_resetwal/t/002_corrupted.pl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
6060
[ 'pg_resetwal', $node->data_dir ],
6161
qr/not proceeding because control file values were guessed/,
6262
'does not run when control file values were guessed');
63-
command_ok([ 'pg_resetwal', '-f', $node->data_dir ],
63+
command_ok(
64+
[ 'pg_resetwal', '--force', $node->data_dir ],
6465
'runs with force when control file values were guessed');
6566

6667
done_testing();

src/bin/pg_rewind/t/009_growing_files.pl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@
5656
'--target-pgdata' => $primary_pgdata,
5757
'--no-sync',
5858
],
59-
'2>>',
60-
"$standby_pgdata/tst_both_dir/file1");
59+
'2>>' => "$standby_pgdata/tst_both_dir/file1");
6160
ok(!$ret, 'Error out on copying growing file');
6261

6362
# Ensure that the files are of different size, the final error message should

src/bin/pg_rewind/t/RewindTest.pm

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ sub primary_psql
6969
my $cmd = shift;
7070
my $dbname = shift || 'postgres';
7171

72-
system_or_bail 'psql', '-q', '--no-psqlrc', '-d',
73-
$node_primary->connstr($dbname), '-c', "$cmd";
72+
system_or_bail 'psql', '--quiet', '--no-psqlrc',
73+
'--dbname' => $node_primary->connstr($dbname),
74+
'--command' => $cmd;
7475
return;
7576
}
7677

@@ -79,8 +80,9 @@ sub standby_psql
7980
my $cmd = shift;
8081
my $dbname = shift || 'postgres';
8182

82-
system_or_bail 'psql', '-q', '--no-psqlrc', '-d',
83-
$node_standby->connstr($dbname), '-c', "$cmd";
83+
system_or_bail 'psql', '--quiet', '--no-psqlrc',
84+
'--dbname' => $node_standby->connstr($dbname),
85+
'--command' => $cmd;
8486
return;
8587
}
8688

@@ -95,11 +97,12 @@ sub check_query
9597

9698
# we want just the output, no formatting
9799
my $result = run [
98-
'psql', '-q', '-A', '-t', '--no-psqlrc', '-d',
99-
$node_primary->connstr('postgres'),
100-
'-c', $query
100+
'psql', '--quiet', '--no-align', '--tuples-only', '--no-psqlrc',
101+
'--dbname' => $node_primary->connstr('postgres'),
102+
'--command' => $query
101103
],
102-
'>', \$stdout, '2>', \$stderr;
104+
'>' => \$stdout,
105+
'2>' => \$stderr;
103106

104107
is($result, 1, "$test_name: psql exit code");
105108
is($stderr, '', "$test_name: psql no stderr");
@@ -124,7 +127,7 @@ sub setup_cluster
124127
$node_primary->init(
125128
allows_streaming => 1,
126129
extra => $extra,
127-
auth_extra => [ '--create-role', 'rewind_user' ]);
130+
auth_extra => [ '--create-role' => 'rewind_user' ]);
128131

129132
# Set wal_keep_size to prevent WAL segment recycling after enforced
130133
# checkpoints in the tests.

src/bin/pg_upgrade/t/002_pg_upgrade.pl

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ sub filter_dump
208208

209209
# Load the dump using the "postgres" database as "regression" does
210210
# not exist yet, and we are done here.
211-
$oldnode->command_ok([ 'psql', '-X', '-f', $olddumpfile, 'postgres' ],
211+
$oldnode->command_ok(
212+
[ 'psql', '--no-psqlrc', '--file' => $olddumpfile, 'postgres' ],
212213
'loaded old dump file');
213214
}
214215
else
@@ -303,14 +304,15 @@ sub filter_dump
303304
my @command_args = ();
304305
for my $upcmd (@{ $adjust_cmds->{$updb} })
305306
{
306-
push @command_args, '-c', $upcmd;
307+
push @command_args, '--command' => $upcmd;
307308
}
308309

309310
# For simplicity, use the newer version's psql to issue the commands.
310311
$newnode->command_ok(
311312
[
312-
'psql', '-X', '-v', 'ON_ERROR_STOP=1',
313-
'-d', $oldnode->connstr($updb),
313+
'psql', '--no-psqlrc',
314+
'--set' => 'ON_ERROR_STOP=1',
315+
'--dbname' => $oldnode->connstr($updb),
314316
@command_args,
315317
],
316318
"ran version adaptation commands for database $updb");
@@ -324,8 +326,9 @@ sub filter_dump
324326
# Take a dump before performing the upgrade as a base comparison. Note
325327
# that we need to use pg_dumpall from the new node here.
326328
my @dump_command = (
327-
'pg_dumpall', '--no-sync', '-d', $oldnode->connstr('postgres'),
328-
'-f', $dump1_file);
329+
'pg_dumpall', '--no-sync',
330+
'--dbname' => $oldnode->connstr('postgres'),
331+
'--file' => $dump1_file);
329332
# --extra-float-digits is needed when upgrading from a version older than 11.
330333
push(@dump_command, '--extra-float-digits', '0')
331334
if ($oldnode->pg_version < 12);
@@ -399,13 +402,13 @@ sub filter_dump
399402
command_checks_all(
400403
[
401404
'pg_upgrade', '--no-sync',
402-
'-d', $oldnode->data_dir,
403-
'-D', $newnode->data_dir,
404-
'-b', $oldbindir . '/does/not/exist/',
405-
'-B', $newbindir,
406-
'-s', $newnode->host,
407-
'-p', $oldnode->port,
408-
'-P', $newnode->port,
405+
'--old-datadir' => $oldnode->data_dir,
406+
'--new-datadir' => $newnode->data_dir,
407+
'--old-bindir' => $oldbindir . '/does/not/exist/',
408+
'--new-bindir' => $newbindir,
409+
'--socketdir' => $newnode->host,
410+
'--old-port' => $oldnode->port,
411+
'--new-port' => $newnode->port,
409412
$mode, '--check',
410413
],
411414
1,
@@ -427,13 +430,13 @@ sub filter_dump
427430
command_checks_all(
428431
[
429432
'pg_upgrade', '--no-sync',
430-
'-d', $oldnode->data_dir,
431-
'-D', $newnode->data_dir,
432-
'-b', $oldbindir,
433-
'-B', $newbindir,
434-
'-s', $newnode->host,
435-
'-p', $oldnode->port,
436-
'-P', $newnode->port,
433+
'--old-datadir' => $oldnode->data_dir,
434+
'--new-datadir' => $newnode->data_dir,
435+
'--old-bindir' => $oldbindir,
436+
'--new-bindir' => $newbindir,
437+
'--socketdir' => $newnode->host,
438+
'--old-port' => $oldnode->port,
439+
'--new-port' => $newnode->port,
437440
$mode, '--check',
438441
],
439442
1,
@@ -451,10 +454,14 @@ sub filter_dump
451454
# --check command works here, cleans up pg_upgrade_output.d.
452455
command_ok(
453456
[
454-
'pg_upgrade', '--no-sync', '-d', $oldnode->data_dir,
455-
'-D', $newnode->data_dir, '-b', $oldbindir,
456-
'-B', $newbindir, '-s', $newnode->host,
457-
'-p', $oldnode->port, '-P', $newnode->port,
457+
'pg_upgrade', '--no-sync',
458+
'--old-datadir' => $oldnode->data_dir,
459+
'--new-datadir' => $newnode->data_dir,
460+
'--old-bindir' => $oldbindir,
461+
'--new-bindir' => $newbindir,
462+
'--socketdir' => $newnode->host,
463+
'--old-port' => $oldnode->port,
464+
'--new-port' => $newnode->port,
458465
$mode, '--check',
459466
],
460467
'run of pg_upgrade --check for new instance');
@@ -464,10 +471,14 @@ sub filter_dump
464471
# Actual run, pg_upgrade_output.d is removed at the end.
465472
command_ok(
466473
[
467-
'pg_upgrade', '--no-sync', '-d', $oldnode->data_dir,
468-
'-D', $newnode->data_dir, '-b', $oldbindir,
469-
'-B', $newbindir, '-s', $newnode->host,
470-
'-p', $oldnode->port, '-P', $newnode->port,
474+
'pg_upgrade', '--no-sync',
475+
'--old-datadir' => $oldnode->data_dir,
476+
'--new-datadir' => $newnode->data_dir,
477+
'--old-bindir' => $oldbindir,
478+
'--new-bindir' => $newbindir,
479+
'--socketdir' => $newnode->host,
480+
'--old-port' => $oldnode->port,
481+
'--new-port' => $newnode->port,
471482
$mode,
472483
],
473484
'run of pg_upgrade for new instance');
@@ -512,10 +523,11 @@ sub filter_dump
512523

513524
# Second dump from the upgraded instance.
514525
@dump_command = (
515-
'pg_dumpall', '--no-sync', '-d', $newnode->connstr('postgres'),
516-
'-f', $dump2_file);
526+
'pg_dumpall', '--no-sync',
527+
'--dbname' => $newnode->connstr('postgres'),
528+
'--file' => $dump2_file);
517529
# --extra-float-digits is needed when upgrading from a version older than 11.
518-
push(@dump_command, '--extra-float-digits', '0')
530+
push(@dump_command, '--extra-float-digits' => '0')
519531
if ($oldnode->pg_version < 12);
520532
$newnode->command_ok(\@dump_command, 'dump after running pg_upgrade');
521533

src/bin/pg_upgrade/t/003_logical_slots.pl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@
4040
# Setup a common pg_upgrade command to be used by all the test cases
4141
my @pg_upgrade_cmd = (
4242
'pg_upgrade', '--no-sync',
43-
'-d', $oldpub->data_dir,
44-
'-D', $newpub->data_dir,
45-
'-b', $oldpub->config_data('--bindir'),
46-
'-B', $newpub->config_data('--bindir'),
47-
'-s', $newpub->host,
48-
'-p', $oldpub->port,
49-
'-P', $newpub->port,
43+
'--old-datadir' => $oldpub->data_dir,
44+
'--new-datadir' => $newpub->data_dir,
45+
'--old-bindir' => $oldpub->config_data('--bindir'),
46+
'--new-bindir' => $newpub->config_data('--bindir'),
47+
'--socketdir' => $newpub->host,
48+
'--old-port' => $oldpub->port,
49+
'--new-port' => $newpub->port,
5050
$mode);
5151

5252
# In a VPATH build, we'll be started in the source directory, but we want

src/bin/pg_upgrade/t/005_char_signedness.pl

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@
3131

3232
# Set the old cluster's default char signedness to unsigned for test.
3333
command_ok(
34-
[ 'pg_resetwal', '--char-signedness', 'unsigned', '-f', $old->data_dir ],
34+
[
35+
'pg_resetwal',
36+
'--char-signedness' => 'unsigned',
37+
'--force',
38+
$old->data_dir
39+
],
3540
"set old cluster's default char signedness to unsigned");
3641

3742
# Check if the value is successfully updated.
@@ -44,14 +49,14 @@
4449
command_checks_all(
4550
[
4651
'pg_upgrade', '--no-sync',
47-
'-d', $old->data_dir,
48-
'-D', $new->data_dir,
49-
'-b', $old->config_data('--bindir'),
50-
'-B', $new->config_data('--bindir'),
51-
'-s', $new->host,
52-
'-p', $old->port,
53-
'-P', $new->port,
54-
'--set-char-signedness', 'signed',
52+
'--old-datadir' => $old->data_dir,
53+
'--new-datadir' => $new->data_dir,
54+
'--old-bindir' => $old->config_data('--bindir'),
55+
'--new-bindir' => $new->config_data('--bindir'),
56+
'--socketdir' => $new->host,
57+
'--old-port' => $old->port,
58+
'--new-port' => $new->port,
59+
'--set-char-signedness' => 'signed',
5560
$mode
5661
],
5762
1,
@@ -64,13 +69,13 @@
6469
command_ok(
6570
[
6671
'pg_upgrade', '--no-sync',
67-
'-d', $old->data_dir,
68-
'-D', $new->data_dir,
69-
'-b', $old->config_data('--bindir'),
70-
'-B', $new->config_data('--bindir'),
71-
'-s', $new->host,
72-
'-p', $old->port,
73-
'-P', $new->port,
72+
'--old-datadir' => $old->data_dir,
73+
'--new-datadir' => $new->data_dir,
74+
'--old-bindir' => $old->config_data('--bindir'),
75+
'--new-bindir' => $new->config_data('--bindir'),
76+
'--socketdir' => $new->host,
77+
'--old-port' => $old->port,
78+
'--new-port' => $new->port,
7479
$mode
7580
],
7681
'run of pg_upgrade');

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy