aboutsummaryrefslogtreecommitdiffstats
path: root/test/plugin_eunit.mk
diff options
context:
space:
mode:
authorStanislav Ovchar <[email protected]>2017-03-15 13:02:12 +0300
committerLoïc Hoguin <[email protected]>2017-04-25 15:27:49 +0200
commit24beec0a19f9e31ff186c7dbb0f95b3675ff4384 (patch)
tree8879ddfffe423a937208db4e9f84f3c5e4e6df6a /test/plugin_eunit.mk
parent750bdd359b0db9fc665d9a371b65ec7bb5d037c7 (diff)
downloaderlang.mk-24beec0a19f9e31ff186c7dbb0f95b3675ff4384.tar.gz
erlang.mk-24beec0a19f9e31ff186c7dbb0f95b3675ff4384.tar.bz2
erlang.mk-24beec0a19f9e31ff186c7dbb0f95b3675ff4384.zip
Accumulate eunit failures in multi-apps
Diffstat (limited to 'test/plugin_eunit.mk')
-rw-r--r--test/plugin_eunit.mk65
1 files changed, 64 insertions, 1 deletions
diff --git a/test/plugin_eunit.mk b/test/plugin_eunit.mk
index ed002a5..900b45e 100644
--- a/test/plugin_eunit.mk
+++ b/test/plugin_eunit.mk
@@ -1,6 +1,6 @@
# EUnit plugin.
-EUNIT_CASES = all apps-only check erl-opts fun mod priv test-dir tests
+EUNIT_CASES = all apps-only check erl-opts fun mod priv test-dir tests multiapps-no-root-check-exit-code
EUNIT_TARGETS = $(addprefix eunit-,$(EUNIT_CASES))
.PHONY: eunit $(EUNIT_TARGETS)
@@ -79,6 +79,69 @@ eunit-apps-only: build clean
$i "Check that EUnit runs tests"
$t $(MAKE) -C $(APP) eunit | grep -q "Test passed."
+ $i "Check that EUnit runs tests"
+
+eunit-multiapps-no-root-check-exit-code: build clean
+
+ $i "Create a multi application repository with no root application"
+ $t mkdir $(APP)/
+ $t cp ../erlang.mk $(APP)/
+ $t echo "include erlang.mk" > $(APP)/Makefile
+
+ $i "Create a new application named my_app1"
+ $t $(MAKE) -C $(APP) new-app in=my_app1 $v
+
+ $i "Create a new application named my_app2"
+ $t $(MAKE) -C $(APP) new-app in=my_app2 $v
+
+ $i "Create a new library named my_lib"
+ $t $(MAKE) -C $(APP) new-lib in=my_lib $v
+
+ $i "Check that EUnit detects no tests"
+ $t $(MAKE) -C $(APP) eunit | grep -q "There were no tests to run."
+
+ $i "Generate a module containing broken EUnit tests in my_app1"
+ $t printf "%s\n" \
+ "-module(my_app1)." \
+ "-ifdef(TEST)." \
+ "-include_lib(\"eunit/include/eunit.hrl\")." \
+ "bad_test() -> ?assert(0 =:= 1)." \
+ "-endif." > $(APP)/apps/my_app1/src/my_app1.erl
+
+ $i "Generate a module containing EUnit good tests in my_app2"
+ $t printf "%s\n" \
+ "-module(my_app2)." \
+ "-ifdef(TEST)." \
+ "-include_lib(\"eunit/include/eunit.hrl\")." \
+ "ok_test() -> ok." \
+ "-endif." > $(APP)/apps/my_app2/src/my_app2.erl
+
+ $i "Generate a module containing EUnit tests in my_lib"
+ $t printf "%s\n" \
+ "-module(my_lib)." \
+ "-ifdef(TEST)." \
+ "-include_lib(\"eunit/include/eunit.hrl\")." \
+ "ok_test() -> ok." \
+ "-endif." > $(APP)/apps/my_lib/src/my_lib.erl
+
+ $i "Check exit code of EUnit for the module with broken test should be non-zero"
+ $t ( set +e; $(MAKE) -C $(APP)/apps/my_app1 eunit ; if [ $$? -ne 0 ] ; then \
+ echo "Test passed exit-code is non-zero" ; \
+ else \
+ echo "Test failed exit-code is zero" ; \
+ exit 100; \
+ fi )
+
+ $i "Check exit code of EUnit for the whole project with broken test should be non-zero"
+ $t ( set +e; $(MAKE) -C $(APP) eunit ; if [ $$? -ne 0 ] ; then \
+ echo "Test passed exit-code is non-zero" ; \
+ else \
+ echo "Test failed exit-code is zero" ; \
+ exit 100; \
+ fi )
+
+
+
eunit-check: build clean
$i "Bootstrap a new OTP application named $(APP)"