aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authornevar <[email protected]>2017-09-07 21:52:30 +0700
committerLoïc Hoguin <[email protected]>2017-09-13 18:45:15 +0200
commit6a764de5ff077a566b7865d0a7a8f3c4c9b0c042 (patch)
treedc040ded9a96d0bb5ee969892f9a063da15d1464 /test
parentd9a9158ccbb94dbb66772a7ef437f30d3e5f652c (diff)
downloaderlang.mk-6a764de5ff077a566b7865d0a7a8f3c4c9b0c042.tar.gz
erlang.mk-6a764de5ff077a566b7865d0a7a8f3c4c9b0c042.tar.bz2
erlang.mk-6a764de5ff077a566b7865d0a7a8f3c4c9b0c042.zip
COVER_DATA_DIR for *.coverdata
Also make COVER_REPORT_DIR not override user value (if set before include erlang.mk). Use incl_app in CT cover spec.
Diffstat (limited to 'test')
-rw-r--r--test/plugin_cover.mk52
1 files changed, 51 insertions, 1 deletions
diff --git a/test/plugin_cover.mk b/test/plugin_cover.mk
index 11fec5c..905e6d2 100644
--- a/test/plugin_cover.mk
+++ b/test/plugin_cover.mk
@@ -1,6 +1,6 @@
# Common Test plugin.
-COVER_CASES = ct eunit report-and-merge
+COVER_CASES = ct custom-dir eunit report-and-merge
COVER_TARGETS = $(addprefix cover-,$(COVER_CASES))
.PHONY: cover $(COVER_TARGETS)
@@ -34,6 +34,56 @@ cover-ct: build clean
$t test ! -e $(APP)/ct.coverdata
$t test ! -e $(APP)/test/ct.cover.spec
+cover-custom-dir: build clean
+
+ $i "Bootstrap a new OTP application named $(APP)"
+ $t mkdir $(APP)/
+ $t cp ../erlang.mk $(APP)/
+ $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
+
+ $i "Set COVER_DATA_DIR in the Makefile"
+ $t perl -ni.bak -e 'print;if ($$.==1) {print "COVER_DATA_DIR = custom_dir\n"}' $(APP)/Makefile
+
+ $i "Generate a module containing EUnit tests"
+ $t printf "%s\n" \
+ "-module($(APP))." \
+ "-ifdef(TEST)." \
+ "-include_lib(\"eunit/include/eunit.hrl\")." \
+ "ok_test() -> ok." \
+ "-endif." > $(APP)/src/$(APP).erl
+
+ $i "Generate a Common Test suite"
+ $t mkdir $(APP)/test
+ $t printf "%s\n" \
+ "-module($(APP)_SUITE)." \
+ "-export([all/0, ok/1])." \
+ "all() -> [ok]." \
+ "ok(_) -> ok." > $(APP)/test/$(APP)_SUITE.erl
+
+ $i "Run Common Test with code coverage enabled"
+ $t $(MAKE) -C $(APP) ct COVER=1 $v
+
+ $i "Run EUnit with code coverage enabled"
+ $t $(MAKE) -C $(APP) eunit COVER=1 $v
+
+ $i "Check that the generated file exists"
+ $t test -f $(APP)/custom_dir/ct.coverdata
+ $t test -f $(APP)/custom_dir/eunit.coverdata
+
+ $i "Merge coverdata files into all.coverdata"
+ $t $(MAKE) -C $(APP) all.coverdata $v
+ $t test -f $(APP)/custom_dir/all.coverdata
+
+ $i "Check that the generated file is removed on clean"
+ $t $(MAKE) -C $(APP) clean $v
+ $t test ! -e $(APP)/custom_dir/eunit.coverdata
+ $t test ! -e $(APP)/custom_dir/ct.coverdata
+ $t test ! -e $(APP)/custom_dir/all.coverdata
+
+ $i "Check that the custom dir is removed on distclean"
+ $t $(MAKE) -C $(APP) distclean $v
+ $t test ! -e $(APP)/custom_dir/
+
cover-eunit: build clean
$i "Bootstrap a new OTP application named $(APP)"