Skip to content

Commit cc75e4a

Browse files
peffgitster
authored andcommitted
t/Makefile: run unit tests alongside shell tests
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/[email protected]/ Signed-off-by: Jeff King <[email protected]> Signed-off-by: Josh Steadmon <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5bbc8c9 commit cc75e4a

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

ci/run-build-and-tests.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ if test -n "$run_tests"
5050
then
5151
group "Run tests" make test ||
5252
handle_failed_tests
53-
group "Run unit tests" \
54-
make DEFAULT_UNIT_TEST_TARGET=unit-tests-prove unit-tests
5553
fi
5654
check_unignored_build_artifacts
5755

t/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ failed:
6868
test -z "$$failed" || $(MAKE) $$failed
6969

7070
prove: pre-clean check-chainlint $(TEST_LINT)
71-
@echo "*** prove ***"; $(CHAINLINTSUPPRESS) $(PROVE) --exec '$(TEST_SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS)
71+
@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)
7272
$(MAKE) clean-except-prove-cache
7373

7474
$(T):

t/run-test.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
3+
# A simple wrapper to run shell tests via TEST_SHELL_PATH,
4+
# or exec unit tests directly.
5+
6+
case "$1" in
7+
*.sh)
8+
if test -z "${TEST_SHELL_PATH}"
9+
then
10+
echo >&2 "ERROR: TEST_SHELL_PATH is empty or not set"
11+
exit 1
12+
fi
13+
exec "${TEST_SHELL_PATH}" "$@"
14+
;;
15+
*)
16+
exec "$@"
17+
;;
18+
esac

0 commit comments

Comments
 (0)