2016-11-26 00:37:43 +01:00
|
|
|
|
# Run program $1 as part of ‘make installcheck’.
|
2014-02-04 11:02:49 +01:00
|
|
|
|
define run-install-test
|
2013-12-10 15:54:34 +01:00
|
|
|
|
|
|
|
|
|
installcheck: $1
|
|
|
|
|
|
2014-02-01 12:20:06 +01:00
|
|
|
|
_installcheck-list += $1
|
2013-12-10 15:54:34 +01:00
|
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
2017-10-03 06:54:00 +02:00
|
|
|
|
# Color code from https://unix.stackexchange.com/a/10065
|
2014-02-01 15:33:27 +01:00
|
|
|
|
installcheck:
|
2017-10-03 06:54:00 +02:00
|
|
|
|
@total=0; failed=0; \
|
|
|
|
|
red=""; \
|
|
|
|
|
green=""; \
|
|
|
|
|
normal=""; \
|
|
|
|
|
if [ -t 1 ]; then \
|
|
|
|
|
ncolors="$$(tput colors)"; \
|
2017-10-06 13:04:12 +02:00
|
|
|
|
if [ -n "$$ncolors" ] && [ "$$ncolors" -ge 8 ]; then \
|
2017-10-03 06:54:00 +02:00
|
|
|
|
red="$$(tput setaf 1)"; \
|
|
|
|
|
green="$$(tput setaf 2)"; \
|
|
|
|
|
normal="$$(tput sgr0)"; \
|
|
|
|
|
fi; \
|
|
|
|
|
fi; \
|
|
|
|
|
for i in $(_installcheck-list); do \
|
2013-12-10 15:54:34 +01:00
|
|
|
|
total=$$((total + 1)); \
|
2017-10-06 13:04:12 +02:00
|
|
|
|
printf "running test $$i..."; \
|
2017-10-03 06:54:00 +02:00
|
|
|
|
log="$$(cd $$(dirname $$i) && $(tests-environment) $$(basename $$i) 2>&1)"; \
|
2017-10-06 13:04:12 +02:00
|
|
|
|
if [ $$? -eq 0 ]; then \
|
2017-10-03 06:54:00 +02:00
|
|
|
|
echo "[$${green}PASS$$normal]"; \
|
2013-12-10 15:54:34 +01:00
|
|
|
|
else \
|
2017-10-03 06:54:00 +02:00
|
|
|
|
echo "[$${red}FAIL$$normal]"; \
|
|
|
|
|
echo "$$log" | sed 's/^/ /'; \
|
2013-12-10 15:54:34 +01:00
|
|
|
|
failed=$$((failed + 1)); \
|
|
|
|
|
fi; \
|
|
|
|
|
done; \
|
|
|
|
|
if [ "$$failed" != 0 ]; then \
|
2017-10-03 06:54:00 +02:00
|
|
|
|
echo "$${red}$$failed out of $$total tests failed $$normal"; \
|
2013-12-10 15:54:34 +01:00
|
|
|
|
exit 1; \
|
2017-10-03 06:54:00 +02:00
|
|
|
|
else \
|
|
|
|
|
echo "$${green}All tests succeeded"; \
|
2013-12-10 15:54:34 +01:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
.PHONY: check installcheck
|