test-lib tests: get rid of copy/pasted mock test code

Now that we've split up the write_sub_test_lib_test*() and
run_sub_test_lib_test*() functions let's fix those tests in
t0000-basic.sh that were verbosely copy/pasting earlier tests.

That we caught all of them was asserted with a follow-up change that's
not part of this series[1], we might add such a duplication check at
some later time, but for now let's just one-off remove the duplicate
boilerplate.

1. https://lore.kernel.org/git/patch-v3-6.9-bc79b29f3c-20210805T103237Z-avarab@gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ævar Arnfjörð Bjarmason 2021-09-22 13:19:53 +02:00 committed by Junio C Hamano
parent 56722a0635
commit 2e54907e83

View File

@ -226,18 +226,13 @@ test_expect_success 'subtest: --verbose option' '
'
test_expect_success 'subtest: --verbose-only option' '
write_and_run_sub_test_lib_test_err \
t2345-verbose-only-2 \
--verbose-only=2 <<-\EOF &&
test_expect_success "passing test" true
test_expect_success "test with output" "echo foo"
test_expect_success "failing test" false
test_done
EOF
check_sub_test_lib_test t2345-verbose-only-2 <<-\EOF
run_sub_test_lib_test_err \
t1234-verbose \
--verbose-only=2 &&
check_sub_test_lib_test t1234-verbose <<-\EOF
> ok 1 - passing test
> Z
> expecting success of 2345.2 '\''test with output'\'': echo foo
> expecting success of 1234.2 '\''test with output'\'': echo foo
> foo
> ok 2 - test with output
> Z
@ -250,15 +245,9 @@ test_expect_success 'subtest: --verbose-only option' '
test_expect_success 'subtest: skip one with GIT_SKIP_TESTS' '
(
write_and_run_sub_test_lib_test git-skip-tests-basic \
--skip="git.2" <<-\EOF &&
for i in 1 2 3
do
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test git-skip-tests-basic <<-\EOF
run_sub_test_lib_test full-pass \
--skip="full.2" &&
check_sub_test_lib_test full-pass <<-\EOF
> ok 1 - passing test #1
> ok 2 # skip passing test #2 (GIT_SKIP_TESTS)
> ok 3 - passing test #3
@ -293,15 +282,9 @@ test_expect_success 'subtest: skip several with GIT_SKIP_TESTS' '
test_expect_success 'subtest: sh pattern skipping with GIT_SKIP_TESTS' '
(
write_and_run_sub_test_lib_test git-skip-tests-sh-pattern \
--skip="git.[2-5]" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test git-skip-tests-sh-pattern <<-\EOF
run_sub_test_lib_test git-skip-tests-several \
--skip="git.[2-5]" &&
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 # skip passing test #3 (GIT_SKIP_TESTS)
@ -316,15 +299,10 @@ test_expect_success 'subtest: sh pattern skipping with GIT_SKIP_TESTS' '
test_expect_success 'subtest: skip entire test suite with GIT_SKIP_TESTS' '
(
write_and_run_sub_test_lib_test git-skip-tests-entire-suite \
--skip="git" <<-\EOF &&
for i in 1 2 3
do
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test git-skip-tests-entire-suite <<-\EOF
GIT_SKIP_TESTS="git" && export GIT_SKIP_TESTS &&
run_sub_test_lib_test git-skip-tests-several \
--skip="git" &&
check_sub_test_lib_test git-skip-tests-several <<-\EOF
> 1..0 # SKIP skip all tests in git
EOF
)
@ -332,15 +310,10 @@ test_expect_success 'subtest: skip entire test suite with GIT_SKIP_TESTS' '
test_expect_success 'subtest: GIT_SKIP_TESTS does not skip unmatched suite' '
(
write_and_run_sub_test_lib_test git-skip-tests-unmatched-suite \
--skip="notgit" <<-\EOF &&
for i in 1 2 3
do
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test git-skip-tests-unmatched-suite <<-\EOF
GIT_SKIP_TESTS="notgit" && export GIT_SKIP_TESTS &&
run_sub_test_lib_test full-pass \
--skip="notfull" &&
check_sub_test_lib_test full-pass <<-\EOF
> ok 1 - passing test #1
> ok 2 - passing test #2
> ok 3 - passing test #3
@ -351,14 +324,8 @@ test_expect_success 'subtest: GIT_SKIP_TESTS does not skip unmatched suite' '
'
test_expect_success 'subtest: --run basic' '
write_and_run_sub_test_lib_test run-basic --run="1,3,5" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-basic <<-\EOF
run_sub_test_lib_test git-skip-tests-several --run="1,3,5" &&
check_sub_test_lib_test git-skip-tests-several <<-\EOF
> ok 1 - passing test #1
> ok 2 # skip passing test #2 (--run)
> ok 3 - passing test #3
@ -371,15 +338,9 @@ test_expect_success 'subtest: --run basic' '
'
test_expect_success 'subtest: --run with a range' '
write_and_run_sub_test_lib_test run-range \
--run="1-3" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-range <<-\EOF
run_sub_test_lib_test git-skip-tests-several \
--run="1-3" &&
check_sub_test_lib_test git-skip-tests-several <<-\EOF
> ok 1 - passing test #1
> ok 2 - passing test #2
> ok 3 - passing test #3
@ -392,15 +353,9 @@ test_expect_success 'subtest: --run with a range' '
'
test_expect_success 'subtest: --run with two ranges' '
write_and_run_sub_test_lib_test run-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"
done
test_done
EOF
check_sub_test_lib_test run-two-ranges <<-\EOF
run_sub_test_lib_test git-skip-tests-several \
--run="1-2,5-6" &&
check_sub_test_lib_test git-skip-tests-several <<-\EOF
> ok 1 - passing test #1
> ok 2 - passing test #2
> ok 3 # skip passing test #3 (--run)
@ -413,15 +368,9 @@ test_expect_success 'subtest: --run with two ranges' '
'
test_expect_success 'subtest: --run with a left open range' '
write_and_run_sub_test_lib_test run-left-open-range \
--run="-3" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-left-open-range <<-\EOF
run_sub_test_lib_test git-skip-tests-several \
--run="-3" &&
check_sub_test_lib_test git-skip-tests-several <<-\EOF
> ok 1 - passing test #1
> ok 2 - passing test #2
> ok 3 - passing test #3
@ -434,15 +383,9 @@ test_expect_success 'subtest: --run with a left open range' '
'
test_expect_success 'subtest: --run with a right open range' '
write_and_run_sub_test_lib_test run-right-open-range \
--run="4-" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-right-open-range <<-\EOF
run_sub_test_lib_test git-skip-tests-several \
--run="4-" &&
check_sub_test_lib_test git-skip-tests-several <<-\EOF
> ok 1 # skip passing test #1 (--run)
> ok 2 # skip passing test #2 (--run)
> ok 3 # skip passing test #3 (--run)
@ -455,15 +398,9 @@ test_expect_success 'subtest: --run with a right open range' '
'
test_expect_success 'subtest: --run with basic negation' '
write_and_run_sub_test_lib_test run-basic-neg \
--run="!3" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-basic-neg <<-\EOF
run_sub_test_lib_test git-skip-tests-several \
--run="!3" &&
check_sub_test_lib_test git-skip-tests-several <<-\EOF
> ok 1 - passing test #1
> ok 2 - passing test #2
> ok 3 # skip passing test #3 (--run)
@ -476,15 +413,9 @@ test_expect_success 'subtest: --run with basic negation' '
'
test_expect_success 'subtest: --run with two negations' '
write_and_run_sub_test_lib_test run-two-neg \
--run="!3,!6" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-two-neg <<-\EOF
run_sub_test_lib_test git-skip-tests-several \
--run="!3,!6" &&
check_sub_test_lib_test git-skip-tests-several <<-\EOF
> ok 1 - passing test #1
> ok 2 - passing test #2
> ok 3 # skip passing test #3 (--run)
@ -497,15 +428,9 @@ test_expect_success 'subtest: --run with two negations' '
'
test_expect_success 'subtest: --run a range and negation' '
write_and_run_sub_test_lib_test run-range-and-neg \
--run="-4,!2" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-range-and-neg <<-\EOF
run_sub_test_lib_test git-skip-tests-several \
--run="-4,!2" &&
check_sub_test_lib_test git-skip-tests-several <<-\EOF
> ok 1 - passing test #1
> ok 2 # skip passing test #2 (--run)
> ok 3 - passing test #3
@ -518,15 +443,9 @@ test_expect_success 'subtest: --run a range and negation' '
'
test_expect_success 'subtest: --run range negation' '
write_and_run_sub_test_lib_test run-range-neg \
--run="!1-3" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-range-neg <<-\EOF
run_sub_test_lib_test git-skip-tests-several \
--run="!1-3" &&
check_sub_test_lib_test git-skip-tests-several <<-\EOF
> ok 1 # skip passing test #1 (--run)
> ok 2 # skip passing test #2 (--run)
> ok 3 # skip passing test #3 (--run)
@ -539,15 +458,9 @@ test_expect_success 'subtest: --run range negation' '
'
test_expect_success 'subtest: --run include, exclude and include' '
write_and_run_sub_test_lib_test run-inc-neg-inc \
--run="1-5,!1-3,2" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-inc-neg-inc <<-\EOF
run_sub_test_lib_test git-skip-tests-several \
--run="1-5,!1-3,2" &&
check_sub_test_lib_test git-skip-tests-several <<-\EOF
> ok 1 # skip passing test #1 (--run)
> ok 2 - passing test #2
> ok 3 # skip passing test #3 (--run)
@ -560,15 +473,9 @@ test_expect_success 'subtest: --run include, exclude and include' '
'
test_expect_success 'subtest: --run include, exclude and include, comma separated' '
write_and_run_sub_test_lib_test run-inc-neg-inc-comma \
--run=1-5,!1-3,2 <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-inc-neg-inc-comma <<-\EOF
run_sub_test_lib_test git-skip-tests-several \
--run=1-5,!1-3,2 &&
check_sub_test_lib_test git-skip-tests-several <<-\EOF
> ok 1 # skip passing test #1 (--run)
> ok 2 - passing test #2
> ok 3 # skip passing test #3 (--run)
@ -581,15 +488,9 @@ test_expect_success 'subtest: --run include, exclude and include, comma separate
'
test_expect_success 'subtest: --run exclude and include' '
write_and_run_sub_test_lib_test run-neg-inc \
--run="!3-,5" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-neg-inc <<-\EOF
run_sub_test_lib_test git-skip-tests-several \
--run="!3-,5" &&
check_sub_test_lib_test git-skip-tests-several <<-\EOF
> ok 1 - passing test #1
> ok 2 - passing test #2
> ok 3 # skip passing test #3 (--run)
@ -602,15 +503,9 @@ test_expect_success 'subtest: --run exclude and include' '
'
test_expect_success 'subtest: --run empty selectors' '
write_and_run_sub_test_lib_test run-empty-sel \
--run="1,,3,,,5" <<-\EOF &&
for i in 1 2 3 4 5 6
do
test_expect_success "passing test #$i" "true"
done
test_done
EOF
check_sub_test_lib_test run-empty-sel <<-\EOF
run_sub_test_lib_test git-skip-tests-several \
--run="1,,3,,,5" &&
check_sub_test_lib_test git-skip-tests-several <<-\EOF
> ok 1 - passing test #1
> ok 2 # skip passing test #2 (--run)
> ok 3 - passing test #3
@ -660,12 +555,9 @@ test_expect_success 'subtest: --run keyword selection' '
'
test_expect_success 'subtest: --run invalid range end' '
write_and_run_sub_test_lib_test_err run-inv-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 \
run_sub_test_lib_test_err run-inv-range-start \
--run="1-z" &&
check_sub_test_lib_test_err run-inv-range-start \
<<-\EOF_OUT 3<<-EOF_ERR
> FATAL: Unexpected exit with code 1
EOF_OUT