--- v4
+++ v1
@@ -12,69 +12,57 @@
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>
---
- t/lib-subtest.sh | 42 +++++++++++++++++++--------
+ t/lib-subtest.sh | 39 +++++++++++++++++++------
t/t0000-basic.sh | 74 ++++++++++++++++++++++++------------------------
- 2 files changed, 67 insertions(+), 49 deletions(-)
+ 2 files changed, 67 insertions(+), 46 deletions(-)
diff --git a/t/lib-subtest.sh b/t/lib-subtest.sh
-index 3cfe09911a2..21fa570d0b2 100644
+index 0c613e00da3..0ece41c0e5f 100644
--- a/t/lib-subtest.sh
+++ b/t/lib-subtest.sh
-@@ -1,3 +1,19 @@
+@@ -1,13 +1,7 @@
+-_run_sub_test_lib_test_common () {
+- neg="$1" name="$2" descr="$3" # stdin is the body of the test code
+- shift 3
+write_sub_test_lib_test () {
+ name="$1" descr="$2" # stdin is the body of the test code
-+ mkdir "$name" &&
-+ write_script "$name/$name.sh" "$TEST_SHELL_PATH" <<-EOF &&
-+ test_description='$descr (run in sub test-lib)
-+
-+ This is run in a sub test-lib so that we do not get incorrect
-+ passing metrics
-+ '
-+
-+ # Point to the t/test-lib.sh, which isn't in ../ as usual
-+ . "\$TEST_DIRECTORY"/test-lib.sh
-+ EOF
-+ cat >>"$name/$name.sh"
+ mkdir "$name" &&
+ (
+- # Pretend we're not running under a test harness, whether we
+- # are or not. The test-lib output depends on the setting of
+- # this variable, so we need a stable setting under which to run
+- # the sub-test.
+- sane_unset HARNESS_ACTIVE &&
+ cd "$name" &&
+ write_script "$name.sh" "$TEST_SHELL_PATH" <<-EOF &&
+ test_description='$descr (run in sub test-lib)
+@@ -19,7 +13,22 @@ _run_sub_test_lib_test_common () {
+ # Point to the t/test-lib.sh, which isn't in ../ as usual
+ . "\$TEST_DIRECTORY"/test-lib.sh
+ EOF
+- cat >>"$name.sh" &&
++ cat >>"$name.sh"
++ )
+}
+
- _run_sub_test_lib_test_common () {
- neg="$1" name="$2" descr="$3" # stdin is the body of the test code
- shift 3
-@@ -18,25 +34,15 @@ _run_sub_test_lib_test_common () {
- esac
- done
-
-- mkdir "$name" &&
- (
++_run_sub_test_lib_test_common () {
++ neg="$1" name="$2" descr="$3" # stdin is the body of the test code
++ shift 3
++ (
+ cd "$name" &&
+
- # Pretend we're not running under a test harness, whether we
- # are or not. The test-lib output depends on the setting of
- # this variable, so we need a stable setting under which to run
- # the sub-test.
- sane_unset HARNESS_ACTIVE &&
-- cd "$name" &&
-- write_script "$name.sh" "$TEST_SHELL_PATH" <<-EOF &&
-- test_description='$descr (run in sub test-lib)
--
-- This is run in a sub test-lib so that we do not get incorrect
-- passing metrics
-- '
-
-- # Point to the t/test-lib.sh, which isn't in ../ as usual
-- . "\$TEST_DIRECTORY"/test-lib.sh
-- EOF
-- cat >>"$name.sh" &&
++ # Pretend we're not running under a test harness, whether we
++ # are or not. The test-lib output depends on the setting of
++ # this variable, so we need a stable setting under which to run
++ # the sub-test.
++ sane_unset HARNESS_ACTIVE &&
++
export TEST_DIRECTORY &&
- # The child test re-sources GIT-BUILD-OPTIONS and may thus
- # override the test output directory. We thus pass it as an
-@@ -55,6 +61,18 @@ _run_sub_test_lib_test_common () {
+ TEST_OUTPUT_DIRECTORY=$(pwd) &&
+ export TEST_OUTPUT_DIRECTORY &&
+@@ -33,6 +42,18 @@ _run_sub_test_lib_test_common () {
)
}
@@ -94,7 +82,7 @@
_run_sub_test_lib_test_common '' "$@"
}
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
-index a3865dd77ba..a7c5aaacab6 100755
+index 72809477645..7f6714a5fc5 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -68,7 +68,7 @@ test_expect_success 'success is reported like this' '
@@ -178,51 +166,51 @@
t2345-verbose-only-2 "test verbose-only=2" \
--verbose-only=2 <<-\EOF &&
test_expect_success "passing test" true
-@@ -255,7 +255,7 @@ test_expect_success 'test --verbose-only' '
-
+@@ -256,7 +256,7 @@ test_expect_success 'test --verbose-only' '
test_expect_success 'GIT_SKIP_TESTS' '
(
+ GIT_SKIP_TESTS="git.2" && export GIT_SKIP_TESTS &&
- run_sub_test_lib_test git-skip-tests-basic \
+ write_and_run_sub_test_lib_test git-skip-tests-basic \
- "GIT_SKIP_TESTS" \
- --skip="git.2" <<-\EOF &&
+ "GIT_SKIP_TESTS" <<-\EOF &&
for i in 1 2 3
-@@ -276,7 +276,7 @@ test_expect_success 'GIT_SKIP_TESTS' '
-
+ do
+@@ -277,7 +277,7 @@ test_expect_success 'GIT_SKIP_TESTS' '
test_expect_success 'GIT_SKIP_TESTS several tests' '
(
+ GIT_SKIP_TESTS="git.2 git.5" && export GIT_SKIP_TESTS &&
- run_sub_test_lib_test git-skip-tests-several \
+ write_and_run_sub_test_lib_test git-skip-tests-several \
- "GIT_SKIP_TESTS several tests" \
- --skip="git.2 git.5" <<-\EOF &&
+ "GIT_SKIP_TESTS several tests" <<-\EOF &&
for i in 1 2 3 4 5 6
-@@ -300,7 +300,7 @@ test_expect_success 'GIT_SKIP_TESTS several tests' '
-
+ do
+@@ -301,7 +301,7 @@ test_expect_success 'GIT_SKIP_TESTS several tests' '
test_expect_success 'GIT_SKIP_TESTS sh pattern' '
(
+ GIT_SKIP_TESTS="git.[2-5]" && export GIT_SKIP_TESTS &&
- run_sub_test_lib_test git-skip-tests-sh-pattern \
+ write_and_run_sub_test_lib_test git-skip-tests-sh-pattern \
- "GIT_SKIP_TESTS sh pattern" \
- --skip="git.[2-5]" <<-\EOF &&
+ "GIT_SKIP_TESTS sh pattern" <<-\EOF &&
for i in 1 2 3 4 5 6
-@@ -324,7 +324,7 @@ test_expect_success 'GIT_SKIP_TESTS sh pattern' '
-
+ do
+@@ -325,7 +325,7 @@ test_expect_success 'GIT_SKIP_TESTS sh pattern' '
test_expect_success 'GIT_SKIP_TESTS entire suite' '
(
+ GIT_SKIP_TESTS="git" && export GIT_SKIP_TESTS &&
- run_sub_test_lib_test git-skip-tests-entire-suite \
+ write_and_run_sub_test_lib_test git-skip-tests-entire-suite \
- "GIT_SKIP_TESTS entire suite" \
- --skip="git" <<-\EOF &&
+ "GIT_SKIP_TESTS entire suite" <<-\EOF &&
for i in 1 2 3
-@@ -341,7 +341,7 @@ test_expect_success 'GIT_SKIP_TESTS entire suite' '
-
+ do
+@@ -342,7 +342,7 @@ test_expect_success 'GIT_SKIP_TESTS entire suite' '
test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '
(
+ GIT_SKIP_TESTS="notgit" && export GIT_SKIP_TESTS &&
- run_sub_test_lib_test git-skip-tests-unmatched-suite \
+ write_and_run_sub_test_lib_test git-skip-tests-unmatched-suite \
- "GIT_SKIP_TESTS does not skip unmatched suite" \
- --skip="notgit" <<-\EOF &&
+ "GIT_SKIP_TESTS does not skip unmatched suite" <<-\EOF &&
for i in 1 2 3
+ do
@@ -361,7 +361,7 @@ test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '
'
@@ -431,5 +419,5 @@
test_expect_success "tests clean up even after a failure" "
> ../../clean-atexit &&
--
-2.33.0.1225.g9f062250122
+2.32.0.rc3.434.gd8aed1f08a7