test-lib tests: split up "write and run" into two functions
Refactor the function to write and run tests of the test-lib.sh output
into two functions.
When this was added back in 565b6fa87b (tests: refactor mechanics of
testing in a sub test-lib, 2012-12-16) there was no reason to do this,
but since we started supporting test arguments in
517cd55fd5 (test-lib: self-test that --verbose works, 2013-06-23)
we've started to write out duplicate tests simply to test different
arguments, now we'll be able to re-use them.
This change doesn't consolidate any of those tests yet, it just makes
it possible to do so. All the changes in t0000-basic.sh are a simple
search-replacement.
Since the _run_sub_test_lib_test_common() function doesn't handle
running the test anymore we can do away with the sub-shell, which was
used to scope an "unset" and "export" shell variables.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Ævar Arnfjörð Bjarmason4 years agocommitted byJunio C Hamano
@ -85,7 +85,7 @@ test_expect_success 'pretend we have a fully passing test suite' '
@@ -85,7 +85,7 @@ test_expect_success 'pretend we have a fully passing test suite' '
'
test_expect_success 'pretend we have a partially passing test suite' '
run_sub_test_lib_test_err \
write_and_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"
@ -103,7 +103,7 @@ test_expect_success 'pretend we have a partially passing test suite' '
@@ -103,7 +103,7 @@ test_expect_success 'pretend we have a partially passing test suite' '
'
test_expect_success 'pretend we have a known breakage' '
run_sub_test_lib_test failing-todo "A failing TODO test" <<-\EOF &&
write_and_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
@ -118,7 +118,7 @@ test_expect_success 'pretend we have a known breakage' '
@@ -118,7 +118,7 @@ test_expect_success 'pretend we have a known breakage' '
'
test_expect_success 'pretend we have fixed a known breakage' '
run_sub_test_lib_test passing-todo "A passing TODO test" <<-\EOF &&
write_and_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
@ -130,7 +130,7 @@ test_expect_success 'pretend we have fixed a known breakage' '
@@ -130,7 +130,7 @@ test_expect_success 'pretend we have fixed a known breakage' '
'
test_expect_success 'pretend we have fixed one of two known breakages (run in sub test-lib)' '
test_expect_failure "pretend we have a known breakage" "false"
test_expect_success "pretend we have a passing test" "true"
@ -149,7 +149,7 @@ test_expect_success 'pretend we have fixed one of two known breakages (run in su
@@ -149,7 +149,7 @@ test_expect_success 'pretend we have fixed one of two known breakages (run in su
'
test_expect_success 'pretend we have a pass, fail, and known breakage' '
run_sub_test_lib_test_err \
write_and_run_sub_test_lib_test_err \
mixed-results1 "mixed results #1" <<-\EOF &&
test_expect_success "passing test" "true"
test_expect_success "failing test" "false"
@ -168,7 +168,7 @@ test_expect_success 'pretend we have a pass, fail, and known breakage' '
@@ -168,7 +168,7 @@ test_expect_success 'pretend we have a pass, fail, and known breakage' '
'
test_expect_success 'pretend we have a mix of all possible results' '
run_sub_test_lib_test_err \
write_and_run_sub_test_lib_test_err \
mixed-results2 "mixed results #2" <<-\EOF &&
test_expect_success "passing test" "true"
test_expect_success "passing test" "true"
@ -204,7 +204,7 @@ test_expect_success 'pretend we have a mix of all possible results' '
@@ -204,7 +204,7 @@ test_expect_success 'pretend we have a mix of all possible results' '
@ -785,7 +785,7 @@ test_expect_success 'lazy prereqs do not turn off tracing' '
@@ -785,7 +785,7 @@ test_expect_success 'lazy prereqs do not turn off tracing' '
'
test_expect_success 'tests clean up after themselves' '
run_sub_test_lib_test cleanup "test with cleanup" <<-\EOF &&
write_and_run_sub_test_lib_test cleanup "test with cleanup" <<-\EOF &&
clean=no
test_expect_success "do cleanup" "
test_when_finished clean=yes
@ -805,7 +805,7 @@ test_expect_success 'tests clean up after themselves' '
@@ -805,7 +805,7 @@ test_expect_success 'tests clean up after themselves' '
'
test_expect_success 'tests clean up even on failures' '
run_sub_test_lib_test_err \
write_and_run_sub_test_lib_test_err \
failing-cleanup "Failing tests with cleanup commands" <<-\EOF &&
test_expect_success "tests clean up even after a failure" "
touch clean-after-failure &&
@ -834,7 +834,7 @@ test_expect_success 'tests clean up even on failures' '
@@ -834,7 +834,7 @@ test_expect_success 'tests clean up even on failures' '