Skip to content

Commit 3040b07

Browse files
committed
Merge branch 'pb/test-parse-options-expect' into pu
* pb/test-parse-options-expect: t0040: convert all possible tests to use `test-parse-options --expect`
2 parents 180c3b5 + 86009f3 commit 3040b07

File tree

1 file changed

+13
-170
lines changed

1 file changed

+13
-170
lines changed

t/t0040-parse-options.sh

Lines changed: 13 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -208,32 +208,15 @@ test_expect_success 'unambiguously abbreviated option' '
208208
'
209209

210210
test_expect_success 'unambiguously abbreviated option with "="' '
211-
test-parse-options --int=2 >output 2>output.err &&
212-
test_must_be_empty output.err &&
213-
test_cmp expect output
211+
test-parse-options --expect="integer: 2" --int=2
214212
'
215213

216214
test_expect_success 'ambiguously abbreviated option' '
217215
test_expect_code 129 test-parse-options --strin 123
218216
'
219217

220-
cat >expect <<\EOF
221-
boolean: 0
222-
integer: 0
223-
magnitude: 0
224-
timestamp: 0
225-
string: 123
226-
abbrev: 7
227-
verbose: -1
228-
quiet: 0
229-
dry run: no
230-
file: (not set)
231-
EOF
232-
233218
test_expect_success 'non ambiguous option (after two options it abbreviates)' '
234-
test-parse-options --st 123 >output 2>output.err &&
235-
test_must_be_empty output.err &&
236-
test_cmp expect output
219+
test-parse-options --expect="string: 123" --st 123
237220
'
238221

239222
cat >typo.err <<\EOF
@@ -256,24 +239,8 @@ test_expect_success 'detect possible typos' '
256239
test_cmp typo.err output.err
257240
'
258241

259-
cat >expect <<\EOF
260-
boolean: 0
261-
integer: 0
262-
magnitude: 0
263-
timestamp: 0
264-
string: (not set)
265-
abbrev: 7
266-
verbose: -1
267-
quiet: 0
268-
dry run: no
269-
file: (not set)
270-
arg 00: --quux
271-
EOF
272-
273242
test_expect_success 'keep some options as arguments' '
274-
test-parse-options --quux >output 2>output.err &&
275-
test_must_be_empty output.err &&
276-
test_cmp expect output
243+
test-parse-options --expect="arg 00: --quux" --quux
277244
'
278245

279246
cat >expect <<\EOF
@@ -350,54 +317,20 @@ test_expect_success 'OPT_NEGBIT() and OPT_SET_INT() work' '
350317
test_cmp expect output
351318
'
352319

353-
cat >expect <<\EOF
354-
boolean: 6
355-
integer: 0
356-
magnitude: 0
357-
timestamp: 0
358-
string: (not set)
359-
abbrev: 7
360-
verbose: -1
361-
quiet: 0
362-
dry run: no
363-
file: (not set)
364-
EOF
365-
366320
test_expect_success 'OPT_BIT() works' '
367-
test-parse-options -bb --or4 >output 2>output.err &&
368-
test_must_be_empty output.err &&
369-
test_cmp expect output
321+
test-parse-options --expect="boolean: 6" -bb --or4
370322
'
371323

372324
test_expect_success 'OPT_NEGBIT() works' '
373-
test-parse-options -bb --no-neg-or4 >output 2>output.err &&
374-
test_must_be_empty output.err &&
375-
test_cmp expect output
325+
test-parse-options --expect="boolean: 6" -bb --no-neg-or4
376326
'
377327

378328
test_expect_success 'OPT_COUNTUP() with PARSE_OPT_NODASH works' '
379-
test-parse-options + + + + + + >output 2>output.err &&
380-
test_must_be_empty output.err &&
381-
test_cmp expect output
329+
test-parse-options --expect="boolean: 6" + + + + + +
382330
'
383331

384-
cat >expect <<\EOF
385-
boolean: 0
386-
integer: 12345
387-
magnitude: 0
388-
timestamp: 0
389-
string: (not set)
390-
abbrev: 7
391-
verbose: -1
392-
quiet: 0
393-
dry run: no
394-
file: (not set)
395-
EOF
396-
397332
test_expect_success 'OPT_NUMBER_CALLBACK() works' '
398-
test-parse-options -12345 >output 2>output.err &&
399-
test_must_be_empty output.err &&
400-
test_cmp expect output
333+
test-parse-options --expect="integer: 12345" -12345
401334
'
402335

403336
cat >expect <<\EOF
@@ -435,118 +368,28 @@ test_expect_success '--no-list resets list' '
435368
test_cmp expect output
436369
'
437370

438-
cat >expect <<\EOF
439-
boolean: 0
440-
integer: 0
441-
magnitude: 0
442-
timestamp: 0
443-
string: (not set)
444-
abbrev: 7
445-
verbose: -1
446-
quiet: 3
447-
dry run: no
448-
file: (not set)
449-
EOF
450-
451371
test_expect_success 'multiple quiet levels' '
452-
test-parse-options -q -q -q >output 2>output.err &&
453-
test_must_be_empty output.err &&
454-
test_cmp expect output
372+
test-parse-options --expect="quiet: 3" -q -q -q
455373
'
456374

457-
cat >expect <<\EOF
458-
boolean: 0
459-
integer: 0
460-
magnitude: 0
461-
timestamp: 0
462-
string: (not set)
463-
abbrev: 7
464-
verbose: 3
465-
quiet: 0
466-
dry run: no
467-
file: (not set)
468-
EOF
469-
470375
test_expect_success 'multiple verbose levels' '
471-
test-parse-options -v -v -v >output 2>output.err &&
472-
test_must_be_empty output.err &&
473-
test_cmp expect output
376+
test-parse-options --expect="verbose: 3" -v -v -v
474377
'
475378

476-
cat >expect <<\EOF
477-
boolean: 0
478-
integer: 0
479-
magnitude: 0
480-
timestamp: 0
481-
string: (not set)
482-
abbrev: 7
483-
verbose: -1
484-
quiet: 0
485-
dry run: no
486-
file: (not set)
487-
EOF
488-
489379
test_expect_success '--no-quiet sets --quiet to 0' '
490-
test-parse-options --no-quiet >output 2>output.err &&
491-
test_must_be_empty output.err &&
492-
test_cmp expect output
380+
test-parse-options --expect="quiet: 0" --no-quiet
493381
'
494382

495-
cat >expect <<\EOF
496-
boolean: 0
497-
integer: 0
498-
magnitude: 0
499-
timestamp: 0
500-
string: (not set)
501-
abbrev: 7
502-
verbose: -1
503-
quiet: 0
504-
dry run: no
505-
file: (not set)
506-
EOF
507-
508383
test_expect_success '--no-quiet resets multiple -q to 0' '
509-
test-parse-options -q -q -q --no-quiet >output 2>output.err &&
510-
test_must_be_empty output.err &&
511-
test_cmp expect output
384+
test-parse-options --expect="quiet: 0" -q -q -q --no-quiet
512385
'
513386

514-
cat >expect <<\EOF
515-
boolean: 0
516-
integer: 0
517-
magnitude: 0
518-
timestamp: 0
519-
string: (not set)
520-
abbrev: 7
521-
verbose: 0
522-
quiet: 0
523-
dry run: no
524-
file: (not set)
525-
EOF
526-
527387
test_expect_success '--no-verbose sets verbose to 0' '
528-
test-parse-options --no-verbose >output 2>output.err &&
529-
test_must_be_empty output.err &&
530-
test_cmp expect output
388+
test-parse-options --expect="verbose: 0" --no-verbose
531389
'
532390

533-
cat >expect <<\EOF
534-
boolean: 0
535-
integer: 0
536-
magnitude: 0
537-
timestamp: 0
538-
string: (not set)
539-
abbrev: 7
540-
verbose: 0
541-
quiet: 0
542-
dry run: no
543-
file: (not set)
544-
EOF
545-
546391
test_expect_success '--no-verbose resets multiple verbose to 0' '
547-
test-parse-options -v -v -v --no-verbose >output 2>output.err &&
548-
test_must_be_empty output.err &&
549-
test_cmp expect output
392+
test-parse-options --expect="verbose: 0" -v -v -v --no-verbose
550393
'
551394

552395
test_done

0 commit comments

Comments
 (0)