Merge branch 'jk/t0000-cleanups'

Code clean-up.

* jk/t0000-cleanups:
  t0000: consistently use single quotes for outer tests
  t0000: run cleaning test inside sub-test
  t0000: run prereq tests inside sub-test
  t0000: keep clean-up tests together
This commit is contained in:
Junio C Hamano 2021-02-10 14:48:32 -08:00
commit e5abed92f5

View File

@ -135,32 +135,32 @@ check_sub_test_lib_test_err () {
)
}
test_expect_success 'pretend we have a fully passing test suite' "
run_sub_test_lib_test full-pass '3 passing tests' <<-\\EOF &&
test_expect_success 'pretend we have a fully passing test suite' '
run_sub_test_lib_test full-pass "3 passing tests" <<-\EOF &&
for i in 1 2 3
do
test_expect_success \"passing test #\$i\" 'true'
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test full-pass <<-\\EOF
check_sub_test_lib_test full-pass <<-\EOF
> ok 1 - passing test #1
> ok 2 - passing test #2
> ok 3 - passing test #3
> # passed all 3 test(s)
> 1..3
EOF
"
'
test_expect_success 'pretend we have a partially passing test suite' "
test_expect_success 'pretend we have a partially passing test suite' '
run_sub_test_lib_test_err \
partial-pass '2/3 tests passing' <<-\\EOF &&
test_expect_success 'passing test #1' 'true'
test_expect_success 'failing test #2' 'false'
test_expect_success 'passing test #3' 'true'
partial-pass "2/3 tests passing" <<-\EOF &&
test_expect_success "passing test #1" "true"
test_expect_success "failing test #2" "false"
test_expect_success "passing test #3" "true"
test_done
EOF
check_sub_test_lib_test partial-pass <<-\\EOF
check_sub_test_lib_test partial-pass <<-\EOF
> ok 1 - passing test #1
> not ok 2 - failing test #2
# false
@ -168,44 +168,44 @@ test_expect_success 'pretend we have a partially passing test suite' "
> # failed 1 among 3 test(s)
> 1..3
EOF
"
'
test_expect_success 'pretend we have a known breakage' "
run_sub_test_lib_test failing-todo 'A failing TODO test' <<-\\EOF &&
test_expect_success 'passing test' 'true'
test_expect_failure 'pretend we have a known breakage' 'false'
test_expect_success 'pretend we have a known breakage' '
run_sub_test_lib_test failing-todo "A failing TODO test" <<-\EOF &&
test_expect_success "passing test" "true"
test_expect_failure "pretend we have a known breakage" "false"
test_done
EOF
check_sub_test_lib_test failing-todo <<-\\EOF
check_sub_test_lib_test failing-todo <<-\EOF
> ok 1 - passing test
> not ok 2 - pretend we have a known breakage # TODO known breakage
> # still have 1 known breakage(s)
> # passed all remaining 1 test(s)
> 1..2
EOF
"
'
test_expect_success 'pretend we have fixed a known breakage' "
run_sub_test_lib_test passing-todo 'A passing TODO test' <<-\\EOF &&
test_expect_failure 'pretend we have fixed a known breakage' 'true'
test_expect_success 'pretend we have fixed a known breakage' '
run_sub_test_lib_test passing-todo "A passing TODO test" <<-\EOF &&
test_expect_failure "pretend we have fixed a known breakage" "true"
test_done
EOF
check_sub_test_lib_test passing-todo <<-\\EOF
check_sub_test_lib_test passing-todo <<-\EOF
> ok 1 - pretend we have fixed a known breakage # TODO known breakage vanished
> # 1 known breakage(s) vanished; please update test(s)
> 1..1
EOF
"
'
test_expect_success 'pretend we have fixed one of two known breakages (run in sub test-lib)' "
test_expect_success 'pretend we have fixed one of two known breakages (run in sub test-lib)' '
run_sub_test_lib_test partially-passing-todos \
'2 TODO tests, one passing' <<-\\EOF &&
test_expect_failure 'pretend we have a known breakage' 'false'
test_expect_success 'pretend we have a passing test' 'true'
test_expect_failure 'pretend we have fixed another known breakage' 'true'
"2 TODO tests, one passing" <<-\EOF &&
test_expect_failure "pretend we have a known breakage" "false"
test_expect_success "pretend we have a passing test" "true"
test_expect_failure "pretend we have fixed another known breakage" "true"
test_done
EOF
check_sub_test_lib_test partially-passing-todos <<-\\EOF
check_sub_test_lib_test partially-passing-todos <<-\EOF
> not ok 1 - pretend we have a known breakage # TODO known breakage
> ok 2 - pretend we have a passing test
> ok 3 - pretend we have fixed another known breakage # TODO known breakage vanished
@ -214,17 +214,17 @@ test_expect_success 'pretend we have fixed one of two known breakages (run in su
> # passed all remaining 1 test(s)
> 1..3
EOF
"
'
test_expect_success 'pretend we have a pass, fail, and known breakage' "
test_expect_success 'pretend we have a pass, fail, and known breakage' '
run_sub_test_lib_test_err \
mixed-results1 'mixed results #1' <<-\\EOF &&
test_expect_success 'passing test' 'true'
test_expect_success 'failing test' 'false'
test_expect_failure 'pretend we have a known breakage' 'false'
mixed-results1 "mixed results #1" <<-\EOF &&
test_expect_success "passing test" "true"
test_expect_success "failing test" "false"
test_expect_failure "pretend we have a known breakage" "false"
test_done
EOF
check_sub_test_lib_test mixed-results1 <<-\\EOF
check_sub_test_lib_test mixed-results1 <<-\EOF
> ok 1 - passing test
> not ok 2 - failing test
> # false
@ -233,24 +233,24 @@ test_expect_success 'pretend we have a pass, fail, and known breakage' "
> # failed 1 among remaining 2 test(s)
> 1..3
EOF
"
'
test_expect_success 'pretend we have a mix of all possible results' "
test_expect_success 'pretend we have a mix of all possible results' '
run_sub_test_lib_test_err \
mixed-results2 'mixed results #2' <<-\\EOF &&
test_expect_success 'passing test' 'true'
test_expect_success 'passing test' 'true'
test_expect_success 'passing test' 'true'
test_expect_success 'passing test' 'true'
test_expect_success 'failing test' 'false'
test_expect_success 'failing test' 'false'
test_expect_success 'failing test' 'false'
test_expect_failure 'pretend we have a known breakage' 'false'
test_expect_failure 'pretend we have a known breakage' 'false'
test_expect_failure 'pretend we have fixed a known breakage' 'true'
mixed-results2 "mixed results #2" <<-\EOF &&
test_expect_success "passing test" "true"
test_expect_success "passing test" "true"
test_expect_success "passing test" "true"
test_expect_success "passing test" "true"
test_expect_success "failing test" "false"
test_expect_success "failing test" "false"
test_expect_success "failing test" "false"
test_expect_failure "pretend we have a known breakage" "false"
test_expect_failure "pretend we have a known breakage" "false"
test_expect_failure "pretend we have fixed a known breakage" "true"
test_done
EOF
check_sub_test_lib_test mixed-results2 <<-\\EOF
check_sub_test_lib_test mixed-results2 <<-\EOF
> ok 1 - passing test
> ok 2 - passing test
> ok 3 - passing test
@ -269,7 +269,7 @@ test_expect_success 'pretend we have a mix of all possible results' "
> # failed 3 among remaining 7 test(s)
> 1..10
EOF
"
'
test_expect_success C_LOCALE_OUTPUT 'test --verbose' '
run_sub_test_lib_test_err \
@ -321,18 +321,18 @@ test_expect_success 'test --verbose-only' '
EOF
'
test_expect_success 'GIT_SKIP_TESTS' "
test_expect_success 'GIT_SKIP_TESTS' '
(
GIT_SKIP_TESTS='git.2' && export GIT_SKIP_TESTS &&
GIT_SKIP_TESTS="git.2" && export GIT_SKIP_TESTS &&
run_sub_test_lib_test git-skip-tests-basic \
'GIT_SKIP_TESTS' <<-\\EOF &&
"GIT_SKIP_TESTS" <<-\EOF &&
for i in 1 2 3
do
test_expect_success \"passing test #\$i\" 'true'
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test git-skip-tests-basic <<-\\EOF
check_sub_test_lib_test git-skip-tests-basic <<-\EOF
> ok 1 - passing test #1
> ok 2 # skip passing test #2 (GIT_SKIP_TESTS)
> ok 3 - passing test #3
@ -340,20 +340,20 @@ test_expect_success 'GIT_SKIP_TESTS' "
> 1..3
EOF
)
"
'
test_expect_success 'GIT_SKIP_TESTS several tests' "
test_expect_success 'GIT_SKIP_TESTS several tests' '
(
GIT_SKIP_TESTS='git.2 git.5' && export GIT_SKIP_TESTS &&
GIT_SKIP_TESTS="git.2 git.5" && export GIT_SKIP_TESTS &&
run_sub_test_lib_test git-skip-tests-several \
'GIT_SKIP_TESTS several tests' <<-\\EOF &&
"GIT_SKIP_TESTS several tests" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success \"passing test #\$i\" 'true'
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test git-skip-tests-several <<-\\EOF
check_sub_test_lib_test git-skip-tests-several <<-\EOF
> ok 1 - passing test #1
> ok 2 # skip passing test #2 (GIT_SKIP_TESTS)
> ok 3 - passing test #3
@ -364,20 +364,20 @@ test_expect_success 'GIT_SKIP_TESTS several tests' "
> 1..6
EOF
)
"
'
test_expect_success 'GIT_SKIP_TESTS sh pattern' "
test_expect_success 'GIT_SKIP_TESTS sh pattern' '
(
GIT_SKIP_TESTS='git.[2-5]' && export GIT_SKIP_TESTS &&
GIT_SKIP_TESTS="git.[2-5]" && export GIT_SKIP_TESTS &&
run_sub_test_lib_test git-skip-tests-sh-pattern \
'GIT_SKIP_TESTS sh pattern' <<-\\EOF &&
"GIT_SKIP_TESTS sh pattern" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success \"passing test #\$i\" 'true'
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test git-skip-tests-sh-pattern <<-\\EOF
check_sub_test_lib_test git-skip-tests-sh-pattern <<-\EOF
> ok 1 - passing test #1
> ok 2 # skip passing test #2 (GIT_SKIP_TESTS)
> ok 3 # skip passing test #3 (GIT_SKIP_TESTS)
@ -388,37 +388,37 @@ test_expect_success 'GIT_SKIP_TESTS sh pattern' "
> 1..6
EOF
)
"
'
test_expect_success 'GIT_SKIP_TESTS entire suite' "
test_expect_success 'GIT_SKIP_TESTS entire suite' '
(
GIT_SKIP_TESTS='git' && export GIT_SKIP_TESTS &&
GIT_SKIP_TESTS="git" && export GIT_SKIP_TESTS &&
run_sub_test_lib_test git-skip-tests-entire-suite \
'GIT_SKIP_TESTS entire suite' <<-\\EOF &&
"GIT_SKIP_TESTS entire suite" <<-\EOF &&
for i in 1 2 3
do
test_expect_success \"passing test #\$i\" 'true'
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test git-skip-tests-entire-suite <<-\\EOF
check_sub_test_lib_test git-skip-tests-entire-suite <<-\EOF
> 1..0 # SKIP skip all tests in git
EOF
)
"
'
test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' "
test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '
(
GIT_SKIP_TESTS='notgit' && export GIT_SKIP_TESTS &&
GIT_SKIP_TESTS="notgit" && export GIT_SKIP_TESTS &&
run_sub_test_lib_test git-skip-tests-unmatched-suite \
'GIT_SKIP_TESTS does not skip unmatched suite' <<-\\EOF &&
"GIT_SKIP_TESTS does not skip unmatched suite" <<-\EOF &&
for i in 1 2 3
do
test_expect_success \"passing test #\$i\" 'true'
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test git-skip-tests-unmatched-suite <<-\\EOF
check_sub_test_lib_test git-skip-tests-unmatched-suite <<-\EOF
> ok 1 - passing test #1
> ok 2 - passing test #2
> ok 3 - passing test #3
@ -426,18 +426,18 @@ test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' "
> 1..3
EOF
)
"
'
test_expect_success '--run basic' "
test_expect_success '--run basic' '
run_sub_test_lib_test run-basic \
'--run basic' --run='1,3,5' <<-\\EOF &&
"--run basic" --run="1,3,5" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success \"passing test #\$i\" 'true'
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-basic <<-\\EOF
check_sub_test_lib_test run-basic <<-\EOF
> ok 1 - passing test #1
> ok 2 # skip passing test #2 (--run)
> ok 3 - passing test #3
@ -447,18 +447,18 @@ test_expect_success '--run basic' "
> # passed all 6 test(s)
> 1..6
EOF
"
'
test_expect_success '--run with a range' "
test_expect_success '--run with a range' '
run_sub_test_lib_test run-range \
'--run with a range' --run='1-3' <<-\\EOF &&
"--run with a range" --run="1-3" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success \"passing test #\$i\" 'true'
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-range <<-\\EOF
check_sub_test_lib_test run-range <<-\EOF
> ok 1 - passing test #1
> ok 2 - passing test #2
> ok 3 - passing test #3
@ -468,18 +468,18 @@ test_expect_success '--run with a range' "
> # passed all 6 test(s)
> 1..6
EOF
"
'
test_expect_success '--run with two ranges' "
test_expect_success '--run with two ranges' '
run_sub_test_lib_test run-two-ranges \
'--run with two ranges' --run='1-2,5-6' <<-\\EOF &&
"--run with two ranges" --run="1-2,5-6" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success \"passing test #\$i\" 'true'
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-two-ranges <<-\\EOF
check_sub_test_lib_test run-two-ranges <<-\EOF
> ok 1 - passing test #1
> ok 2 - passing test #2
> ok 3 # skip passing test #3 (--run)
@ -489,18 +489,18 @@ test_expect_success '--run with two ranges' "
> # passed all 6 test(s)
> 1..6
EOF
"
'
test_expect_success '--run with a left open range' "
test_expect_success '--run with a left open range' '
run_sub_test_lib_test run-left-open-range \
'--run with a left open range' --run='-3' <<-\\EOF &&
"--run with a left open range" --run="-3" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success \"passing test #\$i\" 'true'
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-left-open-range <<-\\EOF
check_sub_test_lib_test run-left-open-range <<-\EOF
> ok 1 - passing test #1
> ok 2 - passing test #2
> ok 3 - passing test #3
@ -510,18 +510,18 @@ test_expect_success '--run with a left open range' "
> # passed all 6 test(s)
> 1..6
EOF
"
'
test_expect_success '--run with a right open range' "
test_expect_success '--run with a right open range' '
run_sub_test_lib_test run-right-open-range \
'--run with a right open range' --run='4-' <<-\\EOF &&
"--run with a right open range" --run="4-" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success \"passing test #\$i\" 'true'
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-right-open-range <<-\\EOF
check_sub_test_lib_test run-right-open-range <<-\EOF
> ok 1 # skip passing test #1 (--run)
> ok 2 # skip passing test #2 (--run)
> ok 3 # skip passing test #3 (--run)
@ -531,18 +531,18 @@ test_expect_success '--run with a right open range' "
> # passed all 6 test(s)
> 1..6
EOF
"
'
test_expect_success '--run with basic negation' "
test_expect_success '--run with basic negation' '
run_sub_test_lib_test run-basic-neg \
'--run with basic negation' --run='"'!3'"' <<-\\EOF &&
"--run with basic negation" --run="!3" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success \"passing test #\$i\" 'true'
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-basic-neg <<-\\EOF
check_sub_test_lib_test run-basic-neg <<-\EOF
> ok 1 - passing test #1
> ok 2 - passing test #2
> ok 3 # skip passing test #3 (--run)
@ -552,18 +552,18 @@ test_expect_success '--run with basic negation' "
> # passed all 6 test(s)
> 1..6
EOF
"
'
test_expect_success '--run with two negations' "
test_expect_success '--run with two negations' '
run_sub_test_lib_test run-two-neg \
'--run with two negations' --run='"'!3,!6'"' <<-\\EOF &&
"--run with two negations" --run="!3,!6" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success \"passing test #\$i\" 'true'
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-two-neg <<-\\EOF
check_sub_test_lib_test run-two-neg <<-\EOF
> ok 1 - passing test #1
> ok 2 - passing test #2
> ok 3 # skip passing test #3 (--run)
@ -573,18 +573,18 @@ test_expect_success '--run with two negations' "
> # passed all 6 test(s)
> 1..6
EOF
"
'
test_expect_success '--run a range and negation' "
test_expect_success '--run a range and negation' '
run_sub_test_lib_test run-range-and-neg \
'--run a range and negation' --run='"'-4,!2'"' <<-\\EOF &&
"--run a range and negation" --run="-4,!2" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success \"passing test #\$i\" 'true'
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-range-and-neg <<-\\EOF
check_sub_test_lib_test run-range-and-neg <<-\EOF
> ok 1 - passing test #1
> ok 2 # skip passing test #2 (--run)
> ok 3 - passing test #3
@ -594,18 +594,18 @@ test_expect_success '--run a range and negation' "
> # passed all 6 test(s)
> 1..6
EOF
"
'
test_expect_success '--run range negation' "
test_expect_success '--run range negation' '
run_sub_test_lib_test run-range-neg \
'--run range negation' --run='"'!1-3'"' <<-\\EOF &&
"--run range negation" --run="!1-3" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success \"passing test #\$i\" 'true'
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-range-neg <<-\\EOF
check_sub_test_lib_test run-range-neg <<-\EOF
> ok 1 # skip passing test #1 (--run)
> ok 2 # skip passing test #2 (--run)
> ok 3 # skip passing test #3 (--run)
@ -615,19 +615,19 @@ test_expect_success '--run range negation' "
> # passed all 6 test(s)
> 1..6
EOF
"
'
test_expect_success '--run include, exclude and include' "
test_expect_success '--run include, exclude and include' '
run_sub_test_lib_test run-inc-neg-inc \
'--run include, exclude and include' \
--run='"'1-5,!1-3,2'"' <<-\\EOF &&
"--run include, exclude and include" \
--run="1-5,!1-3,2" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success \"passing test #\$i\" 'true'
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-inc-neg-inc <<-\\EOF
check_sub_test_lib_test run-inc-neg-inc <<-\EOF
> ok 1 # skip passing test #1 (--run)
> ok 2 - passing test #2
> ok 3 # skip passing test #3 (--run)
@ -637,19 +637,19 @@ test_expect_success '--run include, exclude and include' "
> # passed all 6 test(s)
> 1..6
EOF
"
'
test_expect_success '--run include, exclude and include, comma separated' "
test_expect_success '--run include, exclude and include, comma separated' '
run_sub_test_lib_test run-inc-neg-inc-comma \
'--run include, exclude and include, comma separated' \
--run=1-5,\!1-3,2 <<-\\EOF &&
"--run include, exclude and include, comma separated" \
--run=1-5,!1-3,2 <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success \"passing test #\$i\" 'true'
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-inc-neg-inc-comma <<-\\EOF
check_sub_test_lib_test run-inc-neg-inc-comma <<-\EOF
> ok 1 # skip passing test #1 (--run)
> ok 2 - passing test #2
> ok 3 # skip passing test #3 (--run)
@ -659,19 +659,19 @@ test_expect_success '--run include, exclude and include, comma separated' "
> # passed all 6 test(s)
> 1..6
EOF
"
'
test_expect_success '--run exclude and include' "
test_expect_success '--run exclude and include' '
run_sub_test_lib_test run-neg-inc \
'--run exclude and include' \
--run='"'!3-,5'"' <<-\\EOF &&
"--run exclude and include" \
--run="!3-,5" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success \"passing test #\$i\" 'true'
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-neg-inc <<-\\EOF
check_sub_test_lib_test run-neg-inc <<-\EOF
> ok 1 - passing test #1
> ok 2 - passing test #2
> ok 3 # skip passing test #3 (--run)
@ -681,19 +681,19 @@ test_expect_success '--run exclude and include' "
> # passed all 6 test(s)
> 1..6
EOF
"
'
test_expect_success '--run empty selectors' "
test_expect_success '--run empty selectors' '
run_sub_test_lib_test run-empty-sel \
'--run empty selectors' \
--run='1,,3,,,5' <<-\\EOF &&
"--run empty selectors" \
--run="1,,3,,,5" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success \"passing test #\$i\" 'true'
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-empty-sel <<-\\EOF
check_sub_test_lib_test run-empty-sel <<-\EOF
> ok 1 - passing test #1
> ok 2 # skip passing test #2 (--run)
> ok 3 - passing test #3
@ -703,20 +703,20 @@ test_expect_success '--run empty selectors' "
> # passed all 6 test(s)
> 1..6
EOF
"
'
test_expect_success '--run substring selector' "
test_expect_success '--run substring selector' '
run_sub_test_lib_test run-substring-selector \
'--run empty selectors' \
--run='relevant' <<-\\EOF &&
test_expect_success \"relevant test\" 'true'
"--run empty selectors" \
--run="relevant" <<-\EOF &&
test_expect_success "relevant test" "true"
for i in 1 2 3 4 5 6
do
test_expect_success \"other test #\$i\" 'true'
test_expect_success "other test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-substring-selector <<-\\EOF
check_sub_test_lib_test run-substring-selector <<-\EOF
> ok 1 - relevant test
> ok 2 # skip other test #1 (--run)
> ok 3 # skip other test #2 (--run)
@ -727,167 +727,165 @@ test_expect_success '--run substring selector' "
> # passed all 7 test(s)
> 1..7
EOF
"
'
test_expect_success '--run keyword selection' "
test_expect_success '--run keyword selection' '
run_sub_test_lib_test_err run-inv-range-start \
'--run invalid range start' \
--run='a-5' <<-\\EOF &&
test_expect_success \"passing test #1\" 'true'
"--run invalid range start" \
--run="a-5" <<-\EOF &&
test_expect_success "passing test #1" "true"
test_done
EOF
check_sub_test_lib_test_err run-inv-range-start \
<<-\\EOF_OUT 3<<-\\EOF_ERR
<<-\EOF_OUT 3<<-EOF_ERR
> FATAL: Unexpected exit with code 1
EOF_OUT
> error: --run: invalid non-numeric in range start: 'a-5'
> error: --run: invalid non-numeric in range start: ${SQ}a-5${SQ}
EOF_ERR
"
'
test_expect_success '--run invalid range end' "
test_expect_success '--run invalid range end' '
run_sub_test_lib_test_err run-inv-range-end \
'--run invalid range end' \
--run='1-z' <<-\\EOF &&
test_expect_success \"passing test #1\" 'true'
"--run invalid range end" \
--run="1-z" <<-\EOF &&
test_expect_success "passing test #1" "true"
test_done
EOF
check_sub_test_lib_test_err run-inv-range-end \
<<-\\EOF_OUT 3<<-\\EOF_ERR
<<-\EOF_OUT 3<<-EOF_ERR
> FATAL: Unexpected exit with code 1
EOF_OUT
> error: --run: invalid non-numeric in range end: '1-z'
> error: --run: invalid non-numeric in range end: ${SQ}1-z${SQ}
EOF_ERR
"
test_set_prereq HAVEIT
haveit=no
test_expect_success HAVEIT 'test runs if prerequisite is satisfied' '
test_have_prereq HAVEIT &&
haveit=yes
'
donthaveit=yes
test_expect_success DONTHAVEIT 'unmet prerequisite causes test to be skipped' '
donthaveit=no
'
if test -z "$GIT_TEST_FAIL_PREREQS_INTERNAL" -a $haveit$donthaveit != yesyes
then
say "bug in test framework: prerequisite tags do not work reliably"
exit 1
fi
test_set_prereq HAVETHIS
haveit=no
test_expect_success HAVETHIS,HAVEIT 'test runs if prerequisites are satisfied' '
test_have_prereq HAVEIT &&
test_have_prereq HAVETHIS &&
haveit=yes
'
donthaveit=yes
test_expect_success HAVEIT,DONTHAVEIT 'unmet prerequisites causes test to be skipped' '
donthaveit=no
'
donthaveiteither=yes
test_expect_success DONTHAVEIT,HAVEIT 'unmet prerequisites causes test to be skipped' '
donthaveiteither=no
'
if test -z "$GIT_TEST_FAIL_PREREQS_INTERNAL" -a $haveit$donthaveit$donthaveiteither != yesyesyes
then
say "bug in test framework: multiple prerequisite tags do not work reliably"
exit 1
fi
test_lazy_prereq LAZY_TRUE true
havetrue=no
test_expect_success LAZY_TRUE 'test runs if lazy prereq is satisfied' '
havetrue=yes
'
donthavetrue=yes
test_expect_success !LAZY_TRUE 'missing lazy prereqs skip tests' '
donthavetrue=no
'
if test -z "$GIT_TEST_FAIL_PREREQS_INTERNAL" -a "$havetrue$donthavetrue" != yesyes
then
say 'bug in test framework: lazy prerequisites do not work'
exit 1
fi
test_expect_success 'tests respect prerequisites' '
run_sub_test_lib_test prereqs "tests respect prereqs" <<-\EOF &&
test_lazy_prereq LAZY_FALSE false
nothavefalse=no
test_expect_success !LAZY_FALSE 'negative lazy prereqs checked' '
nothavefalse=yes
'
havefalse=yes
test_expect_success LAZY_FALSE 'missing negative lazy prereqs will skip' '
havefalse=no
'
test_set_prereq HAVEIT
test_expect_success HAVEIT "prereq is satisfied" "true"
test_expect_success "have_prereq works" "
test_have_prereq HAVEIT
"
test_expect_success DONTHAVEIT "prereq not satisfied" "false"
if test -z "$GIT_TEST_FAIL_PREREQS_INTERNAL" -a "$nothavefalse$havefalse" != yesyes
then
say 'bug in test framework: negative lazy prerequisites do not work'
exit 1
fi
clean=no
test_expect_success 'tests clean up after themselves' '
test_when_finished clean=yes
'
if test -z "$GIT_TEST_FAIL_PREREQS_INTERNAL" -a $clean != yes
then
say "bug in test framework: basic cleanup command does not work reliably"
exit 1
fi
test_lazy_prereq NESTED_INNER '
>inner &&
rm -f outer
'
test_lazy_prereq NESTED_PREREQ '
>outer &&
test_have_prereq NESTED_INNER &&
echo "can create new file in cwd" >file &&
test -f outer &&
test ! -f inner
'
test_expect_success NESTED_PREREQ 'evaluating nested lazy prereqs dont interfere with each other' '
nestedworks=yes
'
if test -z "$GIT_TEST_FAIL_PREREQS_INTERNAL" && test "$nestedworks" != yes
then
say 'bug in test framework: nested lazy prerequisites do not work'
exit 1
fi
test_expect_success 'lazy prereqs do not turn off tracing' "
run_sub_test_lib_test lazy-prereq-and-tracing \
'lazy prereqs and -x' -v -x <<-\\EOF &&
test_lazy_prereq LAZY true
test_expect_success lazy 'test_have_prereq LAZY && echo trace'
test_set_prereq HAVETHIS
test_expect_success HAVETHIS,HAVEIT "multiple prereqs" "true"
test_expect_success HAVEIT,DONTHAVEIT "mixed prereqs (yes,no)" "false"
test_expect_success DONTHAVEIT,HAVEIT "mixed prereqs (no,yes)" "false"
test_done
EOF
grep 'echo trace' lazy-prereq-and-tracing/err
"
check_sub_test_lib_test prereqs <<-\EOF
ok 1 - prereq is satisfied
ok 2 - have_prereq works
ok 3 # skip prereq not satisfied (missing DONTHAVEIT)
ok 4 - multiple prereqs
ok 5 # skip mixed prereqs (yes,no) (missing DONTHAVEIT of HAVEIT,DONTHAVEIT)
ok 6 # skip mixed prereqs (no,yes) (missing DONTHAVEIT of DONTHAVEIT,HAVEIT)
# passed all 6 test(s)
1..6
EOF
'
test_expect_success 'tests clean up even on failures' "
test_expect_success 'tests respect lazy prerequisites' '
run_sub_test_lib_test lazy-prereqs "respect lazy prereqs" <<-\EOF &&
test_lazy_prereq LAZY_TRUE true
test_expect_success LAZY_TRUE "lazy prereq is satisifed" "true"
test_expect_success !LAZY_TRUE "negative lazy prereq" "false"
test_lazy_prereq LAZY_FALSE false
test_expect_success LAZY_FALSE "lazy prereq not satisfied" "false"
test_expect_success !LAZY_FALSE "negative false prereq" "true"
test_done
EOF
check_sub_test_lib_test lazy-prereqs <<-\EOF
ok 1 - lazy prereq is satisifed
ok 2 # skip negative lazy prereq (missing !LAZY_TRUE)
ok 3 # skip lazy prereq not satisfied (missing LAZY_FALSE)
ok 4 - negative false prereq
# passed all 4 test(s)
1..4
EOF
'
test_expect_success 'nested lazy prerequisites' '
run_sub_test_lib_test nested-lazy "nested lazy prereqs" <<-\EOF &&
test_lazy_prereq NESTED_INNER "
>inner &&
rm -f outer
"
test_lazy_prereq NESTED_PREREQ "
>outer &&
test_have_prereq NESTED_INNER &&
echo can create new file in cwd >file &&
test_path_is_file outer &&
test_path_is_missing inner
"
test_expect_success NESTED_PREREQ "evaluate nested prereq" "true"
test_done
EOF
check_sub_test_lib_test nested-lazy <<-\EOF
ok 1 - evaluate nested prereq
# passed all 1 test(s)
1..1
EOF
'
test_expect_success 'lazy prereqs do not turn off tracing' '
run_sub_test_lib_test lazy-prereq-and-tracing \
"lazy prereqs and -x" -v -x <<-\EOF &&
test_lazy_prereq LAZY true
test_expect_success lazy "test_have_prereq LAZY && echo trace"
test_done
EOF
grep "echo trace" lazy-prereq-and-tracing/err
'
test_expect_success 'tests clean up after themselves' '
run_sub_test_lib_test cleanup "test with cleanup" <<-\EOF &&
clean=no
test_expect_success "do cleanup" "
test_when_finished clean=yes
"
test_expect_success "cleanup happened" "
test $clean = yes
"
test_done
EOF
check_sub_test_lib_test cleanup <<-\EOF
ok 1 - do cleanup
ok 2 - cleanup happened
# passed all 2 test(s)
1..2
EOF
'
test_expect_success 'tests clean up even on failures' '
run_sub_test_lib_test_err \
failing-cleanup 'Failing tests with cleanup commands' <<-\\EOF &&
test_expect_success 'tests clean up even after a failure' '
failing-cleanup "Failing tests with cleanup commands" <<-\EOF &&
test_expect_success "tests clean up even after a failure" "
touch clean-after-failure &&
test_when_finished rm clean-after-failure &&
(exit 1)
'
test_expect_success 'failure to clean up causes the test to fail' '
"
test_expect_success "failure to clean up causes the test to fail" "
test_when_finished \"(exit 2)\"
'
"
test_done
EOF
check_sub_test_lib_test failing-cleanup <<-\\EOF
check_sub_test_lib_test failing-cleanup <<-\EOF
> not ok 1 - tests clean up even after a failure
> # Z
> # touch clean-after-failure &&
@ -896,30 +894,30 @@ test_expect_success 'tests clean up even on failures' "
> # Z
> not ok 2 - failure to clean up causes the test to fail
> # Z
> # test_when_finished \"(exit 2)\"
> # test_when_finished "(exit 2)"
> # Z
> # failed 2 among 2 test(s)
> 1..2
EOF
"
'
test_expect_success 'test_atexit is run' "
test_expect_success 'test_atexit is run' '
run_sub_test_lib_test_err \
atexit-cleanup 'Run atexit commands' -i <<-\\EOF &&
test_expect_success 'tests clean up even after a failure' '
atexit-cleanup "Run atexit commands" -i <<-\EOF &&
test_expect_success "tests clean up even after a failure" "
> ../../clean-atexit &&
test_atexit rm ../../clean-atexit &&
> ../../also-clean-atexit &&
test_atexit rm ../../also-clean-atexit &&
> ../../dont-clean-atexit &&
(exit 1)
'
"
test_done
EOF
test_path_is_file dont-clean-atexit &&
test_path_is_missing clean-atexit &&
test_path_is_missing also-clean-atexit
"
'
test_expect_success 'test_oid provides sane info by default' '
test_oid zero >actual &&