diff options
author | Michael Paquier | 2025-01-22 05:47:13 +0000 |
---|---|---|
committer | Michael Paquier | 2025-01-22 05:47:13 +0000 |
commit | ce1b0f9da03e1cebc293f60b378079b22bd7cc0f (patch) | |
tree | 78c3030de2cc9d201168e8297b5754bf35e37fd2 /src/bin/initdb | |
parent | 4a0e7314f11ee03adfe9df945598c068b4179314 (diff) |
Improve grammar of options for command arrays in TAP tests
This commit rewrites a good chunk of the command arrays in TAP tests
with a grammar based on the following rules:
- Fat commas are used between option names and their values, making it
clear to both humans and perltidy that values and names are bound
together. This is particularly useful for the readability of multi-line
command arrays, and there are plenty of them in the TAP tests. Most of
the test code is updated to use this style. Some commands used
parenthesis to show the link, or attached values and options in a single
string. These are updated to use fat commas instead.
- Option names are switched to use their long names, making them more
self-documented. Based on a suggestion by Andrew Dunstan.
- Add some trailing commas after the last item in multi-line arrays,
which is a common perl style.
Not all the places are taken care of, but this covers a very good chunk
of them.
Author: Dagfinn Ilmari Mannsåker
Reviewed-by: Michael Paquier, Peter Smith, Euler Taveira
Discussion: https://postgr.es/m/87jzc46d8u.fsf@wibble.ilmari.org
Diffstat (limited to 'src/bin/initdb')
-rw-r--r-- | src/bin/initdb/t/001_initdb.pl | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/bin/initdb/t/001_initdb.pl b/src/bin/initdb/t/001_initdb.pl index f114c2a1b62..5cff5ce5e4d 100644 --- a/src/bin/initdb/t/001_initdb.pl +++ b/src/bin/initdb/t/001_initdb.pl @@ -22,21 +22,19 @@ program_help_ok('initdb'); program_version_ok('initdb'); program_options_handling_ok('initdb'); -command_fails([ 'initdb', '-S', "$tempdir/nonexistent" ], +command_fails([ 'initdb', '--sync-only', "$tempdir/nonexistent" ], 'sync missing data directory'); mkdir $xlogdir; mkdir "$xlogdir/lost+found"; -command_fails( - [ 'initdb', '-X', $xlogdir, $datadir ], +command_fails([ 'initdb', '--waldir' => $xlogdir, $datadir ], 'existing nonempty xlog directory'); rmdir "$xlogdir/lost+found"; command_fails( - [ 'initdb', '-X', 'pgxlog', $datadir ], + [ 'initdb', '--waldir' => 'pgxlog', $datadir ], 'relative xlog directory not allowed'); -command_fails( - [ 'initdb', '-U', 'pg_test', $datadir ], +command_fails([ 'initdb', '--username' => 'pg_test', $datadir ], 'role names cannot begin with "pg_"'); mkdir $datadir; @@ -49,12 +47,15 @@ mkdir $datadir; local (%ENV) = %ENV; delete $ENV{TZ}; - # while we are here, also exercise -T and -c options + # while we are here, also exercise --text-search-config and --set options command_ok( [ - 'initdb', '-N', '-T', 'german', '-c', - 'default_text_search_config=german', - '-X', $xlogdir, $datadir + 'initdb', + '--no-sync', + '--text-search-config' => 'german', + '--set' => 'default_text_search_config=german', + '--waldir' => $xlogdir, + $datadir ], 'successful creation'); @@ -75,17 +76,19 @@ command_like( qr/Data page checksum version:.*1/, 'checksums are enabled in control file'); -command_ok([ 'initdb', '-S', $datadir ], 'sync only'); +command_ok([ 'initdb', '--sync-only', $datadir ], 'sync only'); command_fails([ 'initdb', $datadir ], 'existing data directory'); if ($supports_syncfs) { - command_ok([ 'initdb', '-S', $datadir, '--sync-method', 'syncfs' ], + command_ok( + [ 'initdb', '--sync-only', $datadir, '--sync-method' => 'syncfs' ], 'sync method syncfs'); } else { - command_fails([ 'initdb', '-S', $datadir, '--sync-method', 'syncfs' ], + command_fails( + [ 'initdb', '--sync-only', $datadir, '--sync-method' => 'syncfs' ], 'sync method syncfs'); } @@ -126,7 +129,7 @@ if ($ENV{with_icu} eq 'yes') command_like( [ 'initdb', '--no-sync', - '-A', 'trust', + '-A' => 'trust', '--locale-provider=icu', '--locale=und', '--lc-collate=C', '--lc-ctype=C', '--lc-messages=C', '--lc-numeric=C', @@ -246,7 +249,8 @@ command_fails( ], 'fails for invalid option combination'); -command_fails([ 'initdb', '--no-sync', '--set', 'foo=bar', "$tempdir/dataX" ], +command_fails( + [ 'initdb', '--no-sync', '--set' => 'foo=bar', "$tempdir/dataX" ], 'fails for invalid --set option'); # Make sure multiple invocations of -c parameters are added case insensitive @@ -279,7 +283,7 @@ command_like( # not part of the tests included in pg_checksums to save from # the creation of an extra instance. command_fails( - [ 'pg_checksums', '-D', $datadir_nochecksums ], + [ 'pg_checksums', '--pgdata' => $datadir_nochecksums ], "pg_checksums fails with data checksum disabled"); done_testing(); |