]> git.ipfire.org Git - thirdparty/git.git/commit
t0000: clear GIT_SKIP_TESTS before running sub-tests
authorJeff King <peff@peff.net>
Fri, 16 Jul 2021 18:43:47 +0000 (14:43 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 19 Jul 2021 20:26:00 +0000 (13:26 -0700)
commitac223c404774ff69d347118e65c91015fbbec925
tree2f86162ac5b4af5283e652c70b0193ab7f4a91cd
parentdaab8a564f8bbac55f70f8bf86c070e001a9b006
t0000: clear GIT_SKIP_TESTS before running sub-tests

In t0000, we run several fake "sub-test" suites to verify the behavior
of the test suite. But because we don't clear the parent environment
completely, the sub-tests can be fooled by variables meant for the
parent. For example:

  GIT_SKIP_TESTS=t1234 ./t0000-basic.sh

fails when a sub-test expects its fake t1234 to actually run. This
particular pattern is unlikely in practice; we're running a single
script, and there is no t1234 in the real test suite anyway (not yet, at
least). A more real-world example is:

  GIT_SKIP_TESTS=t[^0]* make test

to run only the t0* tests.

The fix is conceptually simple: we should clear the GIT_SKIP_TESTS
variable when running the sub-tests, because its contents (if any) will
be meant for the main test suite. This is easy to do centrally in our
sub-test helper.

But there's a catch: some of our tests do set GIT_SKIP_TESTS
intentionally to test the feature. We need to allow them to continue to
set it, but clear it for all the other tests. And the sub-test helper
can't tell if the GIT_SKIP_TESTS it sees is from a test or not. We can
handle this by adding a new option to the helper to let callers specify
the skip list.

I considered adding a more general "--eval" option to let callers set up
the env for the sub-test however they like. That would cover this case
and possible future ones. But the quoting gets awkward for the callers
(since we're now 2 layers deep in evals!), so I went with the simpler
more specific solution.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t0000-basic.sh