1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 14:25:20 +03:00

Merge pull request #7521 from mikeller/make_tests_fast_again

Separate out target specific tests into the 'test-all' goal.
This commit is contained in:
Michael Keller 2019-02-04 17:24:23 +13:00 committed by GitHub
commit 0752b62206
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 11 deletions

View file

@ -424,10 +424,14 @@ endif
# Gather up all of the tests.
TEST_SRCS = $(sort $(wildcard $(TEST_DIR)/*.cc))
TEST_BASENAMES = $(TEST_SRCS:$(TEST_DIR)/%.cc=%)
TESTS = $(foreach test,$(TEST_BASENAMES),$(if $($(test)_EXPAND),$(foreach \
target,$(filter-out $($(test)_BLACKLIST),$(VALID_TARGETS)),$(test).$(target)),$(test)))
TESTS_REPRESENTATIVE = $(foreach test,$(TEST_BASENAMES),$(if $($(test)_EXPAND),$(test).$(word \
1,$(filter-out $($(test)_BLACKLIST),$(VALID_TARGETS))),$(test)))
TESTS_TARGET_SPECIFIC = $(foreach test,$(TEST_BASENAMES),$(if $($(test)_EXPAND),$(test)))
TESTS_TARGET_SPECIFIC_EXPANDED = $(foreach test,$(TESTS_TARGET_SPECIFIC),$(foreach \
target,$(filter-out $($(test)_BLACKLIST),$(VALID_TARGETS)),$(test).$(target)))
TESTS = $(foreach test,$(TEST_BASENAMES),$(if $($(test)_EXPAND),,$(test)))
TESTS_ALL = $(TESTS) $(TESTS_TARGET_SPECIFIC_EXPANDED)
TESTS_REPRESENTATIVE = $(TESTS) $(foreach test,$(TESTS_TARGET_SPECIFIC), \
$(test).$(word 1,$(filter-out $($(test)_BLACKLIST),$(VALID_TARGETS))))
# All Google Test headers. Usually you shouldn't change this
# definition.
@ -440,9 +444,12 @@ include ../../make/build_verbosity.mk
# House-keeping build targets.
## test : Build and run the Unit Tests (default goal)
## test : Build and run the non target specific Unit Tests (default goal)
test: $(TESTS:%=test_%)
## test-all : Build and run all Unit Tests
test-all: $(TESTS_ALL:%=test_%)
## test-representative : Build and run a representative subset of the Unit Tests (i.e. run every expanded test only for the first target)
test-representative: $(TESTS_REPRESENTATIVE:%=test_%)
@ -469,7 +476,7 @@ help what usage: Makefile
@echo "Any of the Unit Test programs can be used as goals to build:"
@$(foreach test, $(TESTS), echo " $(OBJECT_DIR)/$(test)/$(test)";)
@echo ""
@echo "Any of the Unit Test programs can be used as goals to build and run:"
@echo "Any of the Unit Test programs (except for target specific unit tests) can be used as goals to build and run:"
@$(foreach test, $(TESTS), echo " test_$(test)";)
## clean : Cleanup the UnitTest binaries.
@ -605,11 +612,19 @@ test_$1: $(OBJECT_DIR)/$1/$(basename $1)
endef
$(eval $(foreach test,$(TESTS),$(call test-specific-stuff,$(test))))
ifeq ($(MAKECMDGOALS),test-all)
$(eval $(foreach test,$(TESTS_ALL),$(call test-specific-stuff,$(test))))
else
ifeq ($(MAKECMDGOALS),test-representative)
$(eval $(foreach test,$(TESTS_REPRESENTATIVE),$(call test-specific-stuff,$(test))))
else
$(eval $(foreach test,$(TESTS),$(call test-specific-stuff,$(test))))
endif
endif
$(foreach test,$(TESTS),$(if $($(basename $(test))_SRC),,$(error \
$(foreach test,$(TESTS_ALL),$(if $($(basename $(test))_SRC),,$(error \
Test 'unit/$(basename $(test)).cc' has no '$(basename $(test))_SRC' variable defined)))
$(foreach var,$(filter-out TARGET_SRC,$(filter %_SRC,$(.VARIABLES))),$(if $(filter $(var:_SRC=)%,$(TESTS)),,$(error \
$(foreach var,$(filter-out TARGET_SRC,$(filter %_SRC,$(.VARIABLES))),$(if $(filter $(var:_SRC=)%,$(TESTS_ALL)),,$(error \
Variable '$(var)' has no 'unit/$(var:_SRC=).cc' test)))