Makefile 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. # Copyright (c) 2014, Viktor Söderqvist <viktor@zuiderkwast.se>
  2. # This file is part of erlang.mk and subject to the terms of the ISC License.
  3. # Tests for erlang.mk targets. If any test fails or if you run a target other
  4. # than 'all', you must probably do 'make clean' before you can test again.
  5. # Verbosity.
  6. V ?= 0
  7. # Temporary files directory.
  8. ERLANG_MK_TMP=$(CURDIR)/tmp
  9. export ERLANG_MK_TMP
  10. # Temporary application name, taken from rule name.
  11. APP = $(subst -,_,$@)
  12. APP_TO_CLEAN = $(subst -,_,$(patsubst clean-%,%,$@))
  13. # Erlang, quickly!
  14. ERL = erl +A0 -noinput -boot start_clean
  15. # t = Verbosity control for tests
  16. # v = Verbosity control for erlang.mk
  17. # i = Command to display (or suppress) info messages
  18. ifeq ($V,0)
  19. # Show info messages only
  20. t = @
  21. v = V=0 >/dev/null 2>&1
  22. i = @echo $@:
  23. else ifeq ($V,1)
  24. # Show test commands
  25. t =
  26. v = V=0 >/dev/null 2>&1
  27. i = @echo == $@:
  28. else ifeq ($V,2)
  29. # Show briefly what erlang.mk is doing
  30. t = @echo " TEST " $@;
  31. v = V=0
  32. i = @echo == $@:
  33. else
  34. # Show all commands with maximum verbosity
  35. t =
  36. v = V=1
  37. i = @echo == $@:
  38. endif
  39. .PHONY: all clean app ct eunit tests-cover docs
  40. .NOTPARALLEL:
  41. all: clean core bootstrap app ct eunit tests-cover docs pkgs
  42. $i '+---------------------+'
  43. $i '| All tests passed. |'
  44. $i '+---------------------+'
  45. clean: clean-core clean-bootstrap
  46. $t rm -rf app1 pkgs.log $(ERLANG_MK_TMP)
  47. build:
  48. $i "Generate a bleeding edge Erlang.mk"
  49. $t cd .. && $(MAKE) $v
  50. # Core.
  51. .PHONY: core clean-core
  52. core: core-upgrade
  53. clean-core: clean-core-upgrade
  54. # Core: Erlang.mk upgrade.
  55. CORE_UPGRADE_CASES = no-config custom-config renamed-config
  56. CORE_UPGRADE_TARGETS = $(addprefix core-upgrade-,$(CORE_UPGRADE_CASES))
  57. CORE_UPGRADE_CLEAN_TARGETS = $(addprefix clean-,$(CORE_UPGRADE_TARGETS))
  58. .PHONY: core-upgrade $(CORE_UPGRADE_TARGETS) $(CORE_UPGRADE_CLEAN_TARGETS)
  59. core-upgrade: $(CORE_UPGRADE_TARGETS)
  60. core-upgrade-no-config: build clean-core-upgrade-no-config
  61. $i "Bootstrap a new OTP library named $(APP)"
  62. $t mkdir $(APP)/
  63. $t cp ../erlang.mk $(APP)/
  64. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  65. $i "Append a rule to the Erlang.mk file for testing purposes"
  66. $t echo "erlang_mk_upgrade_test_rule: ; @echo FAIL" >> $(APP)/erlang.mk
  67. $i "Upgrade Erlang.mk"
  68. $t $(MAKE) -C $(APP) erlang-mk $v
  69. $i "Check that the rule is gone"
  70. $t if $(MAKE) -C $(APP) erlang_mk_upgrade_test_rule $v; then false; fi
  71. core-upgrade-custom-config: build clean-core-upgrade-custom-config
  72. $i "Bootstrap a new OTP library named $(APP)"
  73. $t mkdir $(APP)/
  74. $t cp ../erlang.mk $(APP)/
  75. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  76. $i "Create a custom build.config file without plugins"
  77. $t echo "core/*" > $(APP)/build.config
  78. $i "Upgrade Erlang.mk"
  79. $t $(MAKE) -C $(APP) erlang-mk $v
  80. $i "Check that the bootstrap plugin is gone"
  81. $t if $(MAKE) -C $(APP) list-templates $v; then false; fi
  82. core-upgrade-renamed-config: build clean-core-upgrade-renamed-config
  83. $i "Bootstrap a new OTP library named $(APP)"
  84. $t mkdir $(APP)/
  85. $t cp ../erlang.mk $(APP)/
  86. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  87. $i "Create a custom build.config file without plugins; name it my.build.config"
  88. $t echo "core/*" > $(APP)/my.build.config
  89. $i "Set ERLANG_MK_BUILD_CONFIG=my.build.config in the Makefile"
  90. $t echo "ERLANG_MK_BUILD_CONFIG = my.build.config" >> $(APP)/Makefile
  91. $i "Upgrade Erlang.mk"
  92. $t $(MAKE) -C $(APP) erlang-mk $v
  93. $i "Check that the bootstrap plugin is gone"
  94. $t if $(MAKE) -C $(APP) list-templates $v; then false; fi
  95. clean-core-upgrade: $(CORE_UPGRADE_CLEAN_TARGETS)
  96. $(CORE_UPGRADE_CLEAN_TARGETS):
  97. $t rm -rf $(APP_TO_CLEAN)/
  98. # Bootstrap plugin.
  99. BOOTSTRAP_CASES = app lib rel templates
  100. BOOTSTRAP_TARGETS = $(addprefix bootstrap-,$(BOOTSTRAP_CASES))
  101. BOOTSTRAP_CLEAN_TARGETS = $(addprefix clean-,$(BOOTSTRAP_TARGETS))
  102. .PHONY: bootstrap $(BOOTSTRAP_TARGETS) $(BOOTSTRAP_CLEAN_TARGETS)
  103. bootstrap: $(BOOTSTRAP_TARGETS)
  104. bootstrap-app: build clean-bootstrap-app
  105. $i "Bootstrap a new OTP application named $(APP)"
  106. $t mkdir $(APP)/
  107. $t cp ../erlang.mk $(APP)/
  108. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  109. $i "Check that all bootstrapped files exist"
  110. $t test -f $(APP)/Makefile
  111. $t test -f $(APP)/src/$(APP).app.src
  112. $t test -f $(APP)/src/$(APP)_app.erl
  113. $t test -f $(APP)/src/$(APP)_sup.erl
  114. $i "Build the application"
  115. $t $(MAKE) -C $(APP) $v
  116. $i "Check that all compiled files exist"
  117. $t test -f $(APP)/ebin/$(APP).app
  118. $t test -f $(APP)/ebin/$(APP)_app.beam
  119. $t test -f $(APP)/ebin/$(APP)_sup.beam
  120. $i "Check that the application was compiled correctly"
  121. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  122. ok = application:start($(APP)), \
  123. {ok, [$(APP)_app, $(APP)_sup]} = application:get_key($(APP), modules), \
  124. {module, $(APP)_app} = code:load_file($(APP)_app), \
  125. {module, $(APP)_sup} = code:load_file($(APP)_sup), \
  126. halt()"
  127. bootstrap-lib: build clean-bootstrap-lib
  128. $i "Bootstrap a new OTP library named $(APP)"
  129. $t mkdir $(APP)/
  130. $t cp ../erlang.mk $(APP)/
  131. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  132. $i "Check that all bootstrapped files exist"
  133. $t test -f $(APP)/Makefile
  134. $t test -f $(APP)/src/$(APP).app.src
  135. $i "Build the application"
  136. $t $(MAKE) -C $(APP) $v
  137. $i "Check that all compiled files exist"
  138. $t test -f $(APP)/ebin/$(APP).app
  139. $i "Check that the application was compiled correctly"
  140. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  141. ok = application:start($(APP)), \
  142. {ok, []} = application:get_key($(APP), modules), \
  143. halt()"
  144. bootstrap-rel: build clean-bootstrap-rel
  145. $i "Bootstrap a new release-enabled OTP application named $(APP)"
  146. $t mkdir $(APP)/
  147. $t cp ../erlang.mk $(APP)/
  148. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap bootstrap-rel $v
  149. $i "Check that all bootstrapped files exist"
  150. $t test -f $(APP)/Makefile
  151. $t test -f $(APP)/relx.config
  152. $t test -f $(APP)/rel/sys.config
  153. $t test -f $(APP)/rel/vm.args
  154. $t test -f $(APP)/src/$(APP).app.src
  155. $t test -f $(APP)/src/$(APP)_app.erl
  156. $t test -f $(APP)/src/$(APP)_sup.erl
  157. $i "Build the application and the release"
  158. $t $(MAKE) -C $(APP) $v
  159. $i "Check that all compiled files exist"
  160. $t test -f $(APP)/ebin/$(APP).app
  161. $t test -f $(APP)/ebin/$(APP)_app.beam
  162. $t test -f $(APP)/ebin/$(APP)_sup.beam
  163. $i "Check that the release was generated"
  164. $t test -f $(APP)/_rel/$(APP)_release/bin/$(APP)_release
  165. $i "Check that the release can be started and stopped"
  166. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release start $v
  167. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release stop $v
  168. $i "Check that there's no erl_crash.dump file"
  169. $t test ! -f $(APP)/_rel/$(APP)_release/erl_crash.dump
  170. bootstrap-templates: build clean-bootstrap-templates
  171. $i "Bootstrap a new OTP library named $(APP)"
  172. $t mkdir $(APP)/
  173. $t cp ../erlang.mk $(APP)/
  174. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  175. $i "Check that we can get the list of templates"
  176. $t test `$(MAKE) -C $(APP) --no-print-directory list-templates V=0 | wc -l` -eq 1
  177. $i "Generate one of each template"
  178. $t $(MAKE) -C $(APP) --no-print-directory new t=gen_fsm n=my_fsm
  179. $t $(MAKE) -C $(APP) --no-print-directory new t=gen_server n=my_server
  180. $t $(MAKE) -C $(APP) --no-print-directory new t=supervisor n=my_sup
  181. $t $(MAKE) -C $(APP) --no-print-directory new t=cowboy_http n=my_http
  182. $t $(MAKE) -C $(APP) --no-print-directory new t=cowboy_loop n=my_loop
  183. $t $(MAKE) -C $(APP) --no-print-directory new t=cowboy_rest n=my_rest
  184. $t $(MAKE) -C $(APP) --no-print-directory new t=cowboy_ws n=my_ws
  185. $t $(MAKE) -C $(APP) --no-print-directory new t=ranch_protocol n=my_protocol
  186. # Here we disable warnings because templates contain missing behaviors.
  187. $i "Build the application"
  188. $t $(MAKE) -C $(APP) ERLC_OPTS=+debug_info $v
  189. $i "Check that all compiled files exist"
  190. $t test -f $(APP)/ebin/$(APP).app
  191. $t test -f $(APP)/ebin/my_fsm.beam
  192. $t test -f $(APP)/ebin/my_server.beam
  193. $t test -f $(APP)/ebin/my_sup.beam
  194. $i "Check that all the modules can be loaded"
  195. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  196. ok = application:start($(APP)), \
  197. {ok, Mods = [my_fsm, my_http, my_loop, my_protocol, my_rest, my_server, my_sup, my_ws]} \
  198. = application:get_key($(APP), modules), \
  199. [{module, M} = code:load_file(M) || M <- Mods], \
  200. halt()"
  201. clean-bootstrap: $(BOOTSTRAP_CLEAN_TARGETS)
  202. $(BOOTSTRAP_CLEAN_TARGETS):
  203. $t rm -rf $(APP_TO_CLEAN)/
  204. ########################################
  205. # Legacy tests.
  206. app: app1
  207. $i "app: Testing the 'app' target."
  208. $t $(MAKE) -C app1 app $v
  209. $i "Checking the modules line in the generated .app file."
  210. $t [ `grep -E "{modules, *\['m'\]}" app1/ebin/app1.app | wc -l` -eq 1 ]
  211. $t [ -e app1/ebin/m.beam ]
  212. $i "Checking that '$(MAKE) clean-app' deletes ebin."
  213. $t $(MAKE) -C app1 clean-app $v
  214. $t [ ! -e app1/ebin ]
  215. $i "Checking that '$(MAKE) app' returns non-zero on compile errors."
  216. $t printf "%s\n" \
  217. "-module(syntax_error)." \
  218. "foo lorem_ipsum dolor sit amet." \
  219. > app1/src/syntax_error.erl
  220. $t if $(MAKE) -C app1 app $v ; then false ; fi
  221. $t rm app1/src/syntax_error.erl
  222. $i "Test 'app' passed."
  223. ct: app1
  224. $i "ct: Testing ct and related targets."
  225. $i "Setting up test suite."
  226. $t mkdir -p app1/test
  227. $t printf "%s\n" \
  228. "-module(m_SUITE)." \
  229. "-export([all/0, testcase1/1])." \
  230. "all() -> [testcase1]." \
  231. "testcase1(_) -> 2 = m:succ(1)." \
  232. > app1/test/m_SUITE.erl
  233. $t $(MAKE) -C app1 ct $v
  234. $i "Checking files created by '$(MAKE) ct'."
  235. $t [ -e app1/test/m_SUITE.beam ]
  236. $t [ -e app1/ebin/m.beam ]
  237. $t [ -e app1/logs ]
  238. $i "Checking that '$(MAKE) clean' does not delete logs."
  239. $t $(MAKE) -C app1 clean $v
  240. $t [ -e app1/logs ]
  241. $i "Testing target 'ct-mysuite' where mysuite_SUITE is a test suite."
  242. $t $(MAKE) -C app1 ct-m $v
  243. $i "Checking that '$(MAKE) ct' returns non-zero for a failing suite."
  244. $t printf "%s\n" \
  245. "-module(failing_SUITE)." \
  246. "-export([all/0, testcase1/1])." \
  247. "all() -> [testcase1]." \
  248. "testcase1(_) -> 42 = m:succ(1)." \
  249. > app1/test/failing_SUITE.erl
  250. $t if $(MAKE) -C app1 ct-failing $v ; then false ; fi
  251. $i "Checking that '$(MAKE) distclean-ct' deletes logs."
  252. $t $(MAKE) -C app1 distclean-ct $v
  253. $t [ ! -e app1/logs ]
  254. $t [ -e app1/ebin/m.beam ]
  255. $i "Cleaning up test data."
  256. $t rm -rf app1/test
  257. $i "Test 'ct' passed."
  258. eunit: app1
  259. $i "eunit: Testing the 'eunit' target."
  260. $i "Running eunit test case inside module src/t.erl"
  261. $t $(call create-module-t)
  262. $t $(MAKE) -C app1 distclean $v
  263. $t $(MAKE) -C app1 eunit $v
  264. $i "Checking that the eunit test in module t."
  265. $t echo t | cmp app1/test-eunit.log -
  266. $t rm app1/test-eunit.log
  267. $i "Running eunit tests in a separate directory."
  268. $t mkdir -p app1/eunit
  269. $t printf '%s\n' \
  270. '-module(t_tests).' \
  271. '-include_lib("eunit/include/eunit.hrl").' \
  272. 'succ_test() ->' \
  273. ' ?assertEqual(2, t:succ(1)),' \
  274. ' os:cmd("echo t_tests >> test-eunit.log").' \
  275. > app1/eunit/t_tests.erl
  276. $t printf '%s\n' \
  277. '-module(x_tests).' \
  278. '-include_lib("eunit/include/eunit.hrl").' \
  279. 'succ_test() ->' \
  280. ' ?assertEqual(2, t:succ(1)),' \
  281. ' os:cmd("echo x_tests >> test-eunit.log").' \
  282. > app1/eunit/x_tests.erl
  283. $t $(MAKE) -C app1 distclean TEST_DIR=eunit $v
  284. $t $(MAKE) -C app1 eunit TEST_DIR=eunit $v
  285. $i "Checking that '$(MAKE) eunit' didn't run the tests in t_tests twice, etc."
  286. $t printf "%s\n" t t_tests x_tests | cmp app1/test-eunit.log -
  287. $t rm app1/test-eunit.log
  288. $i "Checking that '$(MAKE) eunit' returns non-zero for a failing test."
  289. $t rm -f app1/eunit/*
  290. $t printf "%s\n" \
  291. "-module(t_tests)." \
  292. '-include_lib("eunit/include/eunit.hrl").' \
  293. "succ_test() ->" \
  294. " ?assertEqual(42, t:succ(1))." \
  295. > app1/eunit/t_tests.erl
  296. $t $(MAKE) -C app1 distclean TEST_DIR=eunit $v
  297. $t if $(MAKE) -C app1 eunit TEST_DIR=eunit $v ; then false ; fi
  298. $t rm -rf app1/eunit app1/src/t.erl app1/test-eunit.log
  299. $i "Test 'eunit' passed."
  300. # TODO: do coverage for 'tests' instead of 'eunit ct' when triq is fixed
  301. tests-cover: app1
  302. $i "tests-cover: Testing 'eunit' and 'ct' with COVER=1"
  303. $i "Setting up eunit and ct suites."
  304. $t $(call create-module-t)
  305. $t mkdir -p app1/test
  306. $t printf "%s\n" \
  307. "-module(m_SUITE)." \
  308. "-export([all/0, testcase1/1])." \
  309. "all() -> [testcase1]." \
  310. "testcase1(_) -> 2 = m:succ(1)." \
  311. > app1/test/m_SUITE.erl
  312. $i "Running tests with coverage analysis."
  313. $t $(MAKE) -C app1 eunit ct COVER=1 $v
  314. $t [ -e app1/test-eunit.log ]
  315. $t [ -e app1/eunit.coverdata ]
  316. $t [ -e app1/ct.coverdata ]
  317. $i "Generating coverage report."
  318. $t $(MAKE) -C app1 cover-report COVER=1 $v
  319. $t [ -e app1/cover/m.COVER.html ]
  320. $t [ -e app1/cover/t.COVER.html ]
  321. $t [ -e app1/cover/index.html ]
  322. $i "Checking combined coverage from eunit and ct."
  323. $t [ `grep 'Total: 100%' app1/cover/index.html | wc -l` -eq 1 ]
  324. $i "Checking that cover-report-clean removes cover report."
  325. $t $(MAKE) -C app1 cover-report-clean $v
  326. $t [ ! -e app1/cover ]
  327. $i "Checking that coverdata-clean removes cover data."
  328. $t $(MAKE) -C app1 coverdata-clean $v
  329. $t [ ! -e app1/eunit.coverdata ]
  330. @# clean up
  331. $t rm -rf app1/src/t.erl app1/test app1/test-eunit.log
  332. $t $(MAKE) -C app1 clean $v
  333. $i "Test 'tests-cover' passed."
  334. docs: app1
  335. $i "docs: Testing EDoc including DOC_DEPS."
  336. $t printf "%s\n" \
  337. "PROJECT = app1" \
  338. "DOC_DEPS = edown" \
  339. "dep_edown = git https://github.com/uwiger/edown.git 0.7" \
  340. "EDOC_OPTS = {doclet, edown_doclet}" \
  341. "include erlang.mk" \
  342. "distclean:: distclean-doc-md" \
  343. "distclean-doc-md:" \
  344. " rm -rf doc/*.md" \
  345. > app1/Makefile-doc
  346. $i "Downloading doc deps (edown) and building docs."
  347. $t $(MAKE) -C app1 -f Makefile-doc docs $v
  348. $i "Checking that '$(MAKE) docs' using edown generated a markdown file."
  349. $t [ -e app1/doc/m.md ]
  350. $i "Checking that '$(MAKE) distclean' deletes all generated doc files."
  351. $t $(MAKE) -C app1 -f Makefile-doc distclean $v
  352. $t [ "`ls app1/doc/`" = "" ]
  353. $i "Cleaning up test data."
  354. $t rm app1/Makefile-doc
  355. $i "Test 'docs' passed."
  356. define app1_setup
  357. $i "Setting up app."
  358. $t mkdir -p app1
  359. $t cd .. && $(MAKE)
  360. $t cp ../erlang.mk app1/
  361. $t $(MAKE) -C app1 -f erlang.mk bootstrap-lib
  362. $t printf "%s\n" \
  363. "-module(m)." \
  364. "-export([succ/1])." \
  365. "succ(N) -> N + 1." \
  366. > app1/src/m.erl
  367. endef
  368. define pkg_test_target
  369. pkg-$(1)-clean:
  370. $t rm -rf app1 erl_crash.dump
  371. pkg-$(1)-app1:
  372. $(call app1_setup)
  373. # Running 'make' twice to make sure it recompiles fine.
  374. pkg-$(1): pkg-$(1)-clean pkg-$(1)-app1
  375. $i
  376. $i " pkgs: Checking that '$(1)' builds correctly"
  377. $i
  378. $t printf "%s\n" \
  379. "PROJECT = app1" \
  380. "DEPS = $(1)" \
  381. "include erlang.mk" \
  382. > app1/Makefile
  383. $t \
  384. if [ "$(1)" = "amqp_client" ]; then \
  385. $(MAKE) -C app1 RABBITMQ_CLIENT_PATCH=1; \
  386. elif [ "$(1)" = "rabbit" ]; then \
  387. $(MAKE) -C app1 RABBITMQ_SERVER_PATCH=1; \
  388. else \
  389. $(MAKE) -C app1; \
  390. fi; \
  391. if [ $$$$? -ne 0 ]; then \
  392. echo "$(1): make error" >> pkgs.log; \
  393. else \
  394. $(MAKE) -C app1; if [ $$$$? -ne 0 ]; then \
  395. echo "$(1): re-make error" >> pkgs.log; \
  396. else \
  397. find . -type f -name erl_crash.dump; if [ $$$$? -ne 0 ]; then \
  398. echo "$(1): erl_crash.dump found" >> pkgs.log; \
  399. else \
  400. erl +A0 -noinput -boot start_clean -pa app1/deps/*/ebin -eval " \
  401. Apps = [list_to_atom(App) || \"app1/deps/\" ++ App \
  402. <- filelib:wildcard(\"app1/deps/*\")], \
  403. [begin \
  404. io:format(\"Loading application ~p~n\", [App]), \
  405. case application:load(App) of \
  406. {error, _} -> ok; \
  407. ok -> \
  408. {ok, Mods} = application:get_key(App, modules), \
  409. [try io:format(\" Loading module ~p~n\", [Mod]), \
  410. {module, Mod} = code:load_file(Mod) \
  411. catch C:R -> timer:sleep(500), erlang:C(R) \
  412. end || Mod <- Mods] \
  413. end \
  414. end || App <- Apps], \
  415. halt()."; if [ $$$$? -ne 0 ]; then \
  416. echo "$(1): load error" >> pkgs.log; \
  417. fi \
  418. fi \
  419. fi \
  420. fi
  421. endef
  422. PACKAGES = $(foreach pkg,$(sort $(wildcard ../index/*.mk)),$(notdir $(basename $(pkg))))
  423. $(foreach pkg,$(PACKAGES),$(eval $(call pkg_test_target,$(pkg))))
  424. pkgs: $(addprefix pkg-,$(PACKAGES))
  425. @if [ -f pkgs.log ]; then \
  426. echo "+-------------------------------+"; \
  427. echo "| ERRORS WHILE TESTING PACKAGES |"; \
  428. echo "+-------------------------------+"; \
  429. cat pkgs.log; \
  430. exit 33; \
  431. fi
  432. # Test application used for testing.
  433. app1:
  434. $(call app1_setup)
  435. # Extra module in app1 used for testing eunit
  436. define create-module-t
  437. printf '%s\n' \
  438. '-module(t).' \
  439. '-export([succ/1]).' \
  440. 'succ(N) -> N + 1.' \
  441. '-ifdef(TEST).' \
  442. '-include_lib("eunit/include/eunit.hrl").' \
  443. 'succ_test() ->' \
  444. ' ?assertEqual(2, succ(1)),' \
  445. ' os:cmd("echo t >> test-eunit.log").' \
  446. '-endif.' \
  447. > app1/src/t.erl
  448. endef