Commit 7e2b3d95 authored by Stewart Williams's avatar Stewart Williams
Browse files

bug fix: make test should exit with status code of tests, not of tee

parent dd4aaad8
Loading
Loading
Loading
Loading
Loading
+19 −11
Original line number Diff line number Diff line
# With a command like 'pytest | tee output.txt', make must launch subshells
# with '-o pipefail' otherwise the exit code is that of tee and not that of
# pytest.
SHELL=/bin/bash
.SHELLFLAGS=-o pipefail -c

all: test

test:
	cd /app && python setup.py test | tee setup_py_test.stdout
	cd /app && ./code-analysis.sh | tee code_analysis.stdout
# A temporary volume is mounted at /build when 'make test' is executing.
	# The following steps copy across useful output to this volume which can
	# then be extracted to form the CI summary for the test procedure.
# The 'if [ -d /build ]...' steps copy across useful output to this volume
# which can then be extracted to form the CI summary for the test procedure.
test:
	cd /app && ./code-analysis.sh | tee code_analysis.stdout.txt
	cd /app && python setup.py test | tee setup_py_test.stdout.txt; \
		status=$$?; \
		if [ -d /build ]; then \
		mv /app/setup_py_test.stdout /build; \
		mv /app/code_analysis.stdout /build; \
			mv /app/setup_py_test.stdout.txt /build; \
			mv /app/code_analysis.stdout.txt /build; \
			mv /app/htmlcov /build; \
			mv /app/coverage.xml /build; \
	fi;
		fi; \
		exit $$status

.PHONY: all test