@@ -8,7 +8,7 @@ test_description='our own option parser'
8
8
. ./test-lib.sh
9
9
10
10
cat > expect << \EOF
11
- usage: test-parse-options <options>
11
+ usage: test-tool parse-options <options>
12
12
13
13
A helper function for the parse-options API.
14
14
@@ -52,7 +52,7 @@ Standard options
52
52
EOF
53
53
54
54
test_expect_success ' test help' '
55
- test_must_fail test-parse-options -h >output 2>output.err &&
55
+ test_must_fail test-tool parse-options -h >output 2>output.err &&
56
56
test_must_be_empty output.err &&
57
57
test_i18ncmp expect output
58
58
'
@@ -64,7 +64,7 @@ check () {
64
64
shift &&
65
65
expect=" $1 " &&
66
66
shift &&
67
- test-parse-options --expect=" $what $expect " " $@ "
67
+ test-tool parse-options --expect=" $what $expect " " $@ "
68
68
}
69
69
70
70
check_unknown_i18n () {
@@ -75,7 +75,7 @@ check_unknown_i18n() {
75
75
echo error: unknown switch \` ${1# -} \' > expect ;;
76
76
esac &&
77
77
cat expect.err >> expect &&
78
- test_must_fail test-parse-options $* > output 2> output.err &&
78
+ test_must_fail test-tool parse-options $* > output 2> output.err &&
79
79
test_must_be_empty output &&
80
80
test_i18ncmp expect output.err
81
81
}
@@ -133,7 +133,7 @@ file: prefix/my.file
133
133
EOF
134
134
135
135
test_expect_success ' short options' '
136
- test-parse-options -s123 -b -i 1729 -m 16k -b -vv -n -F my.file \
136
+ test-tool parse-options -s123 -b -i 1729 -m 16k -b -vv -n -F my.file \
137
137
>output 2>output.err &&
138
138
test_cmp expect output &&
139
139
test_must_be_empty output.err
@@ -153,7 +153,7 @@ file: prefix/fi.le
153
153
EOF
154
154
155
155
test_expect_success ' long options' '
156
- test-parse-options --boolean --integer 1729 --magnitude 16k \
156
+ test-tool parse-options --boolean --integer 1729 --magnitude 16k \
157
157
--boolean --string2=321 --verbose --verbose --no-dry-run \
158
158
--abbrev=10 --file fi.le --obsolete \
159
159
>output 2>output.err &&
@@ -162,9 +162,9 @@ test_expect_success 'long options' '
162
162
'
163
163
164
164
test_expect_success ' missing required value' '
165
- test_expect_code 129 test-parse-options -s &&
166
- test_expect_code 129 test-parse-options --string &&
167
- test_expect_code 129 test-parse-options --file
165
+ test_expect_code 129 test-tool parse-options -s &&
166
+ test_expect_code 129 test-tool parse-options --string &&
167
+ test_expect_code 129 test-tool parse-options --file
168
168
'
169
169
170
170
cat > expect << \EOF
@@ -184,7 +184,7 @@ arg 02: --boolean
184
184
EOF
185
185
186
186
test_expect_success ' intermingled arguments' '
187
- test-parse-options a1 --string 123 b1 --boolean -j 13 -- --boolean \
187
+ test-tool parse-options a1 --string 123 b1 --boolean -j 13 -- --boolean \
188
188
>output 2>output.err &&
189
189
test_must_be_empty output.err &&
190
190
test_cmp expect output
@@ -204,29 +204,29 @@ file: (not set)
204
204
EOF
205
205
206
206
test_expect_success ' unambiguously abbreviated option' '
207
- test-parse-options --int 2 --boolean --no-bo >output 2>output.err &&
207
+ test-tool parse-options --int 2 --boolean --no-bo >output 2>output.err &&
208
208
test_must_be_empty output.err &&
209
209
test_cmp expect output
210
210
'
211
211
212
212
test_expect_success ' unambiguously abbreviated option with "="' '
213
- test-parse-options --expect="integer: 2" --int=2
213
+ test-tool parse-options --expect="integer: 2" --int=2
214
214
'
215
215
216
216
test_expect_success ' ambiguously abbreviated option' '
217
- test_expect_code 129 test-parse-options --strin 123
217
+ test_expect_code 129 test-tool parse-options --strin 123
218
218
'
219
219
220
220
test_expect_success ' non ambiguous option (after two options it abbreviates)' '
221
- test-parse-options --expect="string: 123" --st 123
221
+ test-tool parse-options --expect="string: 123" --st 123
222
222
'
223
223
224
224
cat > typo.err << \EOF
225
225
error: did you mean ` --boolean` (with two dashes ?)
226
226
EOF
227
227
228
228
test_expect_success ' detect possible typos' '
229
- test_must_fail test-parse-options -boolean >output 2>output.err &&
229
+ test_must_fail test-tool parse-options -boolean >output 2>output.err &&
230
230
test_must_be_empty output &&
231
231
test_cmp typo.err output.err
232
232
'
@@ -236,13 +236,13 @@ error: did you mean `--ambiguous` (with two dashes ?)
236
236
EOF
237
237
238
238
test_expect_success ' detect possible typos' '
239
- test_must_fail test-parse-options -ambiguous >output 2>output.err &&
239
+ test_must_fail test-tool parse-options -ambiguous >output 2>output.err &&
240
240
test_must_be_empty output &&
241
241
test_cmp typo.err output.err
242
242
'
243
243
244
244
test_expect_success ' keep some options as arguments' '
245
- test-parse-options --expect="arg 00: --quux" --quux
245
+ test-tool parse-options --expect="arg 00: --quux" --quux
246
246
'
247
247
248
248
cat > expect << \EOF
@@ -260,7 +260,7 @@ arg 00: foo
260
260
EOF
261
261
262
262
test_expect_success ' OPT_DATE() works' '
263
- test-parse-options -t "1970-01-01 00:00:01 +0000" \
263
+ test-tool parse-options -t "1970-01-01 00:00:01 +0000" \
264
264
foo -q >output 2>output.err &&
265
265
test_must_be_empty output.err &&
266
266
test_cmp expect output
@@ -281,13 +281,13 @@ file: (not set)
281
281
EOF
282
282
283
283
test_expect_success ' OPT_CALLBACK() and OPT_BIT() work' '
284
- test-parse-options --length=four -b -4 >output 2>output.err &&
284
+ test-tool parse-options --length=four -b -4 >output 2>output.err &&
285
285
test_must_be_empty output.err &&
286
286
test_cmp expect output
287
287
'
288
288
289
289
test_expect_success ' OPT_CALLBACK() and callback errors work' '
290
- test_must_fail test-parse-options --no-length >output 2>output.err &&
290
+ test_must_fail test-tool parse-options --no-length >output 2>output.err &&
291
291
test_must_be_empty output &&
292
292
test_must_be_empty output.err
293
293
'
@@ -306,31 +306,31 @@ file: (not set)
306
306
EOF
307
307
308
308
test_expect_success ' OPT_BIT() and OPT_SET_INT() work' '
309
- test-parse-options --set23 -bbbbb --no-or4 >output 2>output.err &&
309
+ test-tool parse-options --set23 -bbbbb --no-or4 >output 2>output.err &&
310
310
test_must_be_empty output.err &&
311
311
test_cmp expect output
312
312
'
313
313
314
314
test_expect_success ' OPT_NEGBIT() and OPT_SET_INT() work' '
315
- test-parse-options --set23 -bbbbb --neg-or4 >output 2>output.err &&
315
+ test-tool parse-options --set23 -bbbbb --neg-or4 >output 2>output.err &&
316
316
test_must_be_empty output.err &&
317
317
test_cmp expect output
318
318
'
319
319
320
320
test_expect_success ' OPT_BIT() works' '
321
- test-parse-options --expect="boolean: 6" -bb --or4
321
+ test-tool parse-options --expect="boolean: 6" -bb --or4
322
322
'
323
323
324
324
test_expect_success ' OPT_NEGBIT() works' '
325
- test-parse-options --expect="boolean: 6" -bb --no-neg-or4
325
+ test-tool parse-options --expect="boolean: 6" -bb --no-neg-or4
326
326
'
327
327
328
328
test_expect_success ' OPT_COUNTUP() with PARSE_OPT_NODASH works' '
329
- test-parse-options --expect="boolean: 6" + + + + + +
329
+ test-tool parse-options --expect="boolean: 6" + + + + + +
330
330
'
331
331
332
332
test_expect_success ' OPT_NUMBER_CALLBACK() works' '
333
- test-parse-options --expect="integer: 12345" -12345
333
+ test-tool parse-options --expect="integer: 12345" -12345
334
334
'
335
335
336
336
cat > expect << \EOF
@@ -347,7 +347,7 @@ file: (not set)
347
347
EOF
348
348
349
349
test_expect_success ' negation of OPT_NONEG flags is not ambiguous' '
350
- test-parse-options --no-ambig >output 2>output.err &&
350
+ test-tool parse-options --no-ambig >output 2>output.err &&
351
351
test_must_be_empty output.err &&
352
352
test_cmp expect output
353
353
'
@@ -358,38 +358,38 @@ list: bar
358
358
list: baz
359
359
EOF
360
360
test_expect_success ' --list keeps list of strings' '
361
- test-parse-options --list foo --list=bar --list=baz >output &&
361
+ test-tool parse-options --list foo --list=bar --list=baz >output &&
362
362
test_cmp expect output
363
363
'
364
364
365
365
test_expect_success ' --no-list resets list' '
366
- test-parse-options --list=other --list=irrelevant --list=options \
366
+ test-tool parse-options --list=other --list=irrelevant --list=options \
367
367
--no-list --list=foo --list=bar --list=baz >output &&
368
368
test_cmp expect output
369
369
'
370
370
371
371
test_expect_success ' multiple quiet levels' '
372
- test-parse-options --expect="quiet: 3" -q -q -q
372
+ test-tool parse-options --expect="quiet: 3" -q -q -q
373
373
'
374
374
375
375
test_expect_success ' multiple verbose levels' '
376
- test-parse-options --expect="verbose: 3" -v -v -v
376
+ test-tool parse-options --expect="verbose: 3" -v -v -v
377
377
'
378
378
379
379
test_expect_success ' --no-quiet sets --quiet to 0' '
380
- test-parse-options --expect="quiet: 0" --no-quiet
380
+ test-tool parse-options --expect="quiet: 0" --no-quiet
381
381
'
382
382
383
383
test_expect_success ' --no-quiet resets multiple -q to 0' '
384
- test-parse-options --expect="quiet: 0" -q -q -q --no-quiet
384
+ test-tool parse-options --expect="quiet: 0" -q -q -q --no-quiet
385
385
'
386
386
387
387
test_expect_success ' --no-verbose sets verbose to 0' '
388
- test-parse-options --expect="verbose: 0" --no-verbose
388
+ test-tool parse-options --expect="verbose: 0" --no-verbose
389
389
'
390
390
391
391
test_expect_success ' --no-verbose resets multiple verbose to 0' '
392
- test-parse-options --expect="verbose: 0" -v -v -v --no-verbose
392
+ test-tool parse-options --expect="verbose: 0" -v -v -v --no-verbose
393
393
'
394
394
395
395
test_done
0 commit comments