diff --git a/makefiles/docker.inc.mk b/makefiles/docker.inc.mk index a62113b9d1..a9aeaee14b 100644 --- a/makefiles/docker.inc.mk +++ b/makefiles/docker.inc.mk @@ -19,13 +19,20 @@ DEPS_FOR_RUNNING_DOCKER := DOCKER ?= docker # List of Docker-enabled make goals -export DOCKER_MAKECMDGOALS_POSSIBLE = \ +DOCKER_MAKECMDGOALS_POSSIBLE := \ all \ scan-build \ scan-build-analyze \ tests-% \ # -export DOCKER_MAKECMDGOALS = $(filter $(DOCKER_MAKECMDGOALS_POSSIBLE),$(MAKECMDGOALS)) + +# On native, we also can run the test in docker +ifneq (, $(filter native%,$(BOARD))) + DOCKER_MAKECMDGOALS_POSSIBLE += test +endif + +export DOCKER_MAKECMDGOALS_POSSIBLE +export DOCKER_MAKECMDGOALS := $(filter $(DOCKER_MAKECMDGOALS_POSSIBLE),$(MAKECMDGOALS)) # Docker creates the files .dockerinit and .dockerenv in the root directory of # the container, we check for the files to determine if we are inside a container. diff --git a/makefiles/tests/tests.inc.mk b/makefiles/tests/tests.inc.mk index 33b0ef1a28..5c1234c740 100644 --- a/makefiles/tests/tests.inc.mk +++ b/makefiles/tests/tests.inc.mk @@ -22,10 +22,17 @@ TEST_DEPS += $(TERMDEPS) TEST_EXECUTOR ?= TEST_EXECUTOR_FLAGS ?= +# Are tests going to be run in docker and we are not yet in docker? +ifeq (0-test,$(INSIDE_DOCKER)-$(filter test,$(DOCKER_MAKECMDGOALS))) +# Yes --> defer test execution to docker +test: ..in-docker-container +else +# No --> run test in this context test: $(TEST_DEPS) $(Q) for t in $(TESTS); do \ $(TEST_EXECUTOR) $(TEST_EXECUTOR_FLAGS) $$t || exit 1; \ done +endif test/available: ifneq (,$(TEST_ON_CI_WHITELIST))