Skip to content

Commit 6423c1c

Browse files
committed
Fix code coverage for ct-* targets
Thanks to David Ansari for the report.
1 parent 94718f7 commit 6423c1c

2 files changed

Lines changed: 30 additions & 3 deletions

File tree

plugins/ct.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ endif
7878
endif
7979

8080
define ct_suite_target
81-
ct-$(1): test-build
82-
$(verbose) mkdir -p $(CT_LOGS_DIR)
83-
$(gen_verbose_esc) $(CT_RUN) -sname ct_$(PROJECT) -suite $(addsuffix _SUITE,$(1)) $(CT_EXTRA) $(CT_OPTS)
81+
ct-$1: test-build
82+
$$(verbose) mkdir -p $$(CT_LOGS_DIR)
83+
$$(gen_verbose_esc) $$(CT_RUN) -sname ct_$$(PROJECT) -suite $$(addsuffix _SUITE,$1) $$(CT_EXTRA) $$(CT_OPTS)
8484
endef
8585

8686
$(foreach test,$(CT_SUITES),$(eval $(call ct_suite_target,$(test))))

test/plugin_cover.mk

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,33 @@ endif
150150
$t test -f $(APP)/logs/ct_run.*/cow_http_hd.COVER.html
151151
$t ! test -e $(APP)/logs/ct_run.*/ranch_app.COVER.html
152152

153+
cover-ct-single-suite: init
154+
155+
$i "Bootstrap a new OTP application named $(APP)"
156+
$t mkdir $(APP)/
157+
$t cp ../erlang.mk $(APP)/
158+
$t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
159+
160+
$i "Generate a Common Test suite"
161+
$t mkdir $(APP)/test
162+
$t printf "%s\n" \
163+
"-module($(APP)_SUITE)." \
164+
"-export([all/0, ok/1])." \
165+
"all() -> [ok]." \
166+
"ok(_) -> application:start($(APP))." > $(APP)/test/$(APP)_SUITE.erl
167+
168+
$i "Run Common Test against this specific test suite with code coverage enabled"
169+
$t $(MAKE) -C $(APP) ct-$(APP) COVER=1 $v
170+
171+
$i "Check that the generated files exist"
172+
$t test -f $(APP)/cover/ct.coverdata
173+
$t test -f $(APP)/test/ct.cover.spec
174+
175+
$i "Check that the generated files are removed on clean"
176+
$t $(MAKE) -C $(APP) clean $v
177+
$t test ! -e $(APP)/cover/ct.coverdata
178+
$t test ! -e $(APP)/test/ct.cover.spec
179+
153180
cover-custom-dir: init
154181

155182
$i "Bootstrap a new OTP application named $(APP)"

0 commit comments

Comments
 (0)