diff options
Diffstat (limited to 'test/plugin_eunit.mk')
-rw-r--r-- | test/plugin_eunit.mk | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/test/plugin_eunit.mk b/test/plugin_eunit.mk index 768358c..bd1f0e0 100644 --- a/test/plugin_eunit.mk +++ b/test/plugin_eunit.mk @@ -1,10 +1,10 @@ # EUnit plugin. -EUNIT_TARGETS = $(call list_targets,eunit) +eunit_TARGETS = $(call list_targets,eunit) -.PHONY: eunit $(EUNIT_TARGETS) +.PHONY: eunit $(eunit_TARGETS) -eunit: $(EUNIT_TARGETS) +eunit: $(eunit_TARGETS) eunit-all: init @@ -235,6 +235,27 @@ eunit-check: init $i "Check that EUnit runs on 'make check'" $t $(MAKE) -C $(APP) check | grep -c "Test passed." | grep -q 1 +eunit-disable: init + + $i "Bootstrap a new OTP application named $(APP)" + $t mkdir $(APP)/ + $t cp ../erlang.mk $(APP)/ + $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v + + $i "Set EUNIT = disable in the Makefile" + $t perl -ni.bak -e 'print;if ($$.==1) {print "EUNIT = disable\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 "Check that EUnit is not run on 'make tests'" + $t $(MAKE) -C $(APP) tests | grep -c "Test passed." | grep -q 0 + eunit-erl-opts: init $i "Bootstrap a new OTP application named $(APP)" @@ -347,6 +368,27 @@ eunit-test-dir: init $i "Check that tests were both run only once" $t printf "%s\n" $(APP) $(APP)_tests | cmp $(APP)/eunit.log - +eunit-test-spec: init + + $i "Bootstrap a new OTP application named $(APP)" + $t mkdir $(APP)/ + $t cp ../erlang.mk $(APP)/ + $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v + + $i "Configure EUNIT_TEST_SPEC to run a setup function" + $t perl -ni.bak -e 'print;if ($$.==1) {print "EUNIT_TEST_SPEC = {setup, fun() -> erlang:display(\"EUNIT_TEST_SPEC\" \"-setup\") end, \$$1} \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 "Check that EUnit runs the setup function" + $t $(MAKE) -C $(APP) eunit | grep -c "EUNIT_TEST_SPEC-setup" | grep -q 1 + eunit-tests: init $i "Bootstrap a new OTP application named $(APP)" |