[RFC PATCH 4/4] t/Makefile: run unit tests alongside shell tests
- From
Josh Steadmon <steadmon@google.com>
- Date
- Jan 16, 2024, 22:23 UTC
- Message-ID
- <c823265f0d6710f99668268ba9ae7092740efbab.1705443632.git.steadmon@google.com>
- In-Reply-To
- <cover.1705443632.git.steadmon@google.com>
From: Jeff King <peff@peff.net>
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.
NEEDS WORK: as discussed in previous commits in this series, there's a desire to avoid `prove` specifically and (IIUC) unnecessary fork()/exec()ing in general on Windows. This change adds an extra exec() for each shell and unit test execution, will that be a problem for Windows?
[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> --- t/Makefile | 2 +- t/run-test.sh | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100755 t/run-test.sh
diff --git a/t/Makefile b/t/Makefile index ad57ec0a41..0038a25e33 100644 --- a/t/Makefile +++ b/t/Makefile @@ -61,7 +61,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) $(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 index 0000000000..c29fef48dc --- /dev/null +++ b/t/run-test.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# A simple wrapper to run shell tests via TEST_SHELL_PATH, +# or exec unit tests directly. + +case "$1" in +*.sh) + exec ${TEST_SHELL_PATH:-/bin/sh} "$@" + ;; +*) + exec "$@" + ;; +esac
-- 2.43.0.381.gb435a96ce8-goog