Skip to content

Commit fd4c4ed

Browse files
committed
initdb: Convert tests to use long options with fat comma style
This is similar to ce1b0f9, 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]
1 parent 473a575 commit fd4c4ed

File tree

1 file changed

+80
-37
lines changed

1 file changed

+80
-37
lines changed

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

+80-37
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@
5050
# while we are here, also exercise --text-search-config and --set options
5151
command_ok(
5252
[
53-
'initdb',
54-
'--no-sync',
53+
'initdb', '--no-sync',
5554
'--text-search-config' => 'german',
5655
'--set' => 'default_text_search_config=german',
5756
'--waldir' => $xlogdir,
@@ -101,8 +100,7 @@
101100
# Init a new db with group access
102101
my $datadir_group = "$tempdir/data_group";
103102

104-
command_ok(
105-
[ 'initdb', '-g', $datadir_group ],
103+
command_ok([ 'initdb', '--allow-group-access', $datadir_group ],
106104
'successful creation with group access');
107105

108106
ok(check_mode_recursive($datadir_group, 0750, 0640),
@@ -114,26 +112,35 @@
114112
if ($ENV{with_icu} eq 'yes')
115113
{
116114
command_fails_like(
117-
[ 'initdb', '--no-sync', '--locale-provider=icu', "$tempdir/data2" ],
115+
[
116+
'initdb', '--no-sync',
117+
'--locale-provider' => 'icu',
118+
"$tempdir/data2"
119+
],
118120
qr/initdb: error: locale must be specified if provider is icu/,
119121
'locale provider ICU requires --icu-locale');
120122

121123
command_ok(
122124
[
123125
'initdb', '--no-sync',
124-
'--locale-provider=icu', '--icu-locale=en',
126+
'--locale-provider' => 'icu',
127+
'--icu-locale' => 'en',
125128
"$tempdir/data3"
126129
],
127130
'option --icu-locale');
128131

129132
command_like(
130133
[
131134
'initdb', '--no-sync',
132-
'-A' => 'trust',
133-
'--locale-provider=icu', '--locale=und',
134-
'--lc-collate=C', '--lc-ctype=C',
135-
'--lc-messages=C', '--lc-numeric=C',
136-
'--lc-monetary=C', '--lc-time=C',
135+
'--auth' => 'trust',
136+
'--locale-provider' => 'icu',
137+
'--locale' => 'und',
138+
'--lc-collate' => 'C',
139+
'--lc-ctype' => 'C',
140+
'--lc-messages' => 'C',
141+
'--lc-numeric' => 'C',
142+
'--lc-monetary' => 'C',
143+
'--lc-time' => 'C',
137144
"$tempdir/data4"
138145
],
139146
qr/^\s+default collation:\s+und\n/ms,
@@ -142,7 +149,8 @@
142149
command_fails_like(
143150
[
144151
'initdb', '--no-sync',
145-
'--locale-provider=icu', '--icu-locale=@colNumeric=lower',
152+
'--locale-provider' => 'icu',
153+
'--icu-locale' => '@colNumeric=lower',
146154
"$tempdir/dataX"
147155
],
148156
qr/could not open collator for locale/,
@@ -151,16 +159,19 @@
151159
command_fails_like(
152160
[
153161
'initdb', '--no-sync',
154-
'--locale-provider=icu', '--encoding=SQL_ASCII',
155-
'--icu-locale=en', "$tempdir/dataX"
162+
'--locale-provider' => 'icu',
163+
'--encoding' => 'SQL_ASCII',
164+
'--icu-locale' => 'en',
165+
"$tempdir/dataX"
156166
],
157167
qr/error: encoding mismatch/,
158168
'fails for encoding not supported by ICU');
159169

160170
command_fails_like(
161171
[
162172
'initdb', '--no-sync',
163-
'--locale-provider=icu', '--icu-locale=nonsense-nowhere',
173+
'--locale-provider' => 'icu',
174+
'--icu-locale' => 'nonsense-nowhere',
164175
"$tempdir/dataX"
165176
],
166177
qr/error: locale "nonsense-nowhere" has unknown language "nonsense"/,
@@ -169,7 +180,8 @@
169180
command_fails_like(
170181
[
171182
'initdb', '--no-sync',
172-
'--locale-provider=icu', '--icu-locale=@colNumeric=lower',
183+
'--locale-provider' => 'icu',
184+
'--icu-locale' => '@colNumeric=lower',
173185
"$tempdir/dataX"
174186
],
175187
qr/could not open collator for locale "und-u-kn-lower": U_ILLEGAL_ARGUMENT_ERROR/,
@@ -178,89 +190,120 @@
178190
else
179191
{
180192
command_fails(
181-
[ 'initdb', '--no-sync', '--locale-provider=icu', "$tempdir/data2" ],
193+
[
194+
'initdb', '--no-sync',
195+
'--locale-provider' => 'icu',
196+
"$tempdir/data2"
197+
],
182198
'locale provider ICU fails since no ICU support');
183199
}
184200

185201
command_fails(
186-
[ 'initdb', '--no-sync', '--locale-provider=builtin', "$tempdir/data6" ],
202+
[
203+
'initdb', '--no-sync',
204+
'--locale-provider' => 'builtin',
205+
"$tempdir/data6"
206+
],
187207
'locale provider builtin fails without --locale');
188208

189209
command_ok(
190210
[
191211
'initdb', '--no-sync',
192-
'--locale-provider=builtin', '--locale=C',
212+
'--locale-provider' => 'builtin',
213+
'--locale' => 'C',
193214
"$tempdir/data7"
194215
],
195216
'locale provider builtin with --locale');
196217

197218
command_ok(
198219
[
199220
'initdb', '--no-sync',
200-
'--locale-provider=builtin', '-E UTF-8',
201-
'--lc-collate=C', '--lc-ctype=C',
202-
'--builtin-locale=C.UTF-8', "$tempdir/data8"
221+
'--locale-provider' => 'builtin',
222+
'--encoding' => 'UTF-8',
223+
'--lc-collate' => 'C',
224+
'--lc-ctype' => 'C',
225+
'--builtin-locale' => 'C.UTF-8',
226+
"$tempdir/data8"
203227
],
204-
'locale provider builtin with -E UTF-8 --builtin-locale=C.UTF-8');
228+
'locale provider builtin with --encoding=UTF-8 --builtin-locale=C.UTF-8');
205229

206230
command_fails(
207231
[
208232
'initdb', '--no-sync',
209-
'--locale-provider=builtin', '-E SQL_ASCII',
210-
'--lc-collate=C', '--lc-ctype=C',
211-
'--builtin-locale=C.UTF-8', "$tempdir/data9"
233+
'--locale-provider' => 'builtin',
234+
'--encoding' => 'SQL_ASCII',
235+
'--lc-collate' => 'C',
236+
'--lc-ctype' => 'C',
237+
'--builtin-locale' => 'C.UTF-8',
238+
"$tempdir/data9"
212239
],
213240
'locale provider builtin with --builtin-locale=C.UTF-8 fails for SQL_ASCII'
214241
);
215242

216243
command_ok(
217244
[
218245
'initdb', '--no-sync',
219-
'--locale-provider=builtin', '--lc-ctype=C',
220-
'--locale=C', "$tempdir/data10"
246+
'--locale-provider' => 'builtin',
247+
'--lc-ctype' => 'C',
248+
'--locale' => 'C',
249+
"$tempdir/data10"
221250
],
222251
'locale provider builtin with --lc-ctype');
223252

224253
command_fails(
225254
[
226255
'initdb', '--no-sync',
227-
'--locale-provider=builtin', '--icu-locale=en',
256+
'--locale-provider' => 'builtin',
257+
'--icu-locale' => 'en',
228258
"$tempdir/dataX"
229259
],
230260
'fails for locale provider builtin with ICU locale');
231261

232262
command_fails(
233263
[
234264
'initdb', '--no-sync',
235-
'--locale-provider=builtin', '--icu-rules=""',
265+
'--locale-provider' => 'builtin',
266+
'--icu-rules' => '""',
236267
"$tempdir/dataX"
237268
],
238269
'fails for locale provider builtin with ICU rules');
239270

240271
command_fails(
241-
[ 'initdb', '--no-sync', '--locale-provider=xyz', "$tempdir/dataX" ],
272+
[
273+
'initdb', '--no-sync',
274+
'--locale-provider' => 'xyz',
275+
"$tempdir/dataX"
276+
],
242277
'fails for invalid locale provider');
243278

244279
command_fails(
245280
[
246281
'initdb', '--no-sync',
247-
'--locale-provider=libc', '--icu-locale=en',
282+
'--locale-provider' => 'libc',
283+
'--icu-locale' => 'en',
248284
"$tempdir/dataX"
249285
],
250286
'fails for invalid option combination');
251287

252288
command_fails(
253-
[ 'initdb', '--no-sync', '--set' => 'foo=bar', "$tempdir/dataX" ],
289+
[
290+
'initdb', '--no-sync',
291+
'--set' => 'foo=bar',
292+
"$tempdir/dataX"
293+
],
254294
'fails for invalid --set option');
255295

256-
# Make sure multiple invocations of -c parameters are added case insensitive
296+
# Make sure multiple invocations of --set parameters are added case
297+
# insensitive.
257298
command_ok(
258299
[
259-
'initdb', '-cwork_mem=128',
260-
'-cWork_Mem=256', '-cWORK_MEM=512',
300+
'initdb', '--no-sync',
301+
'--set' => 'work_mem=128',
302+
'--set' => 'Work_Mem=256',
303+
'--set' => 'WORK_MEM=512',
261304
"$tempdir/dataY"
262305
],
263-
'multiple -c options with different case');
306+
'multiple --set options with different case');
264307

265308
my $conf = slurp_file("$tempdir/dataY/postgresql.conf");
266309
ok($conf !~ qr/^WORK_MEM = /m, "WORK_MEM should not be configured");

0 commit comments

Comments
 (0)