build: refactor Makefile -ct and -prop target generation
Do not pre-generate all the -ct and -prop targets, rather generate only the one that is in the specified build target
This commit is contained in:
parent
97601171a5
commit
5c14ac2e50
34
Makefile
34
Makefile
|
@ -1,3 +1,8 @@
|
||||||
|
ifeq ($(DEBUG),1)
|
||||||
|
DEBUG_INFO = $(info $1)
|
||||||
|
else
|
||||||
|
DEBUG_INFO = @:
|
||||||
|
endif
|
||||||
REBAR = $(CURDIR)/rebar3
|
REBAR = $(CURDIR)/rebar3
|
||||||
BUILD = $(CURDIR)/build
|
BUILD = $(CURDIR)/build
|
||||||
SCRIPTS = $(CURDIR)/scripts
|
SCRIPTS = $(CURDIR)/scripts
|
||||||
|
@ -101,9 +106,13 @@ static_checks:
|
||||||
./scripts/check-i18n-style.sh
|
./scripts/check-i18n-style.sh
|
||||||
./scripts/check_missing_reboot_apps.exs
|
./scripts/check_missing_reboot_apps.exs
|
||||||
|
|
||||||
APPS=$(shell $(SCRIPTS)/find-apps.sh)
|
# Allow user-set CASES environment variable
|
||||||
|
ifneq ($(CASES),)
|
||||||
|
CASES_ARG := --case $(CASES)
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: $(APPS:%=%-ct)
|
## example:
|
||||||
|
## env SUITES=apps/appname/test/test_SUITE.erl CASES=t_foo make apps/appname-ct
|
||||||
define gen-app-ct-target
|
define gen-app-ct-target
|
||||||
$1-ct: $(REBAR) merge-config clean-test-cluster-config
|
$1-ct: $(REBAR) merge-config clean-test-cluster-config
|
||||||
$(eval SUITES := $(shell $(SCRIPTS)/find-suites.sh $1))
|
$(eval SUITES := $(shell $(SCRIPTS)/find-suites.sh $1))
|
||||||
|
@ -112,20 +121,29 @@ ifneq ($(SUITES),)
|
||||||
--readable=$(CT_READABLE) \
|
--readable=$(CT_READABLE) \
|
||||||
--name $(CT_NODE_NAME) \
|
--name $(CT_NODE_NAME) \
|
||||||
--cover_export_name $(CT_COVER_EXPORT_PREFIX)-$(subst /,-,$1) \
|
--cover_export_name $(CT_COVER_EXPORT_PREFIX)-$(subst /,-,$1) \
|
||||||
--suite $(SUITES)
|
--suite $(SUITES) \
|
||||||
|
$(CASES_ARG)
|
||||||
else
|
else
|
||||||
@echo 'No suites found for $1'
|
@echo 'No suites found for $1'
|
||||||
endif
|
endif
|
||||||
endef
|
endef
|
||||||
$(foreach app,$(APPS),$(eval $(call gen-app-ct-target,$(app))))
|
|
||||||
|
ifneq ($(filter %-ct,$(MAKECMDGOALS)),)
|
||||||
|
app_to_test := $(patsubst %-ct,%,$(filter %-ct,$(MAKECMDGOALS)))
|
||||||
|
$(call DEBUG_INFO,app_to_test $(app_to_test))
|
||||||
|
$(eval $(call gen-app-ct-target,$(app_to_test)))
|
||||||
|
endif
|
||||||
|
|
||||||
## apps/name-prop targets
|
## apps/name-prop targets
|
||||||
.PHONY: $(APPS:%=%-prop)
|
|
||||||
define gen-app-prop-target
|
define gen-app-prop-target
|
||||||
$1-prop:
|
$1-prop:
|
||||||
$(REBAR) proper -d test/props -v -m $(shell $(SCRIPTS)/find-props.sh $1)
|
$(REBAR) proper -d test/props -v -m $(shell $(SCRIPTS)/find-props.sh $1)
|
||||||
endef
|
endef
|
||||||
$(foreach app,$(APPS),$(eval $(call gen-app-prop-target,$(app))))
|
ifneq ($(filter %-prop,$(MAKECMDGOALS)),)
|
||||||
|
app_to_test := $(patsubst %-prop,%,$(filter %-prop,$(MAKECMDGOALS)))
|
||||||
|
$(call DEBUG_INFO,app_to_test $(app_to_test))
|
||||||
|
$(eval $(call gen-app-prop-target,$(app_to_test)))
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: ct-suite
|
.PHONY: ct-suite
|
||||||
ct-suite: $(REBAR) merge-config clean-test-cluster-config
|
ct-suite: $(REBAR) merge-config clean-test-cluster-config
|
||||||
|
@ -303,3 +321,7 @@ fmt: $(REBAR)
|
||||||
.PHONY: clean-test-cluster-config
|
.PHONY: clean-test-cluster-config
|
||||||
clean-test-cluster-config:
|
clean-test-cluster-config:
|
||||||
@rm -f apps/emqx_conf/data/configs/cluster.hocon || true
|
@rm -f apps/emqx_conf/data/configs/cluster.hocon || true
|
||||||
|
|
||||||
|
.PHONY: spellcheck
|
||||||
|
spellcheck:
|
||||||
|
./scripts/spellcheck/spellcheck.sh _build/docgen/$(PROFILE)/schema-en.json
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
## If EMQX_CT_SUITES is provided, it prints the variable.
|
## If EMQX_CT_SUITES or SUITES is provided, it prints the variable.
|
||||||
## Otherwise this script tries to find all test/*_SUITE.erl files of then given app,
|
## Otherwise this script tries to find all test/*_SUITE.erl files of then given app,
|
||||||
## file names are separated by comma for rebar3 ct's `--suite` option
|
## file names are separated by comma for rebar3 ct's `--suite` option
|
||||||
|
|
||||||
|
@ -12,7 +12,8 @@ set -euo pipefail
|
||||||
# ensure dir
|
# ensure dir
|
||||||
cd -P -- "$(dirname -- "$0")/.."
|
cd -P -- "$(dirname -- "$0")/.."
|
||||||
|
|
||||||
## EMQX_CT_SUITES is useful in ad-hoc runs
|
## EMQX_CT_SUITES or SUITES is useful in ad-hoc runs
|
||||||
|
EMQX_CT_SUITES="${EMQX_CT_SUITES:-${SUITES:-}}"
|
||||||
if [ -n "${EMQX_CT_SUITES:-}" ]; then
|
if [ -n "${EMQX_CT_SUITES:-}" ]; then
|
||||||
echo "${EMQX_CT_SUITES}"
|
echo "${EMQX_CT_SUITES}"
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue