mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
initdb: Convert tests to use long options with fat comma style
This is similar to ce1b0f9da0
, 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/878qr146ra.fsf@wibble.ilmari.org
This commit is contained in:
@ -50,8 +50,7 @@ mkdir $datadir;
|
|||||||
# while we are here, also exercise --text-search-config and --set options
|
# while we are here, also exercise --text-search-config and --set options
|
||||||
command_ok(
|
command_ok(
|
||||||
[
|
[
|
||||||
'initdb',
|
'initdb', '--no-sync',
|
||||||
'--no-sync',
|
|
||||||
'--text-search-config' => 'german',
|
'--text-search-config' => 'german',
|
||||||
'--set' => 'default_text_search_config=german',
|
'--set' => 'default_text_search_config=german',
|
||||||
'--waldir' => $xlogdir,
|
'--waldir' => $xlogdir,
|
||||||
@ -101,8 +100,7 @@ SKIP:
|
|||||||
# Init a new db with group access
|
# Init a new db with group access
|
||||||
my $datadir_group = "$tempdir/data_group";
|
my $datadir_group = "$tempdir/data_group";
|
||||||
|
|
||||||
command_ok(
|
command_ok([ 'initdb', '--allow-group-access', $datadir_group ],
|
||||||
[ 'initdb', '-g', $datadir_group ],
|
|
||||||
'successful creation with group access');
|
'successful creation with group access');
|
||||||
|
|
||||||
ok(check_mode_recursive($datadir_group, 0750, 0640),
|
ok(check_mode_recursive($datadir_group, 0750, 0640),
|
||||||
@ -114,14 +112,19 @@ SKIP:
|
|||||||
if ($ENV{with_icu} eq 'yes')
|
if ($ENV{with_icu} eq 'yes')
|
||||||
{
|
{
|
||||||
command_fails_like(
|
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/,
|
qr/initdb: error: locale must be specified if provider is icu/,
|
||||||
'locale provider ICU requires --icu-locale');
|
'locale provider ICU requires --icu-locale');
|
||||||
|
|
||||||
command_ok(
|
command_ok(
|
||||||
[
|
[
|
||||||
'initdb', '--no-sync',
|
'initdb', '--no-sync',
|
||||||
'--locale-provider=icu', '--icu-locale=en',
|
'--locale-provider' => 'icu',
|
||||||
|
'--icu-locale' => 'en',
|
||||||
"$tempdir/data3"
|
"$tempdir/data3"
|
||||||
],
|
],
|
||||||
'option --icu-locale');
|
'option --icu-locale');
|
||||||
@ -129,11 +132,15 @@ if ($ENV{with_icu} eq 'yes')
|
|||||||
command_like(
|
command_like(
|
||||||
[
|
[
|
||||||
'initdb', '--no-sync',
|
'initdb', '--no-sync',
|
||||||
'-A' => 'trust',
|
'--auth' => 'trust',
|
||||||
'--locale-provider=icu', '--locale=und',
|
'--locale-provider' => 'icu',
|
||||||
'--lc-collate=C', '--lc-ctype=C',
|
'--locale' => 'und',
|
||||||
'--lc-messages=C', '--lc-numeric=C',
|
'--lc-collate' => 'C',
|
||||||
'--lc-monetary=C', '--lc-time=C',
|
'--lc-ctype' => 'C',
|
||||||
|
'--lc-messages' => 'C',
|
||||||
|
'--lc-numeric' => 'C',
|
||||||
|
'--lc-monetary' => 'C',
|
||||||
|
'--lc-time' => 'C',
|
||||||
"$tempdir/data4"
|
"$tempdir/data4"
|
||||||
],
|
],
|
||||||
qr/^\s+default collation:\s+und\n/ms,
|
qr/^\s+default collation:\s+und\n/ms,
|
||||||
@ -142,7 +149,8 @@ if ($ENV{with_icu} eq 'yes')
|
|||||||
command_fails_like(
|
command_fails_like(
|
||||||
[
|
[
|
||||||
'initdb', '--no-sync',
|
'initdb', '--no-sync',
|
||||||
'--locale-provider=icu', '--icu-locale=@colNumeric=lower',
|
'--locale-provider' => 'icu',
|
||||||
|
'--icu-locale' => '@colNumeric=lower',
|
||||||
"$tempdir/dataX"
|
"$tempdir/dataX"
|
||||||
],
|
],
|
||||||
qr/could not open collator for locale/,
|
qr/could not open collator for locale/,
|
||||||
@ -151,8 +159,10 @@ if ($ENV{with_icu} eq 'yes')
|
|||||||
command_fails_like(
|
command_fails_like(
|
||||||
[
|
[
|
||||||
'initdb', '--no-sync',
|
'initdb', '--no-sync',
|
||||||
'--locale-provider=icu', '--encoding=SQL_ASCII',
|
'--locale-provider' => 'icu',
|
||||||
'--icu-locale=en', "$tempdir/dataX"
|
'--encoding' => 'SQL_ASCII',
|
||||||
|
'--icu-locale' => 'en',
|
||||||
|
"$tempdir/dataX"
|
||||||
],
|
],
|
||||||
qr/error: encoding mismatch/,
|
qr/error: encoding mismatch/,
|
||||||
'fails for encoding not supported by ICU');
|
'fails for encoding not supported by ICU');
|
||||||
@ -160,7 +170,8 @@ if ($ENV{with_icu} eq 'yes')
|
|||||||
command_fails_like(
|
command_fails_like(
|
||||||
[
|
[
|
||||||
'initdb', '--no-sync',
|
'initdb', '--no-sync',
|
||||||
'--locale-provider=icu', '--icu-locale=nonsense-nowhere',
|
'--locale-provider' => 'icu',
|
||||||
|
'--icu-locale' => 'nonsense-nowhere',
|
||||||
"$tempdir/dataX"
|
"$tempdir/dataX"
|
||||||
],
|
],
|
||||||
qr/error: locale "nonsense-nowhere" has unknown language "nonsense"/,
|
qr/error: locale "nonsense-nowhere" has unknown language "nonsense"/,
|
||||||
@ -169,7 +180,8 @@ if ($ENV{with_icu} eq 'yes')
|
|||||||
command_fails_like(
|
command_fails_like(
|
||||||
[
|
[
|
||||||
'initdb', '--no-sync',
|
'initdb', '--no-sync',
|
||||||
'--locale-provider=icu', '--icu-locale=@colNumeric=lower',
|
'--locale-provider' => 'icu',
|
||||||
|
'--icu-locale' => '@colNumeric=lower',
|
||||||
"$tempdir/dataX"
|
"$tempdir/dataX"
|
||||||
],
|
],
|
||||||
qr/could not open collator for locale "und-u-kn-lower": U_ILLEGAL_ARGUMENT_ERROR/,
|
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
|
else
|
||||||
{
|
{
|
||||||
command_fails(
|
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');
|
'locale provider ICU fails since no ICU support');
|
||||||
}
|
}
|
||||||
|
|
||||||
command_fails(
|
command_fails(
|
||||||
[ 'initdb', '--no-sync', '--locale-provider=builtin', "$tempdir/data6" ],
|
[
|
||||||
|
'initdb', '--no-sync',
|
||||||
|
'--locale-provider' => 'builtin',
|
||||||
|
"$tempdir/data6"
|
||||||
|
],
|
||||||
'locale provider builtin fails without --locale');
|
'locale provider builtin fails without --locale');
|
||||||
|
|
||||||
command_ok(
|
command_ok(
|
||||||
[
|
[
|
||||||
'initdb', '--no-sync',
|
'initdb', '--no-sync',
|
||||||
'--locale-provider=builtin', '--locale=C',
|
'--locale-provider' => 'builtin',
|
||||||
|
'--locale' => 'C',
|
||||||
"$tempdir/data7"
|
"$tempdir/data7"
|
||||||
],
|
],
|
||||||
'locale provider builtin with --locale');
|
'locale provider builtin with --locale');
|
||||||
@ -197,18 +218,24 @@ command_ok(
|
|||||||
command_ok(
|
command_ok(
|
||||||
[
|
[
|
||||||
'initdb', '--no-sync',
|
'initdb', '--no-sync',
|
||||||
'--locale-provider=builtin', '-E UTF-8',
|
'--locale-provider' => 'builtin',
|
||||||
'--lc-collate=C', '--lc-ctype=C',
|
'--encoding' => 'UTF-8',
|
||||||
'--builtin-locale=C.UTF-8', "$tempdir/data8"
|
'--lc-collate' => 'C',
|
||||||
|
'--lc-ctype' => 'C',
|
||||||
|
'--builtin-locale' => 'C.UTF-8',
|
||||||
|
"$tempdir/data8"
|
||||||
],
|
],
|
||||||
'locale provider builtin with -E UTF-8 --builtin-locale=C.UTF-8');
|
'locale provider builtin with --encoding=UTF-8 --builtin-locale=C.UTF-8');
|
||||||
|
|
||||||
command_fails(
|
command_fails(
|
||||||
[
|
[
|
||||||
'initdb', '--no-sync',
|
'initdb', '--no-sync',
|
||||||
'--locale-provider=builtin', '-E SQL_ASCII',
|
'--locale-provider' => 'builtin',
|
||||||
'--lc-collate=C', '--lc-ctype=C',
|
'--encoding' => 'SQL_ASCII',
|
||||||
'--builtin-locale=C.UTF-8', "$tempdir/data9"
|
'--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'
|
'locale provider builtin with --builtin-locale=C.UTF-8 fails for SQL_ASCII'
|
||||||
);
|
);
|
||||||
@ -216,15 +243,18 @@ command_fails(
|
|||||||
command_ok(
|
command_ok(
|
||||||
[
|
[
|
||||||
'initdb', '--no-sync',
|
'initdb', '--no-sync',
|
||||||
'--locale-provider=builtin', '--lc-ctype=C',
|
'--locale-provider' => 'builtin',
|
||||||
'--locale=C', "$tempdir/data10"
|
'--lc-ctype' => 'C',
|
||||||
|
'--locale' => 'C',
|
||||||
|
"$tempdir/data10"
|
||||||
],
|
],
|
||||||
'locale provider builtin with --lc-ctype');
|
'locale provider builtin with --lc-ctype');
|
||||||
|
|
||||||
command_fails(
|
command_fails(
|
||||||
[
|
[
|
||||||
'initdb', '--no-sync',
|
'initdb', '--no-sync',
|
||||||
'--locale-provider=builtin', '--icu-locale=en',
|
'--locale-provider' => 'builtin',
|
||||||
|
'--icu-locale' => 'en',
|
||||||
"$tempdir/dataX"
|
"$tempdir/dataX"
|
||||||
],
|
],
|
||||||
'fails for locale provider builtin with ICU locale');
|
'fails for locale provider builtin with ICU locale');
|
||||||
@ -232,35 +262,48 @@ command_fails(
|
|||||||
command_fails(
|
command_fails(
|
||||||
[
|
[
|
||||||
'initdb', '--no-sync',
|
'initdb', '--no-sync',
|
||||||
'--locale-provider=builtin', '--icu-rules=""',
|
'--locale-provider' => 'builtin',
|
||||||
|
'--icu-rules' => '""',
|
||||||
"$tempdir/dataX"
|
"$tempdir/dataX"
|
||||||
],
|
],
|
||||||
'fails for locale provider builtin with ICU rules');
|
'fails for locale provider builtin with ICU rules');
|
||||||
|
|
||||||
command_fails(
|
command_fails(
|
||||||
[ 'initdb', '--no-sync', '--locale-provider=xyz', "$tempdir/dataX" ],
|
[
|
||||||
|
'initdb', '--no-sync',
|
||||||
|
'--locale-provider' => 'xyz',
|
||||||
|
"$tempdir/dataX"
|
||||||
|
],
|
||||||
'fails for invalid locale provider');
|
'fails for invalid locale provider');
|
||||||
|
|
||||||
command_fails(
|
command_fails(
|
||||||
[
|
[
|
||||||
'initdb', '--no-sync',
|
'initdb', '--no-sync',
|
||||||
'--locale-provider=libc', '--icu-locale=en',
|
'--locale-provider' => 'libc',
|
||||||
|
'--icu-locale' => 'en',
|
||||||
"$tempdir/dataX"
|
"$tempdir/dataX"
|
||||||
],
|
],
|
||||||
'fails for invalid option combination');
|
'fails for invalid option combination');
|
||||||
|
|
||||||
command_fails(
|
command_fails(
|
||||||
[ 'initdb', '--no-sync', '--set' => 'foo=bar', "$tempdir/dataX" ],
|
[
|
||||||
|
'initdb', '--no-sync',
|
||||||
|
'--set' => 'foo=bar',
|
||||||
|
"$tempdir/dataX"
|
||||||
|
],
|
||||||
'fails for invalid --set option');
|
'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(
|
command_ok(
|
||||||
[
|
[
|
||||||
'initdb', '-cwork_mem=128',
|
'initdb', '--no-sync',
|
||||||
'-cWork_Mem=256', '-cWORK_MEM=512',
|
'--set' => 'work_mem=128',
|
||||||
|
'--set' => 'Work_Mem=256',
|
||||||
|
'--set' => 'WORK_MEM=512',
|
||||||
"$tempdir/dataY"
|
"$tempdir/dataY"
|
||||||
],
|
],
|
||||||
'multiple -c options with different case');
|
'multiple --set options with different case');
|
||||||
|
|
||||||
my $conf = slurp_file("$tempdir/dataY/postgresql.conf");
|
my $conf = slurp_file("$tempdir/dataY/postgresql.conf");
|
||||||
ok($conf !~ qr/^WORK_MEM = /m, "WORK_MEM should not be configured");
|
ok($conf !~ qr/^WORK_MEM = /m, "WORK_MEM should not be configured");
|
||||||
|
Reference in New Issue
Block a user