]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t/Makefile: run unit tests alongside shell tests
authorJeff King <peff@peff.net>
Mon, 6 May 2024 19:57:36 +0000 (12:57 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 6 May 2024 21:06:35 +0000 (14:06 -0700)
Add a wrapper script to allow `prove` to run both shell tests and unit
tests from a single invocation. This avoids issues around running prove
twice in CI, as discussed in [1].

Additionally, this moves the unit tests into the main dev workflow, so
that errors can be spotted more quickly. Accordingly, we remove the
separate unit tests step for Linux CI. (We leave the Windows CI
unit-test step as-is, because the sharding scheme there involves
selecting specific test files rather than running `make test`.)

[1] https://lore.kernel.org/git/pull.1613.git.1699894837844.gitgitgadget@gmail.com/

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
ci/run-build-and-tests.sh
t/Makefile
t/run-test.sh [new file with mode: 0755]

index 7a1466b8687f6b24ec370f6577c930cf86621cf8..2528f25e31d3c860d1f2dc435af320a4f1b4973c 100755 (executable)
@@ -50,8 +50,6 @@ if test -n "$run_tests"
 then
        group "Run tests" make test ||
        handle_failed_tests
-       group "Run unit tests" \
-               make DEFAULT_UNIT_TEST_TARGET=unit-tests-prove unit-tests
 fi
 check_unignored_build_artifacts
 
index 0ae04f1e42caf84481f1ec2d5a00d81c0150019e..b2eb9f770bece754e0f025651fa1865f31d6d2da 100644 (file)
@@ -68,7 +68,7 @@ failed:
        test -z "$$failed" || $(MAKE) $$failed
 
 prove: pre-clean check-chainlint $(TEST_LINT)
-       @echo "*** prove ***"; $(CHAINLINTSUPPRESS) $(PROVE) --exec '$(TEST_SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS)
+       @echo "*** prove (shell & unit tests) ***"; $(CHAINLINTSUPPRESS) TEST_SHELL_PATH='$(TEST_SHELL_PATH_SQ)' $(PROVE) --exec ./run-test.sh $(GIT_PROVE_OPTS) $(T) $(UNIT_TESTS) :: $(GIT_TEST_OPTS)
        $(MAKE) clean-except-prove-cache
 
 $(T):
diff --git a/t/run-test.sh b/t/run-test.sh
new file mode 100755 (executable)
index 0000000..13c353b
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# A simple wrapper to run shell tests via TEST_SHELL_PATH,
+# or exec unit tests directly.
+
+case "$1" in
+*.sh)
+       if test -z "${TEST_SHELL_PATH}"
+       then
+               echo >&2 "ERROR: TEST_SHELL_PATH is empty or not set"
+               exit 1
+       fi
+       exec "${TEST_SHELL_PATH}" "$@"
+       ;;
+*)
+       exec "$@"
+       ;;
+esac