2012-10-17 13:09:16 -07:00
|
|
|
#########################################################################
|
|
|
|
# #
|
|
|
|
# OCaml #
|
|
|
|
# #
|
|
|
|
# Xavier Clerc, SED, INRIA Rocquencourt #
|
|
|
|
# #
|
|
|
|
# Copyright 2010 Institut National de Recherche en Informatique et #
|
|
|
|
# en Automatique. All rights reserved. This file is distributed #
|
|
|
|
# under the terms of the Q Public License version 1.0. #
|
|
|
|
# #
|
|
|
|
#########################################################################
|
|
|
|
|
2013-12-05 02:15:29 -08:00
|
|
|
BASEDIR := $(shell pwd)
|
2014-04-12 03:17:02 -07:00
|
|
|
NO_PRINT=`$(MAKE) empty --no-print-directory >/dev/null 2>&1 \
|
|
|
|
&& echo --no-print-directory`
|
2013-05-07 02:39:38 -07:00
|
|
|
|
|
|
|
FIND=find
|
|
|
|
include ../config/Makefile
|
2010-01-25 05:47:28 -08:00
|
|
|
|
2013-05-14 10:05:21 -07:00
|
|
|
.PHONY: default
|
2010-01-25 05:47:28 -08:00
|
|
|
default:
|
|
|
|
@echo "Available targets:"
|
2013-05-15 00:43:59 -07:00
|
|
|
@echo " all launch all tests"
|
2016-01-06 11:55:44 -08:00
|
|
|
@echo " all-foo launch all tests beginning with foo"
|
2016-02-01 06:52:35 -08:00
|
|
|
@echo " parallel launch all tests using GNU parallel"
|
|
|
|
@echo " parallel-foo launch all tests beginning with foo using GNU parallel"
|
2014-04-12 03:17:02 -07:00
|
|
|
@echo " list FILE=f launch the tests listed in f (one per line)"
|
2013-05-15 00:43:59 -07:00
|
|
|
@echo " one DIR=p launch the tests located in path p"
|
2014-04-12 03:17:02 -07:00
|
|
|
@echo " promote DIR=p promote the reference files for the tests in p"
|
2013-05-14 10:05:21 -07:00
|
|
|
@echo " lib build library modules"
|
|
|
|
@echo " clean delete generated files"
|
2014-04-12 03:17:02 -07:00
|
|
|
@echo " report print the report for the last execution"
|
2016-01-06 11:55:44 -08:00
|
|
|
@echo
|
2016-02-01 06:52:35 -08:00
|
|
|
@echo "all*, parallel* and list can automatically re-run failed test directories if"
|
2016-01-06 11:55:44 -08:00
|
|
|
@echo "MAX_TESTSUITE_DIR_RETRIES permits (default value = $(MAX_TESTSUITE_DIR_RETRIES))"
|
2010-01-25 05:47:28 -08:00
|
|
|
|
2013-05-14 10:05:21 -07:00
|
|
|
.PHONY: all
|
2010-06-18 02:41:15 -07:00
|
|
|
all: lib
|
2010-01-25 05:47:28 -08:00
|
|
|
@for dir in tests/*; do \
|
2010-05-19 05:32:00 -07:00
|
|
|
$(MAKE) $(NO_PRINT) exec-one DIR=$$dir; \
|
2010-01-25 05:47:28 -08:00
|
|
|
done 2>&1 | tee _log
|
2016-01-06 11:55:44 -08:00
|
|
|
@$(MAKE) $(NO_PRINT) retries
|
2010-01-25 05:47:28 -08:00
|
|
|
@$(MAKE) report
|
|
|
|
|
2016-01-06 11:55:44 -08:00
|
|
|
.PHONY: all-%
|
|
|
|
all-%: lib
|
|
|
|
@for dir in tests/$**; do \
|
2015-10-25 09:24:49 -07:00
|
|
|
$(MAKE) $(NO_PRINT) exec-one DIR=$$dir; \
|
|
|
|
done 2>&1 | tee _log
|
2016-01-06 11:55:44 -08:00
|
|
|
@$(MAKE) $(NO_PRINT) retries
|
2015-10-25 09:24:49 -07:00
|
|
|
@$(MAKE) report
|
|
|
|
|
2016-02-01 06:52:35 -08:00
|
|
|
# The targets below use GNU parallel to paralellize tests
|
|
|
|
# 'make all' and 'make parallel' should be equivalent
|
|
|
|
#
|
|
|
|
# parallel uses specific logic to make sure the output of the commands
|
|
|
|
# run in parallel are not mangled. By default, it will reproduce
|
|
|
|
# the output of each completed command atomically, in order of completion.
|
|
|
|
#
|
|
|
|
# With the --keep-order option, we ask it to save the completed output
|
|
|
|
# and replay them in invocation order instead. In theory this costs
|
|
|
|
# a tiny bit of performance, but I could not measure any difference.
|
|
|
|
# In theory again, the reporting logic works fine with test outputs
|
|
|
|
# coming in in arbitrary order (so we should not need --keep-order),
|
|
|
|
# but keeping the output deterministic is guaranteed to make
|
|
|
|
# someone's life easier at least once in the future.
|
|
|
|
#
|
|
|
|
# Finally, note that the command we run has a 2>&1 redirection, as
|
|
|
|
# in the other make targets. If we removed the quoting around
|
|
|
|
# "$(MAKE) ... 2>&1", the rediction would apply to the complete output
|
|
|
|
# of parallel, and have a slightly different behavior: by default parallel
|
|
|
|
# cleanly separates the stdout and stderr output of each completed command,
|
|
|
|
# printing stderr first then stdout second (for each command).
|
|
|
|
# I chose to keep the previous behavior exactly unchanged,
|
|
|
|
# but the demangling separation is arguably nicer behavior that we might
|
|
|
|
# want to implement at the exec-one level to also have it in the 'all' target.
|
|
|
|
.PHONY: parallel-%
|
|
|
|
parallel-%: lib
|
|
|
|
@echo | parallel >/dev/null 2>/dev/null \
|
|
|
|
|| (echo "Unable to run the GNU parallel tool;";\
|
|
|
|
echo "You should install it before using the parallel* targets.";\
|
|
|
|
exit 1)
|
|
|
|
@echo | parallel --gnu --no-notice >/dev/null 2>/dev/null \
|
|
|
|
|| (echo "Your 'parallel' tool seems incompatible with GNU parallel;";\
|
|
|
|
echo "This target requires GNU parallel.";\
|
|
|
|
exit 1)
|
|
|
|
@for dir in tests/$**; do echo $$dir; done \
|
|
|
|
| parallel --gnu --no-notice --keep-order \
|
|
|
|
"$(MAKE) $(NO_PRINT) exec-one DIR={} 2>&1" \
|
|
|
|
| tee _log
|
|
|
|
@$(MAKE) $(NO_PRINT) retries
|
|
|
|
@$(MAKE) report
|
|
|
|
|
|
|
|
.PHONY: parallel
|
|
|
|
parallel: parallel-*
|
|
|
|
|
2013-05-14 10:05:21 -07:00
|
|
|
.PHONY: list
|
2010-06-18 02:41:15 -07:00
|
|
|
list: lib
|
2013-05-07 02:39:38 -07:00
|
|
|
@if [ -z "$(FILE)" ]; \
|
|
|
|
then echo "No value set for variable 'FILE'."; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
2010-01-25 05:47:28 -08:00
|
|
|
@while read LINE; do \
|
2010-05-19 05:32:00 -07:00
|
|
|
$(MAKE) $(NO_PRINT) exec-one DIR=$$LINE; \
|
2013-05-07 02:39:38 -07:00
|
|
|
done <$(FILE) 2>&1 | tee _log
|
2016-01-06 11:55:44 -08:00
|
|
|
@$(MAKE) $(NO_PRINT) retries
|
2010-01-25 05:47:28 -08:00
|
|
|
@$(MAKE) report
|
|
|
|
|
2013-05-14 10:05:21 -07:00
|
|
|
.PHONY: one
|
2010-01-25 05:47:28 -08:00
|
|
|
one: lib
|
2013-05-07 02:39:38 -07:00
|
|
|
@if [ -z "$(DIR)" ]; then \
|
|
|
|
echo "No value set for variable 'DIR'."; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
|
|
|
@if [ ! -d $(DIR) ]; then \
|
|
|
|
echo "Directory '$(DIR)' does not exist."; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
2010-05-19 05:32:00 -07:00
|
|
|
@$(MAKE) $(NO_PRINT) exec-one DIR=$(DIR)
|
|
|
|
|
2013-05-14 10:05:21 -07:00
|
|
|
.PHONY: exec-one
|
2010-05-19 05:32:00 -07:00
|
|
|
exec-one:
|
2011-06-15 01:13:13 -07:00
|
|
|
@if [ ! -f $(DIR)/Makefile ]; then \
|
|
|
|
for dir in $(DIR)/*; do \
|
|
|
|
if [ -d $$dir ]; then \
|
|
|
|
$(MAKE) exec-one DIR=$$dir; \
|
|
|
|
fi; \
|
|
|
|
done; \
|
2013-05-29 09:45:07 -07:00
|
|
|
else \
|
2011-06-15 01:13:13 -07:00
|
|
|
echo "Running tests from '$$DIR' ..."; \
|
2013-04-29 06:01:02 -07:00
|
|
|
cd $(DIR) && \
|
|
|
|
$(MAKE) TERM=dumb BASEDIR=$(BASEDIR) || echo '=> unexpected error'; \
|
2011-06-15 01:13:13 -07:00
|
|
|
fi
|
2010-01-25 05:47:28 -08:00
|
|
|
|
2016-01-06 11:55:44 -08:00
|
|
|
.PHONY: clean-one
|
|
|
|
clean-one:
|
|
|
|
@if [ ! -f $(DIR)/Makefile ]; then \
|
|
|
|
for dir in $(DIR)/*; do \
|
|
|
|
if [ -d $$dir ]; then \
|
|
|
|
$(MAKE) clean-one DIR=$$dir; \
|
|
|
|
fi; \
|
|
|
|
done; \
|
|
|
|
else \
|
|
|
|
cd $(DIR) && $(MAKE) TERM=dumb BASEDIR=$(BASEDIR) clean; \
|
|
|
|
fi
|
|
|
|
|
2013-05-07 02:39:38 -07:00
|
|
|
.PHONY: promote
|
|
|
|
promote:
|
|
|
|
@if [ -z "$(DIR)" ]; then \
|
|
|
|
echo "No value set for variable 'DIR'."; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
|
|
|
@if [ ! -d $(DIR) ]; then \
|
|
|
|
echo "Directory '$(DIR)' does not exist."; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
|
|
|
@cd $(DIR) && $(MAKE) TERM=dumb BASEDIR=$(BASEDIR) promote
|
2011-06-15 05:14:14 -07:00
|
|
|
|
2013-05-07 02:39:38 -07:00
|
|
|
.PHONY: lib
|
|
|
|
lib:
|
|
|
|
@cd lib && $(MAKE) -s BASEDIR=$(BASEDIR)
|
2010-01-25 05:47:28 -08:00
|
|
|
|
2013-05-07 02:39:38 -07:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
@cd lib && $(MAKE) BASEDIR=$(BASEDIR) clean
|
|
|
|
@for file in `$(FIND) interactive tests -name Makefile`; do \
|
2011-06-15 01:13:13 -07:00
|
|
|
(cd `dirname $$file` && $(MAKE) BASEDIR=$(BASEDIR) clean); \
|
2010-04-08 05:44:07 -07:00
|
|
|
done
|
2010-01-25 05:47:28 -08:00
|
|
|
|
2013-05-07 02:39:38 -07:00
|
|
|
.PHONY: report
|
|
|
|
report:
|
2010-01-25 05:47:28 -08:00
|
|
|
@if [ ! -f _log ]; then echo "No '_log' file."; exit 1; fi
|
2013-04-29 06:01:02 -07:00
|
|
|
@awk -f makefiles/summarize.awk <_log
|
2010-01-25 05:47:28 -08:00
|
|
|
|
2016-01-06 11:55:44 -08:00
|
|
|
retry-list:
|
|
|
|
@while read LINE; do \
|
|
|
|
if [ -n "$$LINE" ] ; then \
|
|
|
|
echo re-ran $$LINE>>_log; \
|
|
|
|
$(MAKE) $(NO_PRINT) clean-one DIR=$$LINE; \
|
|
|
|
$(MAKE) $(NO_PRINT) exec-one DIR=$$LINE 2>&1 | tee -a _log ; \
|
|
|
|
fi \
|
|
|
|
done <_retries;
|
|
|
|
@$(MAKE) $(NO_PRINT) retries
|
|
|
|
|
|
|
|
retries:
|
|
|
|
@awk -v retries=1 -v max_retries=$(MAX_TESTSUITE_DIR_RETRIES) -f makefiles/summarize.awk <_log >_retries
|
|
|
|
@test `cat _retries | wc -l` -eq 0 || $(MAKE) $(NO_PRINT) retry-list
|
|
|
|
@rm -f _retries
|
|
|
|
|
2013-05-07 02:39:38 -07:00
|
|
|
.PHONY: empty
|
|
|
|
empty:
|