From f638c36f5c6ca817bf9cc69d54ef785d2867e5d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 25 Apr 2017 15:27:09 +0200 Subject: Improve the newly added test --- test/plugin_eunit.mk | 106 +++++++++++++++++++++++---------------------------- 1 file changed, 47 insertions(+), 59 deletions(-) (limited to 'test') diff --git a/test/plugin_eunit.mk b/test/plugin_eunit.mk index 900b45e..5fd5e77 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 multiapps-no-root-check-exit-code +EUNIT_CASES = all apps-only apps-only-error check erl-opts fun mod priv test-dir tests EUNIT_TARGETS = $(addprefix eunit-,$(EUNIT_CASES)) .PHONY: eunit $(EUNIT_TARGETS) @@ -81,66 +81,54 @@ eunit-apps-only: build clean $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-apps-only-error: 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 ! $(MAKE) -C $(APP)/apps/my_app1 eunit $v + + $i "Check exit code of EUnit for the whole project with broken test should be non-zero" + $t ! $(MAKE) -C $(APP) eunit $v eunit-check: build clean -- cgit v1.2.3