diff --git a/tests/Makefile b/tests/Makefile index e238ef2bd..aa5b7c2fd 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -25,16 +25,7 @@ help-recurse-list: @echo " which are ones that have been selected as useful tests.)" @echo "" -# To produce incremental output, invoke make as: make MPARG=-Otarget ... -# To not run in parallel, invoke make as: make MPARG=-j1 ... -ifeq (4.0,$(firstword $(sort ${MAKE_VERSION} 4.0))) - # Version 4.0 or higher - MPARG ?= -Orecurse -else - MPARG ?= -endif - -PLUME_SCRIPTS ?= ${DAIKONDIR}/.utils/plume-scripts +include $(dir $(lastword $(MAKEFILE_LIST)))Makefile.jobs all diffs: txt-diff non-txt-diff dyncomp-tests results @@ -51,12 +42,7 @@ esc jml inv txt-daikon-diff txt-esc-diff txt-jml-diff txt-csharpcontract-diff tx txt-chicory-diff everything-txt-diff stats dyncomp-diff txt-jaif-diff txt-jaif: ${MAKE} pat-daikon-tests-$@ pat-daikon-tests-%: -# Under CI, there are two CPUs, but limit to 1 to avoid out-of-memory error. - if [ -n "$("${PLUME_SCRIPTS}"/is-ci.sh)" ]; then \ - ${MAKE} -C daikon-tests --jobs=1 ${MPARG} $*; \ - else \ - ${MAKE} -C daikon-tests --jobs=4 ${MPARG} $*; \ - fi + ${MAKE} -C daikon-tests --jobs=${DAIKON_TEST_JOBS} ${MPARG} $* list-targets: ${MAKE} -C daikon-tests list-targets diff --git a/tests/Makefile.jobs b/tests/Makefile.jobs new file mode 100644 index 000000000..16e741d96 --- /dev/null +++ b/tests/Makefile.jobs @@ -0,0 +1,28 @@ +# This is a -*- makefile -*-, Emacs +# +# Settings shared by the Makefiles that drive a whole test suite: +# tests/Makefile, tests/kvasir-tests/Makefile, and tests/dyncomp-tests/Makefile. +# The including Makefile locates this file via $(lastword $(MAKEFILE_LIST)), +# so its include line must precede any other include in that Makefile. + +# To produce incremental output, invoke make as: make MPARG=-Otarget ... +# To not run in parallel, invoke make as: make MPARG=-j1 ... +ifeq (4.0,$(firstword $(sort ${MAKE_VERSION} 4.0))) + # Version 4.0 or higher + MPARG ?= -Orecurse +else + MPARG ?= +endif + +ifndef PLUME_SCRIPTS + PLUME_SCRIPTS := $(or ${DAIKONDIR},$(realpath $(dir $(lastword $(MAKEFILE_LIST)))..))/.utils/plume-scripts +endif + +# DAIKON_TEST_JOBS is the number of tests to run in parallel. +# Under CI, limit to 1 to avoid out-of-memory errors. +# To override it, set DAIKON_TEST_JOBS on the command line or in the environment. +# The default is computed only when a recipe uses it, so targets such as +# "clean" and "help" work even if plume-scripts has not been cloned. +ifeq ($(strip ${DAIKON_TEST_JOBS}),) + override DAIKON_TEST_JOBS = $(if $(wildcard ${PLUME_SCRIPTS}/is-ci.sh),$(if $(shell sh "${PLUME_SCRIPTS}/is-ci.sh"),1,4),$(error ${PLUME_SCRIPTS}/is-ci.sh not found; clone plume-scripts there, or set DAIKON_TEST_JOBS)) +endif diff --git a/tests/dyncomp-tests/Makefile b/tests/dyncomp-tests/Makefile index f3452923a..383802773 100644 --- a/tests/dyncomp-tests/Makefile +++ b/tests/dyncomp-tests/Makefile @@ -18,7 +18,7 @@ # Forked from $DAIKONDIR/tests/kvasir-tests/Makefile -PLUME_SCRIPTS ?= ${DAIKONDIR}/.utils/plume-scripts +include $(dir $(lastword $(MAKEFILE_LIST)))../Makefile.jobs default: summary @@ -64,11 +64,7 @@ update-all: .PHONY: clean-all clean-all: - if [ -n "$("${PLUME_SCRIPTS}"/is-ci.sh)" ]; then \ - ${MAKE} --jobs=1 ${MPARG} nightly-tests__clean; \ - else \ - ${MAKE} --jobs=4 ${MPARG} nightly-tests__clean; \ - fi + ${MAKE} --jobs=${DAIKON_TEST_JOBS} ${MPARG} nightly-tests__clean default-projects__%: pgbovine-tests__% diff --git a/tests/kvasir-tests/Makefile b/tests/kvasir-tests/Makefile index bff779dcc..6774e5bb3 100644 --- a/tests/kvasir-tests/Makefile +++ b/tests/kvasir-tests/Makefile @@ -13,24 +13,13 @@ # category to contain it. # -ifeq (4.0,$(firstword $(sort ${MAKE_VERSION} 4.0))) - # Version 4.0 or higher - MPARG ?= -Orecurse -else - MPARG ?= -endif - -PLUME_SCRIPTS ?= ${DAIKONDIR}/.utils/plume-scripts +include $(dir $(lastword $(MAKEFILE_LIST)))../Makefile.jobs default: summary-w-daikon .PHONY: regression-tests regression-tests: - if [ -n "$("${PLUME_SCRIPTS}"/is-ci.sh)" ]; then \ - ${MAKE} --jobs=1 ${MPARG} nightly-tests__diffs-w-daikon-if-working; \ - else \ - ${MAKE} --jobs=4 ${MPARG} nightly-tests__diffs-w-daikon-if-working; \ - fi + ${MAKE} --jobs=${DAIKON_TEST_JOBS} ${MPARG} nightly-tests__diffs-w-daikon-if-working ${MAKE} nightly-summary-only-w-daikon @${MAKE} --no-print-directory results @@ -80,11 +69,7 @@ update-all: .PHONY: clean-all clean-all: - if [ -n "$("${PLUME_SCRIPTS}"/is-ci.sh)" ]; then \ - ${MAKE} --jobs=1 ${MPARG} nightly-tests__clean; \ - else \ - ${MAKE} --jobs=4 ${MPARG} nightly-tests__clean; \ - fi + ${MAKE} --jobs=${DAIKON_TEST_JOBS} ${MPARG} nightly-tests__clean default-projects__%: pgbovine-tests__% smcc-tests__% tiny-real-tests__% tws-tests__% @