]> git.ipfire.org Git - thirdparty/git.git/commit
test-lib: bring $remove_trash out of retirement
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Mon, 10 May 2021 14:19:00 +0000 (16:19 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 May 2021 03:45:17 +0000 (12:45 +0900)
commitedc23840b0baad017d02037f0a833eaa600ee21d
tree4138285592f8e76a1656e250d42bfab60e4e56a0
parent89b43f80a514aee58b662ad606e6352e03eaeee4
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. See df4c0d1a792 (test-lib: abort when can't
remove trash directory, 2017-04-20) for the addition of that error.

So let's partially revert 06478dab4c (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 since abc5d372ec (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, see 4d0912a206 (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>
t/test-lib.sh