test-lib: bring $remove_trash out of retirement
There's no point in creating a repository or directory only to decide right afterwards that we're skipping all the tests. We can save ourselves the redundant "git init" or "mkdir" and "rm -rf" in this case. We carry around the "$remove_trash" variable because if the directory is unexpectedly gone at test_done time we'll still want to hit the "trash directory already removed" error, but not if we never created the trash directory. Seedf4c0d1a79
(test-lib: abort when can't remove trash directory, 2017-04-20) for the addition of that error. So let's partially revert06478dab4c
(test-lib: retire $remove_trash variable, 2017-04-23) and move the decision about whether to skip all tests earlier. Let's also fix a bug that was with us sinceabc5d372ec
(Enable parallel tests, 2008-08-08): we would leak $remove_trash from the environment. We don't want this to error out, so let's reset it to the empty string first: remove_trash=t GIT_SKIP_TESTS=t0001 ./t0001-init.sh I tested this with --debug, see4d0912a206
(test-lib.sh: do not barf under --debug at the end of the test, 2017-04-24) for a bug we don't want to re-introduce. While I'm at it, let's move the HOME assignment to just before test_create_repo, it could be lower, but it seems better to set it before calling anything in test-lib-functions.sh Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
89b43f80a5
commit
edc23840b0
@ -1167,7 +1167,7 @@ test_done () {
|
|||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -z "$debug"
|
if test -z "$debug" && test -n "$remove_trash"
|
||||||
then
|
then
|
||||||
test -d "$TRASH_DIRECTORY" ||
|
test -d "$TRASH_DIRECTORY" ||
|
||||||
error "Tests passed but trash directory already removed before test cleanup; aborting"
|
error "Tests passed but trash directory already removed before test cleanup; aborting"
|
||||||
@ -1332,6 +1332,22 @@ then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Are we running this test at all?
|
||||||
|
remove_trash=
|
||||||
|
this_test=${0##*/}
|
||||||
|
this_test=${this_test%%-*}
|
||||||
|
if match_pattern_list "$this_test" $GIT_SKIP_TESTS
|
||||||
|
then
|
||||||
|
say_color info >&3 "skipping test $this_test altogether"
|
||||||
|
skip_all="skip all tests in $this_test"
|
||||||
|
test_done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Last-minute variable setup
|
||||||
|
HOME="$TRASH_DIRECTORY"
|
||||||
|
GNUPGHOME="$HOME/gnupg-home-not-used"
|
||||||
|
export HOME GNUPGHOME
|
||||||
|
|
||||||
# Test repository
|
# Test repository
|
||||||
rm -fr "$TRASH_DIRECTORY" || {
|
rm -fr "$TRASH_DIRECTORY" || {
|
||||||
GIT_EXIT_OK=t
|
GIT_EXIT_OK=t
|
||||||
@ -1339,10 +1355,7 @@ rm -fr "$TRASH_DIRECTORY" || {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
HOME="$TRASH_DIRECTORY"
|
remove_trash=t
|
||||||
GNUPGHOME="$HOME/gnupg-home-not-used"
|
|
||||||
export HOME GNUPGHOME
|
|
||||||
|
|
||||||
if test -z "$TEST_NO_CREATE_REPO"
|
if test -z "$TEST_NO_CREATE_REPO"
|
||||||
then
|
then
|
||||||
test_create_repo "$TRASH_DIRECTORY"
|
test_create_repo "$TRASH_DIRECTORY"
|
||||||
@ -1354,15 +1367,6 @@ fi
|
|||||||
# in subprocesses like git equals our $PWD (for pathname comparisons).
|
# in subprocesses like git equals our $PWD (for pathname comparisons).
|
||||||
cd -P "$TRASH_DIRECTORY" || exit 1
|
cd -P "$TRASH_DIRECTORY" || exit 1
|
||||||
|
|
||||||
this_test=${0##*/}
|
|
||||||
this_test=${this_test%%-*}
|
|
||||||
if match_pattern_list "$this_test" $GIT_SKIP_TESTS
|
|
||||||
then
|
|
||||||
say_color info >&3 "skipping test $this_test altogether"
|
|
||||||
skip_all="skip all tests in $this_test"
|
|
||||||
test_done
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test -n "$write_junit_xml"
|
if test -n "$write_junit_xml"
|
||||||
then
|
then
|
||||||
junit_xml_dir="$TEST_OUTPUT_DIRECTORY/out"
|
junit_xml_dir="$TEST_OUTPUT_DIRECTORY/out"
|
||||||
|
Loading…
Reference in New Issue
Block a user