From 72ce2655aa4eb6bb6a84b1bca49d1a9a7d572faa Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Mon, 12 Feb 2024 01:19:40 +0000 Subject: [PATCH] Fix unit test execution (#23048) --- Makefile | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index ab30a17f58..78d1a372bc 100644 --- a/Makefile +++ b/Makefile @@ -337,24 +337,23 @@ define BUILD_TEST endif endef +define LIST_TEST + include $(BUILDDEFS_PATH)/testlist.mk + FOUND_TESTS := $$(patsubst ./tests/%,%,$$(TEST_LIST)) + $$(info $$(FOUND_TESTS)) +endef + define PARSE_TEST TESTS := - # list of possible targets, colon-delimited, to reassign to MAKE_TARGET and remove - TARGETS := :clean: - ifneq (,$$(findstring :$$(lastword $$(subst :, ,$$(RULE))):, $$(TARGETS))) - MAKE_TARGET := $$(lastword $$(subst :, ,$$(RULE))) - TEST_SUBPATH := $$(subst $$(eval) ,/,$$(wordlist 2, $$(words $$(subst :, ,$$(RULE))), _ $$(subst :, ,$$(RULE)))) - else - MAKE_TARGET := - TEST_SUBPATH := $$(subst :,/,$$(RULE)) - endif + TEST_NAME := $$(firstword $$(subst :, ,$$(RULE))) + TEST_TARGET := $$(subst $$(TEST_NAME),,$$(subst $$(TEST_NAME):,,$$(RULE))) include $(BUILDDEFS_PATH)/testlist.mk - ifeq ($$(RULE),all) + ifeq ($$(TEST_NAME),all) MATCHED_TESTS := $$(TEST_LIST) else - MATCHED_TESTS := $$(foreach TEST, $$(TEST_LIST),$$(if $$(findstring /$$(TEST_SUBPATH)/, $$(patsubst %,%/,$$(TEST))), $$(TEST),)) + MATCHED_TESTS := $$(foreach TEST, $$(TEST_LIST),$$(if $$(findstring x$$(TEST_NAME)x, x$$(patsubst ./tests/%,%,$$(TEST)x)), $$(TEST),)) endif - $$(foreach TEST,$$(MATCHED_TESTS),$$(eval $$(call BUILD_TEST,$$(TEST),$$(MAKE_TARGET)))) + $$(foreach TEST,$$(MATCHED_TESTS),$$(eval $$(call BUILD_TEST,$$(TEST),$$(TEST_TARGET)))) endef @@ -437,6 +436,10 @@ git-submodules: git-submodule list-keyboards: $(QMK_BIN) list-keyboards --no-resolve-defaults | tr '\n' ' ' +.PHONY: list-tests +list-tests: + $(eval $(call LIST_TEST)) + .PHONY: generate-keyboards-file generate-keyboards-file: $(QMK_BIN) list-keyboards --no-resolve-defaults