aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2023-05-15 11:23:55 +0200
committerLoïc Hoguin <[email protected]>2023-05-15 11:23:55 +0200
commit5f862a58161282bcefc3bf125c8084ce313b13d2 (patch)
tree22603d2b94ea2f94edf1f2c1750dfd665f09feb8 /test
parent2287a1d78feab5b37ada300a56ba7b2e43ad2533 (diff)
downloaderlang.mk-5f862a58161282bcefc3bf125c8084ce313b13d2.tar.gz
erlang.mk-5f862a58161282bcefc3bf125c8084ce313b13d2.tar.bz2
erlang.mk-5f862a58161282bcefc3bf125c8084ce313b13d2.zip
Add test for EUNIT_TEST_SPEC
Diffstat (limited to 'test')
-rw-r--r--test/plugin_eunit.mk21
1 files changed, 21 insertions, 0 deletions
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)"