test-lib tests: don't provide a description for the sub-tests
Change the $test_description provided for the generated subtests to be constant, since the only purpose of having it is that test-lib.sh will barf if it isn't supplied. The other purpose of having it was to effectively split up the test description between the argument to test_expect_success and the argument to "write_and_run_sub_test_lib_test". Let's only use one of the two. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Sep 22, 2021 at 13:19 UTC
c3ff7be6fb04c3150a8496271901a4a918c2c70c
2 files changed
+66
-88
t/lib-subtest.sh
+4
-8
@@ -1,12 +1,8 @@
1
write_sub_test_lib_test () {
2
- name="$1" descr="$2" # stdin is the body of the test code
2
+ name="$1" # stdin is the body of the test code
3
mkdir "$name" &&
4
write_script "$name/$name.sh" "$TEST_SHELL_PATH" <<-EOF &&
5
- test_description='$descr (run in sub test-lib)
6
-
7
- This is run in a sub test-lib so that we do not get incorrect
8
- passing metrics
9
- '
5
+ test_description='A test of test-lib.sh itself'
6
7
# Point to the t/test-lib.sh, which isn't in ../ as usual
8
. "\$TEST_DIRECTORY"/test-lib.sh
@@ -15,8 +11,8 @@ write_sub_test_lib_test () {
11
}
12
13
_run_sub_test_lib_test_common () {
18
- neg="$1" name="$2" descr="$3" # stdin is the body of the test code
19
- shift 3
14
+ neg="$1" name="$2" # stdin is the body of the test code
15
+ shift 2
16
17
# intercept pseudo-options at the front of the argument list that we
18
# will not pass to child script
t/t0000-basic.sh
+62
-80
@@ -67,8 +67,8 @@ test_expect_success 'success is reported like this' '
67
:
68
'
69
70
-test_expect_success 'pretend we have a fully passing test suite' '
71
- write_and_run_sub_test_lib_test full-pass "3 passing tests" <<-\EOF &&
70
+test_expect_success 'subtest: 3 passing tests' '
71
+ write_and_run_sub_test_lib_test full-pass <<-\EOF &&
72
for i in 1 2 3
73
do
74
test_expect_success "passing test #$i" "true"
@@ -84,9 +84,8 @@ test_expect_success 'pretend we have a fully passing test suite' '
84
EOF
85
'
86
87
-test_expect_success 'pretend we have a partially passing test suite' '
88
- write_and_run_sub_test_lib_test_err \
89
- partial-pass "2/3 tests passing" <<-\EOF &&
87
+test_expect_success 'subtest: 2/3 tests passing' '
88
+ write_and_run_sub_test_lib_test_err partial-pass <<-\EOF &&
89
test_expect_success "passing test #1" "true"
90
test_expect_success "failing test #2" "false"
91
test_expect_success "passing test #3" "true"
@@ -102,8 +101,8 @@ test_expect_success 'pretend we have a partially passing test suite' '
101
EOF
102
'
103
105
-test_expect_success 'pretend we have a known breakage' '
106
- write_and_run_sub_test_lib_test failing-todo "A failing TODO test" <<-\EOF &&
104
+test_expect_success 'subtest: a failing TODO test' '
105
+ write_and_run_sub_test_lib_test failing-todo <<-\EOF &&
106
test_expect_success "passing test" "true"
107
test_expect_failure "pretend we have a known breakage" "false"
108
test_done
@@ -117,8 +116,8 @@ test_expect_success 'pretend we have a known breakage' '
116
EOF
117
'
118
120
-test_expect_success 'pretend we have fixed a known breakage' '
121
- write_and_run_sub_test_lib_test passing-todo "A passing TODO test" <<-\EOF &&
119
+test_expect_success 'subtest: a passing TODO test' '
120
+ write_and_run_sub_test_lib_test passing-todo <<-\EOF &&
121
test_expect_failure "pretend we have fixed a known breakage" "true"
122
test_done
123
EOF
@@ -129,9 +128,8 @@ test_expect_success 'pretend we have fixed a known breakage' '
128
EOF
129
'
130
132
-test_expect_success 'pretend we have fixed one of two known breakages (run in sub test-lib)' '
133
- write_and_run_sub_test_lib_test partially-passing-todos \
134
- "2 TODO tests, one passing" <<-\EOF &&
131
+test_expect_success 'subtest: 2 TODO tests, one passin' '
132
+ write_and_run_sub_test_lib_test partially-passing-todos <<-\EOF &&
133
test_expect_failure "pretend we have a known breakage" "false"
134
test_expect_success "pretend we have a passing test" "true"
135
test_expect_failure "pretend we have fixed another known breakage" "true"
@@ -148,9 +146,8 @@ test_expect_success 'pretend we have fixed one of two known breakages (run in su
146
EOF
147
'
148
151
-test_expect_success 'pretend we have a pass, fail, and known breakage' '
152
- write_and_run_sub_test_lib_test_err \
153
- mixed-results1 "mixed results #1" <<-\EOF &&
149
+test_expect_success 'subtest: mixed results: pass, failure and a TODO test' '
150
+ write_and_run_sub_test_lib_test_err mixed-results1 <<-\EOF &&
151
test_expect_success "passing test" "true"
152
test_expect_success "failing test" "false"
153
test_expect_failure "pretend we have a known breakage" "false"
@@ -167,9 +164,8 @@ test_expect_success 'pretend we have a pass, fail, and known breakage' '
164
EOF
165
'
166
170
-test_expect_success 'pretend we have a mix of all possible results' '
171
- write_and_run_sub_test_lib_test_err \
172
- mixed-results2 "mixed results #2" <<-\EOF &&
167
+test_expect_success 'subtest: mixed results: a mixture of all possible results' '
168
+ write_and_run_sub_test_lib_test_err mixed-results2 <<-\EOF &&
169
test_expect_success "passing test" "true"
170
test_expect_success "passing test" "true"
171
test_expect_success "passing test" "true"
@@ -203,9 +199,8 @@ test_expect_success 'pretend we have a mix of all possible results' '
199
EOF
200
'
201
206
-test_expect_success 'test --verbose' '
207
- write_and_run_sub_test_lib_test_err \
208
- t1234-verbose "test verbose" --verbose <<-\EOF &&
202
+test_expect_success 'subtest: --verbose option' '
203
+ write_and_run_sub_test_lib_test_err t1234-verbose --verbose <<-\EOF &&
204
test_expect_success "passing test" true
205
test_expect_success "test with output" "echo foo"
206
test_expect_success "failing test" false
@@ -230,9 +225,9 @@ test_expect_success 'test --verbose' '
225
EOF
226
'
227
233
-test_expect_success 'test --verbose-only' '
228
+test_expect_success 'subtest: --verbose-only option' '
229
write_and_run_sub_test_lib_test_err \
235
- t2345-verbose-only-2 "test verbose-only=2" \
230
+ t2345-verbose-only-2 \
231
--verbose-only=2 <<-\EOF &&
232
test_expect_success "passing test" true
233
test_expect_success "test with output" "echo foo"
@@ -253,10 +248,9 @@ test_expect_success 'test --verbose-only' '
248
EOF
249
'
250
256
-test_expect_success 'GIT_SKIP_TESTS' '
251
+test_expect_success 'subtest: skip one with GIT_SKIP_TESTS' '
252
(
253
write_and_run_sub_test_lib_test git-skip-tests-basic \
259
- "GIT_SKIP_TESTS" \
254
--skip="git.2" <<-\EOF &&
255
for i in 1 2 3
256
do
@@ -274,10 +268,9 @@ test_expect_success 'GIT_SKIP_TESTS' '
268
)
269
'
270
277
-test_expect_success 'GIT_SKIP_TESTS several tests' '
271
+test_expect_success 'subtest: skip several with GIT_SKIP_TESTS' '
272
(
273
write_and_run_sub_test_lib_test git-skip-tests-several \
280
- "GIT_SKIP_TESTS several tests" \
274
--skip="git.2 git.5" <<-\EOF &&
275
for i in 1 2 3 4 5 6
276
do
@@ -298,10 +291,9 @@ test_expect_success 'GIT_SKIP_TESTS several tests' '
291
)
292
'
293
301
-test_expect_success 'GIT_SKIP_TESTS sh pattern' '
294
+test_expect_success 'subtest: sh pattern skipping with GIT_SKIP_TESTS' '
295
(
296
write_and_run_sub_test_lib_test git-skip-tests-sh-pattern \
304
- "GIT_SKIP_TESTS sh pattern" \
297
--skip="git.[2-5]" <<-\EOF &&
298
for i in 1 2 3 4 5 6
299
do
@@ -322,10 +314,9 @@ test_expect_success 'GIT_SKIP_TESTS sh pattern' '
314
)
315
'
316
325
-test_expect_success 'GIT_SKIP_TESTS entire suite' '
317
+test_expect_success 'subtest: skip entire test suite with GIT_SKIP_TESTS' '
318
(
319
write_and_run_sub_test_lib_test git-skip-tests-entire-suite \
328
- "GIT_SKIP_TESTS entire suite" \
320
--skip="git" <<-\EOF &&
321
for i in 1 2 3
322
do
@@ -339,10 +330,9 @@ test_expect_success 'GIT_SKIP_TESTS entire suite' '
330
)
331
'
332
342
-test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '
333
+test_expect_success 'subtest: GIT_SKIP_TESTS does not skip unmatched suite' '
334
(
335
write_and_run_sub_test_lib_test git-skip-tests-unmatched-suite \
345
- "GIT_SKIP_TESTS does not skip unmatched suite" \
336
--skip="notgit" <<-\EOF &&
337
for i in 1 2 3
338
do
@@ -360,9 +350,8 @@ test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '
350
)
351
'
352
363
-test_expect_success '--run basic' '
364
- write_and_run_sub_test_lib_test run-basic \
365
- "--run basic" --run="1,3,5" <<-\EOF &&
353
+test_expect_success 'subtest: --run basic' '
354
+ write_and_run_sub_test_lib_test run-basic --run="1,3,5" <<-\EOF &&
355
for i in 1 2 3 4 5 6
356
do
357
test_expect_success "passing test #$i" "true"
@@ -381,9 +370,9 @@ test_expect_success '--run basic' '
370
EOF
371
'
372
384
-test_expect_success '--run with a range' '
373
+test_expect_success 'subtest: --run with a range' '
374
write_and_run_sub_test_lib_test run-range \
386
- "--run with a range" --run="1-3" <<-\EOF &&
375
+ --run="1-3" <<-\EOF &&
376
for i in 1 2 3 4 5 6
377
do
378
test_expect_success "passing test #$i" "true"
@@ -402,9 +391,9 @@ test_expect_success '--run with a range' '
391
EOF
392
'
393
405
-test_expect_success '--run with two ranges' '
394
+test_expect_success 'subtest: --run with two ranges' '
395
write_and_run_sub_test_lib_test run-two-ranges \
407
- "--run with two ranges" --run="1-2,5-6" <<-\EOF &&
396
+ --run="1-2,5-6" <<-\EOF &&
397
for i in 1 2 3 4 5 6
398
do
399
test_expect_success "passing test #$i" "true"
@@ -423,9 +412,9 @@ test_expect_success '--run with two ranges' '
412
EOF
413
'
414
426
-test_expect_success '--run with a left open range' '
415
+test_expect_success 'subtest: --run with a left open range' '
416
write_and_run_sub_test_lib_test run-left-open-range \
428
- "--run with a left open range" --run="-3" <<-\EOF &&
417
+ --run="-3" <<-\EOF &&
418
for i in 1 2 3 4 5 6
419
do
420
test_expect_success "passing test #$i" "true"
@@ -444,9 +433,9 @@ test_expect_success '--run with a left open range' '
433
EOF
434
'
435
447
-test_expect_success '--run with a right open range' '
436
+test_expect_success 'subtest: --run with a right open range' '
437
write_and_run_sub_test_lib_test run-right-open-range \
449
- "--run with a right open range" --run="4-" <<-\EOF &&
438
+ --run="4-" <<-\EOF &&
439
for i in 1 2 3 4 5 6
440
do
441
test_expect_success "passing test #$i" "true"
@@ -465,9 +454,9 @@ test_expect_success '--run with a right open range' '
454
EOF
455
'
456
468
-test_expect_success '--run with basic negation' '
457
+test_expect_success 'subtest: --run with basic negation' '
458
write_and_run_sub_test_lib_test run-basic-neg \
470
- "--run with basic negation" --run="!3" <<-\EOF &&
459
+ --run="!3" <<-\EOF &&
460
for i in 1 2 3 4 5 6
461
do
462
test_expect_success "passing test #$i" "true"
@@ -486,9 +475,9 @@ test_expect_success '--run with basic negation' '
475
EOF
476
'
477
489
-test_expect_success '--run with two negations' '
478
+test_expect_success 'subtest: --run with two negations' '
479
write_and_run_sub_test_lib_test run-two-neg \
491
- "--run with two negations" --run="!3,!6" <<-\EOF &&
480
+ --run="!3,!6" <<-\EOF &&
481
for i in 1 2 3 4 5 6
482
do
483
test_expect_success "passing test #$i" "true"
@@ -507,9 +496,9 @@ test_expect_success '--run with two negations' '
496
EOF
497
'
498
510
-test_expect_success '--run a range and negation' '
499
+test_expect_success 'subtest: --run a range and negation' '
500
write_and_run_sub_test_lib_test run-range-and-neg \
512
- "--run a range and negation" --run="-4,!2" <<-\EOF &&
501
+ --run="-4,!2" <<-\EOF &&
502
for i in 1 2 3 4 5 6
503
do
504
test_expect_success "passing test #$i" "true"
@@ -528,9 +517,9 @@ test_expect_success '--run a range and negation' '
517
EOF
518
'
519
531
-test_expect_success '--run range negation' '
520
+test_expect_success 'subtest: --run range negation' '
521
write_and_run_sub_test_lib_test run-range-neg \
533
- "--run range negation" --run="!1-3" <<-\EOF &&
522
+ --run="!1-3" <<-\EOF &&
523
for i in 1 2 3 4 5 6
524
do
525
test_expect_success "passing test #$i" "true"
@@ -549,9 +538,8 @@ test_expect_success '--run range negation' '
538
EOF
539
'
540
552
-test_expect_success '--run include, exclude and include' '
541
+test_expect_success 'subtest: --run include, exclude and include' '
542
write_and_run_sub_test_lib_test run-inc-neg-inc \
554
- "--run include, exclude and include" \
543
--run="1-5,!1-3,2" <<-\EOF &&
544
for i in 1 2 3 4 5 6
545
do
@@ -571,9 +559,8 @@ test_expect_success '--run include, exclude and include' '
559
EOF
560
'
561
574
-test_expect_success '--run include, exclude and include, comma separated' '
562
+test_expect_success 'subtest: --run include, exclude and include, comma separated' '
563
write_and_run_sub_test_lib_test run-inc-neg-inc-comma \
576
- "--run include, exclude and include, comma separated" \
564
--run=1-5,!1-3,2 <<-\EOF &&
565
for i in 1 2 3 4 5 6
566
do
@@ -593,9 +580,8 @@ test_expect_success '--run include, exclude and include, comma separated' '
580
EOF
581
'
582
596
-test_expect_success '--run exclude and include' '
583
+test_expect_success 'subtest: --run exclude and include' '
584
write_and_run_sub_test_lib_test run-neg-inc \
598
- "--run exclude and include" \
585
--run="!3-,5" <<-\EOF &&
586
for i in 1 2 3 4 5 6
587
do
@@ -615,9 +601,8 @@ test_expect_success '--run exclude and include' '
601
EOF
602
'
603
618
-test_expect_success '--run empty selectors' '
604
+test_expect_success 'subtest: --run empty selectors' '
605
write_and_run_sub_test_lib_test run-empty-sel \
620
- "--run empty selectors" \
606
--run="1,,3,,,5" <<-\EOF &&
607
for i in 1 2 3 4 5 6
608
do
@@ -637,9 +622,8 @@ test_expect_success '--run empty selectors' '
622
EOF
623
'
624
640
-test_expect_success '--run substring selector' '
625
+test_expect_success 'subtest: --run substring selector' '
626
write_and_run_sub_test_lib_test run-substring-selector \
642
- "--run empty selectors" \
627
--run="relevant" <<-\EOF &&
628
test_expect_success "relevant test" "true"
629
for i in 1 2 3 4 5 6
@@ -661,9 +645,8 @@ test_expect_success '--run substring selector' '
645
EOF
646
'
647
664
-test_expect_success '--run keyword selection' '
648
+test_expect_success 'subtest: --run keyword selection' '
649
write_and_run_sub_test_lib_test_err run-inv-range-start \
666
- "--run invalid range start" \
650
--run="a-5" <<-\EOF &&
651
test_expect_success "passing test #1" "true"
652
test_done
@@ -676,9 +659,8 @@ test_expect_success '--run keyword selection' '
659
EOF_ERR
660
'
661
679
-test_expect_success '--run invalid range end' '
662
+test_expect_success 'subtest: --run invalid range end' '
663
write_and_run_sub_test_lib_test_err run-inv-range-end \
681
- "--run invalid range end" \
664
--run="1-z" <<-\EOF &&
665
test_expect_success "passing test #1" "true"
666
test_done
@@ -691,8 +673,8 @@ test_expect_success '--run invalid range end' '
673
EOF_ERR
674
'
675
694
-test_expect_success 'tests respect prerequisites' '
695
- write_and_run_sub_test_lib_test prereqs "tests respect prereqs" <<-\EOF &&
676
+test_expect_success 'subtest: tests respect prerequisites' '
677
+ write_and_run_sub_test_lib_test prereqs <<-\EOF &&
678
679
test_set_prereq HAVEIT
680
test_expect_success HAVEIT "prereq is satisfied" "true"
@@ -721,8 +703,8 @@ test_expect_success 'tests respect prerequisites' '
703
EOF
704
'
705
724
-test_expect_success 'tests respect lazy prerequisites' '
725
- write_and_run_sub_test_lib_test lazy-prereqs "respect lazy prereqs" <<-\EOF &&
706
+test_expect_success 'subtest: tests respect lazy prerequisites' '
707
+ write_and_run_sub_test_lib_test lazy-prereqs <<-\EOF &&
708
709
test_lazy_prereq LAZY_TRUE true
710
test_expect_success LAZY_TRUE "lazy prereq is satisifed" "true"
@@ -745,8 +727,8 @@ test_expect_success 'tests respect lazy prerequisites' '
727
EOF
728
'
729
748
-test_expect_success 'nested lazy prerequisites' '
749
- write_and_run_sub_test_lib_test nested-lazy "nested lazy prereqs" <<-\EOF &&
730
+test_expect_success 'subtest: nested lazy prerequisites' '
731
+ write_and_run_sub_test_lib_test nested-lazy <<-\EOF &&
732
733
test_lazy_prereq NESTED_INNER "
734
>inner &&
@@ -771,9 +753,9 @@ test_expect_success 'nested lazy prerequisites' '
753
EOF
754
'
755
774
-test_expect_success 'lazy prereqs do not turn off tracing' '
756
+test_expect_success 'subtest: lazy prereqs do not turn off tracing' '
757
write_and_run_sub_test_lib_test lazy-prereq-and-tracing \
776
- "lazy prereqs and -x" -v -x <<-\EOF &&
758
+ -v -x <<-\EOF &&
759
test_lazy_prereq LAZY true
760
761
test_expect_success lazy "test_have_prereq LAZY && echo trace"
@@ -784,8 +766,8 @@ test_expect_success 'lazy prereqs do not turn off tracing' '
766
grep "echo trace" lazy-prereq-and-tracing/err
767
'
768
787
-test_expect_success 'tests clean up after themselves' '
788
- write_and_run_sub_test_lib_test cleanup "test with cleanup" <<-\EOF &&
769
+test_expect_success 'subtest: tests clean up after themselves' '
770
+ write_and_run_sub_test_lib_test cleanup <<-\EOF &&
771
clean=no
772
test_expect_success "do cleanup" "
773
test_when_finished clean=yes
@@ -804,9 +786,9 @@ test_expect_success 'tests clean up after themselves' '
786
EOF
787
'
788
807
-test_expect_success 'tests clean up even on failures' '
789
+test_expect_success 'subtest: tests clean up even on failures' '
790
write_and_run_sub_test_lib_test_err \
809
- failing-cleanup "Failing tests with cleanup commands" <<-\EOF &&
791
+ failing-cleanup <<-\EOF &&
792
test_expect_success "tests clean up even after a failure" "
793
touch clean-after-failure &&
794
test_when_finished rm clean-after-failure &&
@@ -833,9 +815,9 @@ test_expect_success 'tests clean up even on failures' '
815
EOF
816
'
817
836
-test_expect_success 'test_atexit is run' '
818
+test_expect_success 'subtest: test_atexit is run' '
819
write_and_run_sub_test_lib_test_err \
838
- atexit-cleanup "Run atexit commands" -i <<-\EOF &&
820
+ atexit-cleanup -i <<-\EOF &&
821
test_expect_success "tests clean up even after a failure" "
822
> ../../clean-atexit &&
823
test_atexit rm ../../clean-atexit &&