From 5f862a58161282bcefc3bf125c8084ce313b13d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 15 May 2023 11:23:55 +0200 Subject: Add test for EUNIT_TEST_SPEC --- test/plugin_eunit.mk | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test') diff --git a/test/plugin_eunit.mk b/test/plugin_eunit.mk index 768358c..823f619 100644 --- a/test/plugin_eunit.mk +++ b/test/plugin_eunit.mk @@ -347,6 +347,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)" -- cgit v1.2.3