# Runs the cgit test suite. Every t[0-9][0-9][0-9][0-9]-*.sh script beside this # file is a self-contained test built on the test library in the bundled Git # tree, so all that is needed here is a shell to run each one under and a way # to pass extra options along. The top-level Makefile reaches this through its # test target, once cgit and the Git tree it links against have been built. .DEFAULT_GOAL := all .SUFFIXES: # Git's platform detection names a shell only for the few systems whose /bin/sh # cannot run the tests, such as SunOS and UnixWare, and cgit.conf may name one # too, so both are read before anything below uses SHELL_PATH. Elsewhere it is # the /bin/sh make runs recipes with. include ../vendor/git/config.mak.uname -include ../cgit.conf SHELL_PATH ?= $(SHELL) # Escaped for the single quotes that the recipe below puts around the path. SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) TESTS = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)) # A failing script would stop make and leave every later one unrun, so the # scripts run in a make of their own that keeps going, and the summary fails # the run once all of them have had their turn. make test rebuilds with the # flags on its own command line, so the run first names the compiler and the # flags the build used, which Git records ahead of its own -I., and any # sanitizers, which it adds after. .PHONY: all all: @sed -e 's/ -I\. .* \(-fsanitize=[^ ]*\) .*/ \1/' -e 's/ -I\. .*//' \ -e 's/^\([^:]*\): */testing cgit as built by \1 with /' \ ../vendor/git/GIT-CFLAGS @$(MAKE) -k $(TESTS) || : @'$(SHELL_PATH_SQ)' aggregate-results.sh $(TESTS) # Counts left by a script since renamed or removed would otherwise reach the # summary. The directory is made at once, as a script that stops early writes # nothing there itself. .PHONY: pre-clean pre-clean: @$(RM) -r test-results && mkdir test-results # Each test is named after a file that already exists, so without this make # would decide there is nothing to do and run none of them. The exit status # is kept for the summary, since a script can fail without a failed test. .PHONY: $(TESTS) $(TESTS): pre-clean @'$(SHELL_PATH_SQ)' $@ $(CGIT_TEST_OPTS); \ status=$$?; echo $$status >test-results/$(@:.sh=.exit); exit $$status # A script stopped by -i or --debug inside a test that takes permissions # away can leave a directory that rm cannot descend into. .PHONY: clean clean: @if test -d trash; then chmod -R u+rwx trash; fi $(RM) -r trash test-results