t0040: convert all possible tests to use `test-parse-options --expect`
Use "test-parse-options --expect" to rewrite the tests to avoid checking the whole variable dump by just testing what is required. This commit is a follow-up to 8ca65aebad ("t0040: convert a few tests to use test-parse-options --expect", 2016-05-06). Signed-off-by: Pranit Bauva <pranit.bauva@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Pranit Bauva committed
Oct 15, 2016 at 12:28 UTC
86009f32bb0e17829f0178953729e78f69e831c6
1 file changed
+13
-170
t/t0040-parse-options.sh
+13
-170
@@ -208,32 +208,15 @@ test_expect_success 'unambiguously abbreviated option' '
208
'
209
210
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
212
'
213
214
test_expect_success 'ambiguously abbreviated option' '
215
test_expect_code 129 test-parse-options --strin 123
216
'
217
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
-
218
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
220
'
221
222
cat >typo.err <<\EOF
@@ -256,24 +239,8 @@ test_expect_success 'detect possible typos' '
239
test_cmp typo.err output.err
240
'
241
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
-
242
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
244
'
245
246
cat >expect <<\EOF
@@ -350,54 +317,20 @@ test_expect_success 'OPT_NEGBIT() and OPT_SET_INT() work' '
317
test_cmp expect output
318
'
319
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
-
320
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
322
'
323
324
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
326
'
327
328
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" + + + + + +
330
'
331
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
-
332
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
334
'
335
336
cat >expect <<\EOF
@@ -435,118 +368,28 @@ test_expect_success '--no-list resets list' '
368
test_cmp expect output
369
'
370
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
-
371
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
373
'
374
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
-
375
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
377
'
378
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
-
379
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
381
'
382
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
-
383
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
385
'
386
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
-
387
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
389
'
390
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
-
391
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
393
'
394
395
test_done