1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# Copyright (c) 2013-2014, Loïc Hoguin <[email protected]>
# This file is part of erlang.mk and subject to the terms of the ISC License.
.PHONY: build-ct-deps build-ct-suites tests-ct clean-ct distclean-ct
# Configuration.
CT_OPTS ?=
ifneq ($(wildcard test/),)
CT_SUITES ?= $(sort $(subst _SUITE.erl,,$(shell find test -type f -name \*_SUITE.erl -exec basename {} \;)))
else
CT_SUITES ?=
endif
TEST_ERLC_OPTS ?= +debug_info +warn_export_vars +warn_shadow_vars +warn_obsolete_guard
TEST_ERLC_OPTS += -DTEST=1 -DEXTRA=1 +'{parse_transform, eunit_autoexport}'
# Core targets.
tests:: tests-ct
clean:: clean-ct
distclean:: distclean-ct
help::
@printf "%s\n" "" \
"All your common_test suites have their associated targets." \
"A suite named http_SUITE can be ran using the ct-http target."
# Plugin-specific targets.
ALL_TEST_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(TEST_DEPS))
CT_RUN = ct_run \
-no_auto_compile \
-noshell \
-pa $(realpath ebin) $(DEPS_DIR)/*/ebin \
-dir test \
-logdir logs
$(foreach dep,$(TEST_DEPS),$(eval $(call dep_target,$(dep))))
build-ct-deps: $(ALL_TEST_DEPS_DIRS)
@for dep in $(ALL_TEST_DEPS_DIRS) ; do $(MAKE) -C $$dep; done
build-ct-suites: build-ct-deps
$(gen_verbose) erlc -v $(TEST_ERLC_OPTS) -o test/ \
$(wildcard test/*.erl test/*/*.erl) -pa ebin/
tests-ct: ERLC_OPTS = $(TEST_ERLC_OPTS)
tests-ct: clean deps app build-ct-suites
@if [ -d "test" ] ; \
then \
mkdir -p logs/ ; \
$(CT_RUN) -suite $(addsuffix _SUITE,$(CT_SUITES)) $(CT_OPTS) ; \
fi
$(gen_verbose) rm -f test/*.beam
define ct_suite_target
ct-$(1): ERLC_OPTS = $(TEST_ERLC_OPTS)
ct-$(1): clean deps app build-ct-suites
@if [ -d "test" ] ; \
then \
mkdir -p logs/ ; \
$(CT_RUN) -suite $(addsuffix _SUITE,$(1)) $(CT_OPTS) ; \
fi
$(gen_verbose) rm -f test/*.beam
endef
$(foreach test,$(CT_SUITES),$(eval $(call ct_suite_target,$(test))))
clean-ct:
$(gen_verbose) rm -rf test/*.beam
distclean-ct:
$(gen_verbose) rm -rf logs/
|