Add a "generate-testcases" target to make -C tests

Make ktest regeneration use a little bit more of Make's smarts.

Fixed #973
pull/977/head
Jesse Vincent 4 years ago
parent 51fd6be466
commit b0902f35da
No known key found for this signature in database
GPG Key ID: CC228463465E40BC

@ -22,6 +22,7 @@ TEST_FILES=$(wildcard $(SRC_DIR)/*.cpp)
# and add it to the list of possible test files # and add it to the list of possible test files
ifneq (,$(wildcard test.ktest)) ifneq (,$(wildcard test.ktest))
HAS_KTEST_FILE=1
ifeq (,$(findstring $(SRC_DIR)/generated-testcase.cpp, $(TEST_FILES))) ifeq (,$(findstring $(SRC_DIR)/generated-testcase.cpp, $(TEST_FILES)))
TEST_FILES += $(SRC_DIR)/generated-testcase.cpp TEST_FILES += $(SRC_DIR)/generated-testcase.cpp
endif endif
@ -73,12 +74,12 @@ compile-sketch:
# If we have a test.ktest file, it should be processed into a c++ testcase # 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 ${SRC_DIR}/generated-testcase.cpp: test.ktest
ifneq (,$(wildcard 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}" install -d "${SRC_DIR}"
perl ${top_dir}/testing/bin/ktest-to-cxx \ perl ${top_dir}/testing/bin/ktest-to-cxx \
--ktest=test.ktest \ --ktest=test.ktest \

@ -9,6 +9,11 @@ TEST_PATH ?= tests/
TESTS ?= $(shell find ${top_dir}/${TEST_PATH} -name 'sketch.ino' -exec dirname {} \;) TESTS ?= $(shell find ${top_dir}/${TEST_PATH} -name 'sketch.ino' -exec dirname {} \;)
.PHONY: clean cmake-clean all googletest .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} all: ${TESTS}
@for test in ${TESTS}; do \ @for test in ${TESTS}; do \
${MAKE} -s -f ${top_dir}/testing/makefiles/testcase.mk -C $${test} top_dir=${top_dir} testcase=$${test} run; \ ${MAKE} -s -f ${top_dir}/testing/makefiles/testcase.mk -C $${test} top_dir=${top_dir} testcase=$${test} run; \

Loading…
Cancel
Save