initdb: Convert tests to use long options with fat comma style
authorMichael Paquier <[email protected]>
Fri, 24 Jan 2025 06:19:38 +0000 (15:19 +0900)
committerMichael Paquier <[email protected]>
Fri, 24 Jan 2025 06:19:38 +0000 (15:19 +0900)
This is similar to ce1b0f9da03e, but this time this rule is applied to
some of the TAP tests of initdb.

Author: Dagfinn Ilmari MannsÃ¥ker
Discussion: https://postgr.es/m/[email protected]

src/bin/initdb/t/001_initdb.pl

index 5cff5ce5e4d5a630bac0df73c00fd77898e53ad5..01cc4a1602b8ad2ce048771cbe1661e723b72d69 100644 (file)
@@ -50,8 +50,7 @@ mkdir $datadir;
    # while we are here, also exercise --text-search-config and --set options
    command_ok(
        [
-           'initdb',
-           '--no-sync',
+           'initdb', '--no-sync',
            '--text-search-config' => 'german',
            '--set' => 'default_text_search_config=german',
            '--waldir' => $xlogdir,
@@ -101,8 +100,7 @@ SKIP:
    # Init a new db with group access
    my $datadir_group = "$tempdir/data_group";
 
-   command_ok(
-       [ 'initdb', '-g', $datadir_group ],
+   command_ok([ 'initdb', '--allow-group-access', $datadir_group ],
        'successful creation with group access');
 
    ok(check_mode_recursive($datadir_group, 0750, 0640),
@@ -114,14 +112,19 @@ SKIP:
 if ($ENV{with_icu} eq 'yes')
 {
    command_fails_like(
-       [ 'initdb', '--no-sync', '--locale-provider=icu', "$tempdir/data2" ],
+       [
+           'initdb', '--no-sync',
+           '--locale-provider' => 'icu',
+           "$tempdir/data2"
+       ],
        qr/initdb: error: locale must be specified if provider is icu/,
        'locale provider ICU requires --icu-locale');
 
    command_ok(
        [
            'initdb', '--no-sync',
-           '--locale-provider=icu', '--icu-locale=en',
+           '--locale-provider' => 'icu',
+           '--icu-locale' => 'en',
            "$tempdir/data3"
        ],
        'option --icu-locale');
@@ -129,11 +132,15 @@ if ($ENV{with_icu} eq 'yes')
    command_like(
        [
            'initdb', '--no-sync',
-           '-A' => 'trust',
-           '--locale-provider=icu', '--locale=und',
-           '--lc-collate=C', '--lc-ctype=C',
-           '--lc-messages=C', '--lc-numeric=C',
-           '--lc-monetary=C', '--lc-time=C',
+           '--auth' => 'trust',
+           '--locale-provider' => 'icu',
+           '--locale' => 'und',
+           '--lc-collate' => 'C',
+           '--lc-ctype' => 'C',
+           '--lc-messages' => 'C',
+           '--lc-numeric' => 'C',
+           '--lc-monetary' => 'C',
+           '--lc-time' => 'C',
            "$tempdir/data4"
        ],
        qr/^\s+default collation:\s+und\n/ms,
@@ -142,7 +149,8 @@ if ($ENV{with_icu} eq 'yes')
    command_fails_like(
        [
            'initdb', '--no-sync',
-           '--locale-provider=icu', '--icu-locale=@colNumeric=lower',
+           '--locale-provider' => 'icu',
+           '--icu-locale' => '@colNumeric=lower',
            "$tempdir/dataX"
        ],
        qr/could not open collator for locale/,
@@ -151,8 +159,10 @@ if ($ENV{with_icu} eq 'yes')
    command_fails_like(
        [
            'initdb', '--no-sync',
-           '--locale-provider=icu', '--encoding=SQL_ASCII',
-           '--icu-locale=en', "$tempdir/dataX"
+           '--locale-provider' => 'icu',
+           '--encoding' => 'SQL_ASCII',
+           '--icu-locale' => 'en',
+           "$tempdir/dataX"
        ],
        qr/error: encoding mismatch/,
        'fails for encoding not supported by ICU');
@@ -160,7 +170,8 @@ if ($ENV{with_icu} eq 'yes')
    command_fails_like(
        [
            'initdb', '--no-sync',
-           '--locale-provider=icu', '--icu-locale=nonsense-nowhere',
+           '--locale-provider' => 'icu',
+           '--icu-locale' => 'nonsense-nowhere',
            "$tempdir/dataX"
        ],
        qr/error: locale "nonsense-nowhere" has unknown language "nonsense"/,
@@ -169,7 +180,8 @@ if ($ENV{with_icu} eq 'yes')
    command_fails_like(
        [
            'initdb', '--no-sync',
-           '--locale-provider=icu', '--icu-locale=@colNumeric=lower',
+           '--locale-provider' => 'icu',
+           '--icu-locale' => '@colNumeric=lower',
            "$tempdir/dataX"
        ],
        qr/could not open collator for locale "und-u-kn-lower": U_ILLEGAL_ARGUMENT_ERROR/,
@@ -178,18 +190,27 @@ if ($ENV{with_icu} eq 'yes')
 else
 {
    command_fails(
-       [ 'initdb', '--no-sync', '--locale-provider=icu', "$tempdir/data2" ],
+       [
+           'initdb', '--no-sync',
+           '--locale-provider' => 'icu',
+           "$tempdir/data2"
+       ],
        'locale provider ICU fails since no ICU support');
 }
 
 command_fails(
-   [ 'initdb', '--no-sync', '--locale-provider=builtin', "$tempdir/data6" ],
+   [
+       'initdb', '--no-sync',
+       '--locale-provider' => 'builtin',
+       "$tempdir/data6"
+   ],
    'locale provider builtin fails without --locale');
 
 command_ok(
    [
        'initdb', '--no-sync',
-       '--locale-provider=builtin', '--locale=C',
+       '--locale-provider' => 'builtin',
+       '--locale' => 'C',
        "$tempdir/data7"
    ],
    'locale provider builtin with --locale');
@@ -197,18 +218,24 @@ command_ok(
 command_ok(
    [
        'initdb', '--no-sync',
-       '--locale-provider=builtin', '-E UTF-8',
-       '--lc-collate=C', '--lc-ctype=C',
-       '--builtin-locale=C.UTF-8', "$tempdir/data8"
+       '--locale-provider' => 'builtin',
+       '--encoding' => 'UTF-8',
+       '--lc-collate' => 'C',
+       '--lc-ctype' => 'C',
+       '--builtin-locale' => 'C.UTF-8',
+       "$tempdir/data8"
    ],
-   'locale provider builtin with -UTF-8 --builtin-locale=C.UTF-8');
+   'locale provider builtin with --encoding=UTF-8 --builtin-locale=C.UTF-8');
 
 command_fails(
    [
        'initdb', '--no-sync',
-       '--locale-provider=builtin', '-E SQL_ASCII',
-       '--lc-collate=C', '--lc-ctype=C',
-       '--builtin-locale=C.UTF-8', "$tempdir/data9"
+       '--locale-provider' => 'builtin',
+       '--encoding' => 'SQL_ASCII',
+       '--lc-collate' => 'C',
+       '--lc-ctype' => 'C',
+       '--builtin-locale' => 'C.UTF-8',
+       "$tempdir/data9"
    ],
    'locale provider builtin with --builtin-locale=C.UTF-8 fails for SQL_ASCII'
 );
@@ -216,15 +243,18 @@ command_fails(
 command_ok(
    [
        'initdb', '--no-sync',
-       '--locale-provider=builtin', '--lc-ctype=C',
-       '--locale=C', "$tempdir/data10"
+       '--locale-provider' => 'builtin',
+       '--lc-ctype' => 'C',
+       '--locale' => 'C',
+       "$tempdir/data10"
    ],
    'locale provider builtin with --lc-ctype');
 
 command_fails(
    [
        'initdb', '--no-sync',
-       '--locale-provider=builtin', '--icu-locale=en',
+       '--locale-provider' => 'builtin',
+       '--icu-locale' => 'en',
        "$tempdir/dataX"
    ],
    'fails for locale provider builtin with ICU locale');
@@ -232,35 +262,48 @@ command_fails(
 command_fails(
    [
        'initdb', '--no-sync',
-       '--locale-provider=builtin', '--icu-rules=""',
+       '--locale-provider' => 'builtin',
+       '--icu-rules' => '""',
        "$tempdir/dataX"
    ],
    'fails for locale provider builtin with ICU rules');
 
 command_fails(
-   [ 'initdb', '--no-sync', '--locale-provider=xyz', "$tempdir/dataX" ],
+   [
+       'initdb', '--no-sync',
+       '--locale-provider' => 'xyz',
+       "$tempdir/dataX"
+   ],
    'fails for invalid locale provider');
 
 command_fails(
    [
        'initdb', '--no-sync',
-       '--locale-provider=libc', '--icu-locale=en',
+       '--locale-provider' => 'libc',
+       '--icu-locale' => 'en',
        "$tempdir/dataX"
    ],
    'fails for invalid option combination');
 
 command_fails(
-   [ 'initdb', '--no-sync', '--set' => 'foo=bar', "$tempdir/dataX" ],
+   [
+       'initdb', '--no-sync',
+       '--set' => 'foo=bar',
+       "$tempdir/dataX"
+   ],
    'fails for invalid --set option');
 
-# Make sure multiple invocations of -c parameters are added case insensitive
+# Make sure multiple invocations of --set parameters are added case
+# insensitive.
 command_ok(
    [
-       'initdb', '-cwork_mem=128',
-       '-cWork_Mem=256', '-cWORK_MEM=512',
+       'initdb', '--no-sync',
+       '--set' => 'work_mem=128',
+       '--set' => 'Work_Mem=256',
+       '--set' => 'WORK_MEM=512',
        "$tempdir/dataY"
    ],
-   'multiple -c options with different case');
+   'multiple --set options with different case');
 
 my $conf = slurp_file("$tempdir/dataY/postgresql.conf");
 ok($conf !~ qr/^WORK_MEM = /m, "WORK_MEM should not be configured");