From b0902f35daac6cce48b76dde5940a293d5cb82b7 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Fri, 13 Nov 2020 17:35:50 -0800 Subject: [PATCH] Add a "generate-testcases" target to make -C tests Make ktest regeneration use a little bit more of Make's smarts. Fixed #973 --- testing/makefiles/testcase.mk | 5 +++-- tests/Makefile | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/testing/makefiles/testcase.mk b/testing/makefiles/testcase.mk index c926e1e0..f28aff9f 100644 --- a/testing/makefiles/testcase.mk +++ b/testing/makefiles/testcase.mk @@ -22,6 +22,7 @@ TEST_FILES=$(wildcard $(SRC_DIR)/*.cpp) # and add it to the list of possible test files ifneq (,$(wildcard test.ktest)) +HAS_KTEST_FILE=1 ifeq (,$(findstring $(SRC_DIR)/generated-testcase.cpp, $(TEST_FILES))) TEST_FILES += $(SRC_DIR)/generated-testcase.cpp endif @@ -73,12 +74,12 @@ compile-sketch: # If we have a test.ktest file, it should be processed into a c++ testcase -generate-testcase: ${SRC_DIR}/generated-testcase.cpp +generate-testcase: $(if $(HAS_KTEST_FILE), ${SRC_DIR}/generated-testcase.cpp) ${SRC_DIR}/generated-testcase.cpp: test.ktest ifneq (,$(wildcard test.ktest)) - @echo "Compiling ktest script into ${SRC_DIR}/generated-testcase.cpp" + @echo "Compiling ${testcase} ktest script into ${SRC_DIR}/generated-testcase.cpp" install -d "${SRC_DIR}" perl ${top_dir}/testing/bin/ktest-to-cxx \ --ktest=test.ktest \ diff --git a/tests/Makefile b/tests/Makefile index ee274b80..361a98a7 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -9,6 +9,11 @@ TEST_PATH ?= tests/ TESTS ?= $(shell find ${top_dir}/${TEST_PATH} -name 'sketch.ino' -exec dirname {} \;) .PHONY: clean cmake-clean all googletest +generate-testcases: + @for test in ${TESTS}; do \ + ${MAKE} -s -f ${top_dir}/testing/makefiles/testcase.mk -C $${test} top_dir=${top_dir} testcase=$${test} generate-testcase; \ + done + all: ${TESTS} @for test in ${TESTS}; do \ ${MAKE} -s -f ${top_dir}/testing/makefiles/testcase.mk -C $${test} top_dir=${top_dir} testcase=$${test} run; \