Makefile 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828
  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. # OTP master, for downloading files for testing.
  16. OTP_MASTER = https://raw.githubusercontent.com/erlang/otp/master
  17. # t = Verbosity control for tests
  18. # v = Verbosity control for erlang.mk
  19. # i = Command to display (or suppress) info messages
  20. ifeq ($V,0)
  21. # Show info messages only
  22. t = @
  23. v = V=0 >/dev/null 2>&1
  24. i = @echo $@:
  25. else ifeq ($V,1)
  26. # Show test commands
  27. t =
  28. v = V=0 >/dev/null 2>&1
  29. i = @echo == $@:
  30. else ifeq ($V,2)
  31. # Show briefly what erlang.mk is doing
  32. t = @echo " TEST " $@;
  33. v = V=0
  34. i = @echo == $@:
  35. else
  36. # Show all commands with maximum verbosity
  37. t =
  38. v = V=1
  39. i = @echo == $@:
  40. endif
  41. .PHONY: all clean app ct eunit tests-cover docs
  42. .NOTPARALLEL:
  43. all: clean core bootstrap ct eunit tests-cover docs pkgs
  44. $i '+---------------------+'
  45. $i '| All tests passed. |'
  46. $i '+---------------------+'
  47. clean: clean-core clean-bootstrap
  48. $t rm -rf app1 pkgs.log $(ERLANG_MK_TMP)
  49. build:
  50. $i "Generate a bleeding edge Erlang.mk"
  51. $t cd .. && $(MAKE) $v
  52. # Core.
  53. .PHONY: core clean-core
  54. core: core-app core-upgrade
  55. clean-core: clean-core-app clean-core-upgrade
  56. # Core: Building applications.
  57. CORE_APP_CASES = asn1 error generate-erl generate-erl-include generate-erl-prepend help hrl hrl-recursive mib no-makedep xrl xrl-include yrl yrl-include
  58. CORE_APP_TARGETS = $(addprefix core-app-,$(CORE_APP_CASES))
  59. CORE_APP_CLEAN_TARGETS = $(addprefix clean-,$(CORE_APP_TARGETS))
  60. .PHONY: core-app $(CORE_APP_TARGETS) $(CORE_APP_CLEAN_TARGETS)
  61. core-app: $(CORE_APP_TARGETS)
  62. core-app-asn1: build clean-core-app-asn1
  63. $i "Bootstrap a new OTP library named $(APP)"
  64. $t mkdir $(APP)/
  65. $t cp ../erlang.mk $(APP)/
  66. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  67. $i "Download .asn1 files from Erlang/OTP"
  68. $t mkdir $(APP)/asn1/
  69. $t curl -s -o $(APP)/asn1/CAP.asn1 $(OTP_MASTER)/lib/asn1/test/asn1_SUITE_data/CAP.asn1
  70. $t curl -s -o $(APP)/asn1/Def.asn1 $(OTP_MASTER)/lib/asn1/test/asn1_SUITE_data/Def.asn1
  71. $i "Generate .erl files dependent from headers generated by .asn1 files"
  72. $t printf "%s\n" "-module(use_cap)." "-include(\"CAP.hrl\")." > $(APP)/src/use_cap.erl
  73. $t printf "%s\n" "-module(use_def)." "-include(\"Def.hrl\")." > $(APP)/src/use_def.erl
  74. $i "Generate an unrelated .hrl file"
  75. $t mkdir $(APP)/include/
  76. $t touch $(APP)/include/unrelated.hrl
  77. $i "Build the application"
  78. $t $(MAKE) -C $(APP) $v
  79. $i "Check that all compiled files exist"
  80. $t test -f $(APP)/$(APP).d
  81. $t test -f $(APP)/ebin/$(APP).app
  82. $t test -f $(APP)/ebin/CAP.beam
  83. $t test -f $(APP)/ebin/Def.beam
  84. $t test -f $(APP)/ebin/use_cap.beam
  85. $t test -f $(APP)/ebin/use_def.beam
  86. $t test -f $(APP)/include/CAP.asn1db
  87. $t test -f $(APP)/include/CAP.hrl
  88. $t test -f $(APP)/include/Def.asn1db
  89. $t test -f $(APP)/include/Def.hrl
  90. $t test -f $(APP)/src/CAP.erl
  91. $t test -f $(APP)/src/Def.erl
  92. $i "Check that the application was compiled correctly"
  93. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  94. ok = application:start($(APP)), \
  95. {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
  96. = application:get_key($(APP), modules), \
  97. [{module, M} = code:load_file(M) || M <- Mods], \
  98. halt()"
  99. $i "Touch one .asn1 file; check that only required files are rebuilt"
  100. # The use_cap.erl gets touched because of its dependency to CAP.hrl.
  101. $t printf "%s\n" \
  102. $(APP)/$(APP).d \
  103. $(APP)/ebin/$(APP).app \
  104. $(APP)/ebin/CAP.beam \
  105. $(APP)/ebin/use_cap.beam \
  106. $(APP)/include/CAP.asn1db \
  107. $(APP)/include/CAP.hrl \
  108. $(APP)/src/CAP.erl \
  109. $(APP)/src/use_cap.erl | sort > $(APP)/EXPECT
  110. $t touch $(APP)/asn1/CAP.asn1
  111. $t $(MAKE) -C $(APP) $v
  112. $t find $(APP) -type f -newer $(APP)/asn1/CAP.asn1 | sort | diff $(APP)/EXPECT -
  113. $t rm $(APP)/EXPECT
  114. $i "Check that the application was compiled correctly"
  115. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  116. ok = application:start($(APP)), \
  117. {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
  118. = application:get_key($(APP), modules), \
  119. [{module, M} = code:load_file(M) || M <- Mods], \
  120. halt()"
  121. $i "Clean the application"
  122. $t $(MAKE) -C $(APP) clean $v
  123. $i "Check that source files still exist"
  124. $t test -f $(APP)/Makefile
  125. $t test -f $(APP)/erlang.mk
  126. $t test -f $(APP)/asn1/CAP.asn1
  127. $t test -f $(APP)/asn1/Def.asn1
  128. $t test -f $(APP)/include/unrelated.hrl
  129. $t test -f $(APP)/src/$(APP).app.src
  130. $t test -f $(APP)/src/use_cap.erl
  131. $t test -f $(APP)/src/use_def.erl
  132. $i "Check that all build artifacts are removed, including intermediates"
  133. $t test ! -e $(APP)/$(APP).d
  134. $t test ! -e $(APP)/ebin/
  135. $t test ! -e $(APP)/include/CAP.asn1db
  136. $t test ! -e $(APP)/include/CAP.hrl
  137. $t test ! -e $(APP)/include/Def.asn1db
  138. $t test ! -e $(APP)/include/Def.hrl
  139. $t test ! -e $(APP)/src/CAP.erl
  140. $t test ! -e $(APP)/src/Def.erl
  141. $i "Build the application again"
  142. $t $(MAKE) -C $(APP) $v
  143. $i "Check that all compiled files exist"
  144. $t test -f $(APP)/$(APP).d
  145. $t test -f $(APP)/ebin/$(APP).app
  146. $t test -f $(APP)/ebin/CAP.beam
  147. $t test -f $(APP)/ebin/Def.beam
  148. $t test -f $(APP)/ebin/use_cap.beam
  149. $t test -f $(APP)/ebin/use_def.beam
  150. $t test -f $(APP)/include/CAP.asn1db
  151. $t test -f $(APP)/include/CAP.hrl
  152. $t test -f $(APP)/include/Def.asn1db
  153. $t test -f $(APP)/include/Def.hrl
  154. $t test -f $(APP)/src/CAP.erl
  155. $t test -f $(APP)/src/Def.erl
  156. $i "Check that the application was compiled correctly"
  157. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  158. ok = application:start($(APP)), \
  159. {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
  160. = application:get_key($(APP), modules), \
  161. [{module, M} = code:load_file(M) || M <- Mods], \
  162. halt()"
  163. core-app-error: build clean-core-app-error
  164. $i "Bootstrap a new OTP library named $(APP)"
  165. $t mkdir $(APP)/
  166. $t cp ../erlang.mk $(APP)/
  167. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  168. $i "Generate a bad .erl files"
  169. $t touch $(APP)/src/breaking.erl
  170. $i "Generate unrelated .erl files"
  171. $t echo "-module(boy)." > $(APP)/src/boy.erl
  172. $t echo "-module(girl)." > $(APP)/src/girl.erl
  173. $i "Check that trying to build returns non-zero"
  174. $t if $(MAKE) -C $(APP) $v; then false; fi
  175. core-app-generate-erl: build clean-core-app-generate-erl
  176. $i "Bootstrap a new OTP library named $(APP)"
  177. $t mkdir $(APP)/
  178. $t cp ../erlang.mk $(APP)/
  179. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  180. $i "Create a fake script file to be used as dependency"
  181. $t touch $(APP)/script.sh
  182. $i "Append rules to the Makefile to generate a .erl module"
  183. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  184. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@" >> $(APP)/Makefile
  185. $i "Generate unrelated .erl files"
  186. $t echo "-module(boy)." > $(APP)/src/boy.erl
  187. $t echo "-module(girl)." > $(APP)/src/girl.erl
  188. $i "Build the application"
  189. $t $(MAKE) -C $(APP) $v
  190. $i "Check that all compiled files exist"
  191. $t test -f $(APP)/$(APP).d
  192. $t test -f $(APP)/ebin/$(APP).app
  193. $t test -f $(APP)/ebin/boy.beam
  194. $t test -f $(APP)/ebin/generated.beam
  195. $t test -f $(APP)/ebin/girl.beam
  196. $t test -f $(APP)/src/generated.erl
  197. $i "Check that the application was compiled correctly"
  198. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  199. ok = application:start($(APP)), \
  200. {ok, Mods = [boy, generated, girl]} \
  201. = application:get_key($(APP), modules), \
  202. [{module, M} = code:load_file(M) || M <- Mods], \
  203. halt()"
  204. $i "Touch the script file; check that only required files are rebuilt"
  205. $t printf "%s\n" \
  206. $(APP)/$(APP).d \
  207. $(APP)/ebin/$(APP).app \
  208. $(APP)/ebin/generated.beam \
  209. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  210. $t touch $(APP)/script.sh
  211. $t $(MAKE) -C $(APP) $v
  212. $t find $(APP) -type f -newer $(APP)/script.sh | sort | diff $(APP)/EXPECT -
  213. $t rm $(APP)/EXPECT
  214. $i "Check that the application was compiled correctly"
  215. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  216. ok = application:start($(APP)), \
  217. {ok, Mods = [boy, generated, girl]} \
  218. = application:get_key($(APP), modules), \
  219. [{module, M} = code:load_file(M) || M <- Mods], \
  220. halt()"
  221. $i "Clean the application"
  222. $t $(MAKE) -C $(APP) clean $v
  223. $i "Check that source files still exist"
  224. $t test -f $(APP)/Makefile
  225. $t test -f $(APP)/erlang.mk
  226. $t test -f $(APP)/script.sh
  227. $t test -f $(APP)/src/$(APP).app.src
  228. $t test -f $(APP)/src/boy.erl
  229. $t test -f $(APP)/src/girl.erl
  230. $i "Check that the generated .erl file still exists"
  231. $t test -f $(APP)/src/generated.erl
  232. $i "Check that all build artifacts are removed"
  233. $t test ! -e $(APP)/$(APP).d
  234. $t test ! -e $(APP)/ebin/
  235. $i "Add a rule to remove the generated .erl file on clean"
  236. $t echo "clean:: ; rm src/generated.erl" >> $(APP)/Makefile
  237. $i "Clean the application again"
  238. $t $(MAKE) -C $(APP) clean $v
  239. $i "Check that the generated .erl file was removed"
  240. $t test ! -e $(APP)/src/generated.erl
  241. $i "Build the application again"
  242. $t $(MAKE) -C $(APP) $v
  243. $i "Check that all compiled files exist"
  244. $t test -f $(APP)/$(APP).d
  245. $t test -f $(APP)/ebin/$(APP).app
  246. $t test -f $(APP)/ebin/boy.beam
  247. $t test -f $(APP)/ebin/generated.beam
  248. $t test -f $(APP)/ebin/girl.beam
  249. $t test -f $(APP)/src/generated.erl
  250. $i "Check that the application was compiled correctly"
  251. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  252. ok = application:start($(APP)), \
  253. {ok, Mods = [boy, generated, girl]} \
  254. = application:get_key($(APP), modules), \
  255. [{module, M} = code:load_file(M) || M <- Mods], \
  256. halt()"
  257. core-app-generate-erl-include: build clean-core-app-generate-erl-include
  258. $i "Bootstrap a new OTP library named $(APP)"
  259. $t mkdir $(APP)/
  260. $t cp ../erlang.mk $(APP)/
  261. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  262. $i "Create a fake script file to be used as dependency"
  263. $t touch $(APP)/script.sh
  264. $i "Append rules to the Makefile to generate a .erl module"
  265. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  266. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@; echo \"-include(\\\"included.hrl\\\").\" >> \$$@" >> $(APP)/Makefile
  267. $i "Generate the .hrl file"
  268. $t mkdir $(APP)/include/
  269. $t touch $(APP)/include/included.hrl
  270. $i "Generate unrelated .erl files"
  271. $t echo "-module(boy)." > $(APP)/src/boy.erl
  272. $t echo "-module(girl)." > $(APP)/src/girl.erl
  273. $i "Build the application"
  274. $t $(MAKE) -C $(APP) $v
  275. $i "Check that all compiled files exist"
  276. $t test -f $(APP)/$(APP).d
  277. $t test -f $(APP)/ebin/$(APP).app
  278. $t test -f $(APP)/ebin/boy.beam
  279. $t test -f $(APP)/ebin/generated.beam
  280. $t test -f $(APP)/ebin/girl.beam
  281. $t test -f $(APP)/src/generated.erl
  282. $i "Check that the application was compiled correctly"
  283. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  284. ok = application:start($(APP)), \
  285. {ok, Mods = [boy, generated, girl]} \
  286. = application:get_key($(APP), modules), \
  287. [{module, M} = code:load_file(M) || M <- Mods], \
  288. halt()"
  289. $i "Touch the .hrl file; check that only required files are rebuilt"
  290. $t printf "%s\n" \
  291. $(APP)/$(APP).d \
  292. $(APP)/ebin/$(APP).app \
  293. $(APP)/ebin/generated.beam \
  294. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  295. $t touch $(APP)/include/included.hrl
  296. $t $(MAKE) -C $(APP) $v
  297. $t find $(APP) -type f -newer $(APP)/include/included.hrl | sort | diff $(APP)/EXPECT -
  298. $t rm $(APP)/EXPECT
  299. $i "Check that the application was compiled correctly"
  300. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  301. ok = application:start($(APP)), \
  302. {ok, Mods = [boy, generated, girl]} \
  303. = application:get_key($(APP), modules), \
  304. [{module, M} = code:load_file(M) || M <- Mods], \
  305. halt()"
  306. core-app-generate-erl-prepend: build clean-core-app-generate-erl-prepend
  307. $i "Bootstrap a new OTP library named $(APP)"
  308. $t mkdir $(APP)/
  309. $t cp ../erlang.mk $(APP)/
  310. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  311. $i "Create a fake script file to be used as dependency"
  312. $t touch $(APP)/script.sh
  313. $i "Generate a Makefile and prepend rules that generate a .erl module"
  314. $t echo "PROJECT = $(APP)" > $(APP)/Makefile
  315. $t echo ".DEFAULT_GOAL = all" >> $(APP)/Makefile
  316. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  317. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@" >> $(APP)/Makefile
  318. $t echo "include erlang.mk" >> $(APP)/Makefile
  319. $i "Generate unrelated .erl files"
  320. $t echo "-module(boy)." > $(APP)/src/boy.erl
  321. $t echo "-module(girl)." > $(APP)/src/girl.erl
  322. $i "Build the application"
  323. $t $(MAKE) -C $(APP) $v
  324. $i "Check that all compiled files exist"
  325. $t test -f $(APP)/$(APP).d
  326. $t test -f $(APP)/ebin/$(APP).app
  327. $t test -f $(APP)/ebin/boy.beam
  328. $t test -f $(APP)/ebin/generated.beam
  329. $t test -f $(APP)/ebin/girl.beam
  330. $t test -f $(APP)/src/generated.erl
  331. $i "Check that the application was compiled correctly"
  332. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  333. ok = application:start($(APP)), \
  334. {ok, Mods = [boy, generated, girl]} \
  335. = application:get_key($(APP), modules), \
  336. [{module, M} = code:load_file(M) || M <- Mods], \
  337. halt()"
  338. $i "Touch the script file; check that only required files are rebuilt"
  339. $t printf "%s\n" \
  340. $(APP)/$(APP).d \
  341. $(APP)/ebin/$(APP).app \
  342. $(APP)/ebin/generated.beam \
  343. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  344. $t touch $(APP)/script.sh
  345. $t $(MAKE) -C $(APP) $v
  346. $t find $(APP) -type f -newer $(APP)/script.sh | sort | diff $(APP)/EXPECT -
  347. $t rm $(APP)/EXPECT
  348. $i "Check that the application was compiled correctly"
  349. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  350. ok = application:start($(APP)), \
  351. {ok, Mods = [boy, generated, girl]} \
  352. = application:get_key($(APP), modules), \
  353. [{module, M} = code:load_file(M) || M <- Mods], \
  354. halt()"
  355. $i "Clean the application"
  356. $t $(MAKE) -C $(APP) clean $v
  357. $i "Check that source files still exist"
  358. $t test -f $(APP)/Makefile
  359. $t test -f $(APP)/erlang.mk
  360. $t test -f $(APP)/script.sh
  361. $t test -f $(APP)/src/$(APP).app.src
  362. $t test -f $(APP)/src/boy.erl
  363. $t test -f $(APP)/src/girl.erl
  364. $i "Check that the generated .erl file still exists"
  365. $t test -f $(APP)/src/generated.erl
  366. $i "Check that all build artifacts are removed"
  367. $t test ! -e $(APP)/$(APP).d
  368. $t test ! -e $(APP)/ebin/
  369. $i "Add a rule to remove the generated .erl file on clean"
  370. $t echo "clean:: ; rm src/generated.erl" >> $(APP)/Makefile
  371. $i "Clean the application again"
  372. $t $(MAKE) -C $(APP) clean $v
  373. $i "Check that the generated .erl file was removed"
  374. $t test ! -e $(APP)/src/generated.erl
  375. $i "Build the application again"
  376. $t $(MAKE) -C $(APP) $v
  377. $i "Check that all compiled files exist"
  378. $t test -f $(APP)/$(APP).d
  379. $t test -f $(APP)/ebin/$(APP).app
  380. $t test -f $(APP)/ebin/boy.beam
  381. $t test -f $(APP)/ebin/generated.beam
  382. $t test -f $(APP)/ebin/girl.beam
  383. $t test -f $(APP)/src/generated.erl
  384. $i "Check that the application was compiled correctly"
  385. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  386. ok = application:start($(APP)), \
  387. {ok, Mods = [boy, generated, girl]} \
  388. = application:get_key($(APP), modules), \
  389. [{module, M} = code:load_file(M) || M <- Mods], \
  390. halt()"
  391. core-app-help: build clean-core-app-help
  392. $i "Bootstrap a new OTP library named $(APP)"
  393. $t mkdir $(APP)/
  394. $t cp ../erlang.mk $(APP)/
  395. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  396. $i "Run 'make help' and check that it prints help"
  397. $t test -n "`$(MAKE) -C $(APP) help` | grep Usage"
  398. core-app-hrl: build clean-core-app-hrl
  399. $i "Bootstrap a new OTP library named $(APP)"
  400. $t mkdir $(APP)/
  401. $t cp ../erlang.mk $(APP)/
  402. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  403. $i "Generate .hrl files"
  404. $t mkdir $(APP)/include/
  405. $t touch $(APP)/include/blue.hrl $(APP)/include/red.hrl
  406. $i "Generate .erl files dependent from headers"
  407. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  408. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  409. $i "Build the application"
  410. $t $(MAKE) -C $(APP) $v
  411. $i "Check that all compiled files exist"
  412. $t test -f $(APP)/$(APP).d
  413. $t test -f $(APP)/ebin/$(APP).app
  414. $t test -f $(APP)/ebin/use_blue.beam
  415. $t test -f $(APP)/ebin/use_red.beam
  416. $i "Check that the application was compiled correctly"
  417. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  418. ok = application:start($(APP)), \
  419. {ok, Mods = [use_blue, use_red]} \
  420. = application:get_key($(APP), modules), \
  421. [{module, M} = code:load_file(M) || M <- Mods], \
  422. halt()"
  423. $i "Touch one .hrl file; check that only required files are rebuilt"
  424. # The use_red.erl gets touched because of its dependency to red.hrl.
  425. $t printf "%s\n" \
  426. $(APP)/$(APP).d \
  427. $(APP)/ebin/$(APP).app \
  428. $(APP)/ebin/use_red.beam \
  429. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  430. $t touch $(APP)/include/red.hrl
  431. $t $(MAKE) -C $(APP) $v
  432. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  433. $t rm $(APP)/EXPECT
  434. $i "Check that the application was compiled correctly"
  435. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  436. ok = application:start($(APP)), \
  437. {ok, Mods = [use_blue, use_red]} \
  438. = application:get_key($(APP), modules), \
  439. [{module, M} = code:load_file(M) || M <- Mods], \
  440. halt()"
  441. $i "Clean the application"
  442. $t $(MAKE) -C $(APP) clean $v
  443. $i "Check that source files still exist"
  444. $t test -f $(APP)/Makefile
  445. $t test -f $(APP)/erlang.mk
  446. $t test -f $(APP)/include/blue.hrl
  447. $t test -f $(APP)/include/red.hrl
  448. $t test -f $(APP)/src/$(APP).app.src
  449. $t test -f $(APP)/src/use_blue.erl
  450. $t test -f $(APP)/src/use_red.erl
  451. $i "Check that all build artifacts are removed"
  452. $t test ! -e $(APP)/$(APP).d
  453. $t test ! -e $(APP)/ebin/
  454. $i "Build the application again"
  455. $t $(MAKE) -C $(APP) $v
  456. $i "Check that all compiled files exist"
  457. $t test -f $(APP)/$(APP).d
  458. $t test -f $(APP)/ebin/$(APP).app
  459. $t test -f $(APP)/ebin/use_blue.beam
  460. $t test -f $(APP)/ebin/use_red.beam
  461. $i "Check that the application was compiled correctly"
  462. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  463. ok = application:start($(APP)), \
  464. {ok, Mods = [use_blue, use_red]} \
  465. = application:get_key($(APP), modules), \
  466. [{module, M} = code:load_file(M) || M <- Mods], \
  467. halt()"
  468. core-app-hrl-recursive: build clean-core-app-hrl-recursive
  469. $i "Bootstrap a new OTP library named $(APP)"
  470. $t mkdir $(APP)/
  471. $t cp ../erlang.mk $(APP)/
  472. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  473. $i "Generate .hrl files"
  474. $t mkdir $(APP)/include/
  475. $t touch $(APP)/include/blue.hrl $(APP)/include/pill.hrl
  476. $t echo "-include(\"pill.hrl\")." > $(APP)/include/red.hrl
  477. $i "Generate .erl files dependent from headers"
  478. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  479. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  480. $i "Build the application"
  481. $t $(MAKE) -C $(APP) $v
  482. $i "Check that all compiled files exist"
  483. $t test -f $(APP)/$(APP).d
  484. $t test -f $(APP)/ebin/$(APP).app
  485. $t test -f $(APP)/ebin/use_blue.beam
  486. $t test -f $(APP)/ebin/use_red.beam
  487. $i "Check that the application was compiled correctly"
  488. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  489. ok = application:start($(APP)), \
  490. {ok, Mods = [use_blue, use_red]} \
  491. = application:get_key($(APP), modules), \
  492. [{module, M} = code:load_file(M) || M <- Mods], \
  493. halt()"
  494. $i "Touch the deepest .hrl file; check that only required files are rebuilt"
  495. # The use_red.erl gets touched because of its dependency to red.hrl and pill.hrl.
  496. $t printf "%s\n" \
  497. $(APP)/$(APP).d \
  498. $(APP)/ebin/$(APP).app \
  499. $(APP)/ebin/use_red.beam \
  500. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  501. $t touch $(APP)/include/pill.hrl
  502. $t $(MAKE) -C $(APP) $v
  503. $t find $(APP) -type f -newer $(APP)/include/pill.hrl | sort | diff $(APP)/EXPECT -
  504. $t rm $(APP)/EXPECT
  505. $i "Check that the application was compiled correctly"
  506. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  507. ok = application:start($(APP)), \
  508. {ok, Mods = [use_blue, use_red]} \
  509. = application:get_key($(APP), modules), \
  510. [{module, M} = code:load_file(M) || M <- Mods], \
  511. halt()"
  512. $i "Clean the application"
  513. $t $(MAKE) -C $(APP) clean $v
  514. $i "Check that source files still exist"
  515. $t test -f $(APP)/Makefile
  516. $t test -f $(APP)/erlang.mk
  517. $t test -f $(APP)/include/blue.hrl
  518. $t test -f $(APP)/include/pill.hrl
  519. $t test -f $(APP)/include/red.hrl
  520. $t test -f $(APP)/src/$(APP).app.src
  521. $t test -f $(APP)/src/use_blue.erl
  522. $t test -f $(APP)/src/use_red.erl
  523. $i "Check that all build artifacts are removed"
  524. $t test ! -e $(APP)/$(APP).d
  525. $t test ! -e $(APP)/ebin/
  526. $i "Build the application again"
  527. $t $(MAKE) -C $(APP) $v
  528. $i "Check that all compiled files exist"
  529. $t test -f $(APP)/$(APP).d
  530. $t test -f $(APP)/ebin/$(APP).app
  531. $t test -f $(APP)/ebin/use_blue.beam
  532. $t test -f $(APP)/ebin/use_red.beam
  533. $i "Check that the application was compiled correctly"
  534. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  535. ok = application:start($(APP)), \
  536. {ok, Mods = [use_blue, use_red]} \
  537. = application:get_key($(APP), modules), \
  538. [{module, M} = code:load_file(M) || M <- Mods], \
  539. halt()"
  540. core-app-mib: build clean-core-app-mib
  541. $i "Bootstrap a new OTP library named $(APP)"
  542. $t mkdir $(APP)/
  543. $t cp ../erlang.mk $(APP)/
  544. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  545. $i "Download .mib files from Erlang/OTP"
  546. $t mkdir $(APP)/mibs/
  547. $t curl -s -o $(APP)/mibs/EX1-MIB.mib $(OTP_MASTER)/lib/snmp/examples/ex1/EX1-MIB.mib
  548. $t curl -s -o $(APP)/mibs/OTP-REG.mib $(OTP_MASTER)/lib/otp_mibs/mibs/OTP-REG.mib
  549. $i "Generate .erl files dependent from headers generated by .mib files"
  550. $t printf "%s\n" "-module(use_v1)." "-include(\"EX1-MIB.hrl\")." > $(APP)/src/use_v1.erl
  551. $t printf "%s\n" "-module(use_v2)." "-include(\"OTP-REG.hrl\")." > $(APP)/src/use_v2.erl
  552. $i "Generate an unrelated .hrl file"
  553. $t mkdir $(APP)/include/
  554. $t touch $(APP)/include/unrelated.hrl
  555. $i "Build the application"
  556. $t $(MAKE) -C $(APP) $v
  557. $i "Check that all compiled files exist"
  558. $t test -f $(APP)/$(APP).d
  559. $t test -f $(APP)/ebin/$(APP).app
  560. $t test -f $(APP)/ebin/use_v1.beam
  561. $t test -f $(APP)/ebin/use_v2.beam
  562. $t test -f $(APP)/include/EX1-MIB.hrl
  563. $t test -f $(APP)/include/OTP-REG.hrl
  564. $t test -f $(APP)/priv/mibs/EX1-MIB.bin
  565. $t test -f $(APP)/priv/mibs/OTP-REG.bin
  566. $i "Check that the application was compiled correctly"
  567. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  568. ok = application:start($(APP)), \
  569. {ok, Mods = [use_v1, use_v2]} \
  570. = application:get_key($(APP), modules), \
  571. [{module, M} = code:load_file(M) || M <- Mods], \
  572. halt()"
  573. $i "Touch one .mib file; check that only required files are rebuilt"
  574. # The use_v1.erl gets touched because of its dependency to EX1-MIB.hrl.
  575. $t printf "%s\n" \
  576. $(APP)/$(APP).d \
  577. $(APP)/ebin/$(APP).app \
  578. $(APP)/ebin/use_v1.beam \
  579. $(APP)/include/EX1-MIB.hrl \
  580. $(APP)/priv/mibs/EX1-MIB.bin \
  581. $(APP)/src/use_v1.erl | sort > $(APP)/EXPECT
  582. $t touch $(APP)/mibs/EX1-MIB.mib
  583. $t $(MAKE) -C $(APP) $v
  584. $t find $(APP) -type f -newer $(APP)/mibs/EX1-MIB.mib | sort | diff $(APP)/EXPECT -
  585. $t rm $(APP)/EXPECT
  586. $i "Check that the application was compiled correctly"
  587. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  588. ok = application:start($(APP)), \
  589. {ok, Mods = [use_v1, use_v2]} \
  590. = application:get_key($(APP), modules), \
  591. [{module, M} = code:load_file(M) || M <- Mods], \
  592. halt()"
  593. $i "Clean the application"
  594. $t $(MAKE) -C $(APP) clean $v
  595. $i "Check that source files still exist"
  596. $t test -f $(APP)/Makefile
  597. $t test -f $(APP)/erlang.mk
  598. $t test -f $(APP)/include/unrelated.hrl
  599. $t test -f $(APP)/mibs/EX1-MIB.mib
  600. $t test -f $(APP)/mibs/OTP-REG.mib
  601. $t test -f $(APP)/src/$(APP).app.src
  602. $t test -f $(APP)/src/use_v1.erl
  603. $t test -f $(APP)/src/use_v2.erl
  604. $i "Check that all build artifacts are removed, including intermediates"
  605. $t test ! -e $(APP)/$(APP).d
  606. $t test ! -e $(APP)/ebin/
  607. $t test ! -e $(APP)/include/EX1-MIB.hrl
  608. $t test ! -e $(APP)/include/OTP-REG.hrl
  609. $t test ! -e $(APP)/priv/mibs/
  610. $i "Build the application again"
  611. $t $(MAKE) -C $(APP) $v
  612. $i "Check that all compiled files exist"
  613. $t test -f $(APP)/$(APP).d
  614. $t test -f $(APP)/ebin/$(APP).app
  615. $t test -f $(APP)/ebin/use_v1.beam
  616. $t test -f $(APP)/ebin/use_v2.beam
  617. $t test -f $(APP)/include/EX1-MIB.hrl
  618. $t test -f $(APP)/include/OTP-REG.hrl
  619. $t test -f $(APP)/priv/mibs/EX1-MIB.bin
  620. $t test -f $(APP)/priv/mibs/OTP-REG.bin
  621. $i "Check that the application was compiled correctly"
  622. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  623. ok = application:start($(APP)), \
  624. {ok, Mods = [use_v1, use_v2]} \
  625. = application:get_key($(APP), modules), \
  626. [{module, M} = code:load_file(M) || M <- Mods], \
  627. halt()"
  628. core-app-no-makedep: build clean-core-app-no-makedep
  629. $i "Bootstrap a new OTP library named $(APP)"
  630. $t mkdir $(APP)/
  631. $t cp ../erlang.mk $(APP)/
  632. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  633. $i "Set NO_MAKEDEP ?= 1 in the Makefile"
  634. $t sed -i.bak '2i\
  635. NO_MAKEDEP ?= 1\
  636. ' $(APP)/Makefile
  637. $i "Generate .hrl files"
  638. $t mkdir $(APP)/include/
  639. $t touch $(APP)/include/blue.hrl $(APP)/include/red.hrl
  640. $i "Generate .erl files dependent from headers"
  641. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  642. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  643. $i "Build the application"
  644. $t $(MAKE) -C $(APP) $v
  645. $i "Check that all compiled files exist"
  646. $t test -f $(APP)/$(APP).d
  647. $t test -f $(APP)/ebin/$(APP).app
  648. $t test -f $(APP)/ebin/use_blue.beam
  649. $t test -f $(APP)/ebin/use_red.beam
  650. $i "Check that the application was compiled correctly"
  651. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  652. ok = application:start($(APP)), \
  653. {ok, Mods = [use_blue, use_red]} \
  654. = application:get_key($(APP), modules), \
  655. [{module, M} = code:load_file(M) || M <- Mods], \
  656. halt()"
  657. $i "Touch one .hrl file; check that only required files are rebuilt"
  658. # The use_red.erl gets touched because of its dependency to red.hrl.
  659. $t printf "%s\n" \
  660. $(APP)/ebin/$(APP).app \
  661. $(APP)/ebin/use_red.beam \
  662. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  663. $t touch $(APP)/include/red.hrl
  664. $t $(MAKE) -C $(APP) $v
  665. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  666. $t rm $(APP)/EXPECT
  667. $i "Check that the application was compiled correctly"
  668. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  669. ok = application:start($(APP)), \
  670. {ok, Mods = [use_blue, use_red]} \
  671. = application:get_key($(APP), modules), \
  672. [{module, M} = code:load_file(M) || M <- Mods], \
  673. halt()"
  674. $i "Touch one .hrl file; disable NO_MAKEDEP and check that only required files are rebuilt"
  675. # The use_red.erl gets touched because of its dependency to red.hrl.
  676. $t printf "%s\n" \
  677. $(APP)/$(APP).d \
  678. $(APP)/ebin/$(APP).app \
  679. $(APP)/ebin/use_red.beam \
  680. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  681. $t touch $(APP)/include/red.hrl
  682. $t NO_MAKEDEP= $(MAKE) -C $(APP) $v
  683. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  684. $t rm $(APP)/EXPECT
  685. $i "Check that the application was compiled correctly"
  686. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  687. ok = application:start($(APP)), \
  688. {ok, Mods = [use_blue, use_red]} \
  689. = application:get_key($(APP), modules), \
  690. [{module, M} = code:load_file(M) || M <- Mods], \
  691. halt()"
  692. $i "Clean the application"
  693. $t $(MAKE) -C $(APP) clean $v
  694. $i "Check that source files still exist"
  695. $t test -f $(APP)/Makefile
  696. $t test -f $(APP)/erlang.mk
  697. $t test -f $(APP)/include/blue.hrl
  698. $t test -f $(APP)/include/red.hrl
  699. $t test -f $(APP)/src/$(APP).app.src
  700. $t test -f $(APP)/src/use_blue.erl
  701. $t test -f $(APP)/src/use_red.erl
  702. $i "Check that all build artifacts are removed"
  703. $t test ! -e $(APP)/$(APP).d
  704. $t test ! -e $(APP)/ebin/
  705. $i "Build the application again"
  706. $t $(MAKE) -C $(APP) $v
  707. $i "Check that all compiled files exist"
  708. $t test -f $(APP)/$(APP).d
  709. $t test -f $(APP)/ebin/$(APP).app
  710. $t test -f $(APP)/ebin/use_blue.beam
  711. $t test -f $(APP)/ebin/use_red.beam
  712. $i "Check that the application was compiled correctly"
  713. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  714. ok = application:start($(APP)), \
  715. {ok, Mods = [use_blue, use_red]} \
  716. = application:get_key($(APP), modules), \
  717. [{module, M} = code:load_file(M) || M <- Mods], \
  718. halt()"
  719. core-app-xrl: build clean-core-app-xrl
  720. $i "Bootstrap a new OTP library named $(APP)"
  721. $t mkdir $(APP)/
  722. $t cp ../erlang.mk $(APP)/
  723. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  724. $i "Download .xrl files from Robert"
  725. $t curl -s -o $(APP)/src/erlang_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/erlang_scan.xrl
  726. $t curl -s -o $(APP)/src/lfe_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/lfe_scan.xrl
  727. $i "Generate unrelated .erl files"
  728. $t echo "-module(boy)." > $(APP)/src/boy.erl
  729. $t echo "-module(girl)." > $(APP)/src/girl.erl
  730. $i "Disable warnings; our test .xrl files aren't perfect"
  731. $t echo "ERLC_OPTS=+debug_info" >> $(APP)/Makefile
  732. $i "Build the application"
  733. $t $(MAKE) -C $(APP) $v
  734. $i "Check that all compiled files exist"
  735. $t test -f $(APP)/$(APP).d
  736. $t test -f $(APP)/ebin/$(APP).app
  737. $t test -f $(APP)/ebin/boy.beam
  738. $t test -f $(APP)/ebin/erlang_scan.beam
  739. $t test -f $(APP)/ebin/girl.beam
  740. $t test -f $(APP)/ebin/lfe_scan.beam
  741. $t test -f $(APP)/src/erlang_scan.erl
  742. $t test -f $(APP)/src/lfe_scan.erl
  743. $i "Check that the application was compiled correctly"
  744. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  745. ok = application:start($(APP)), \
  746. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  747. = application:get_key($(APP), modules), \
  748. [{module, M} = code:load_file(M) || M <- Mods], \
  749. halt()"
  750. $i "Touch one .xrl file; check that only required files are rebuilt"
  751. $t printf "%s\n" \
  752. $(APP)/$(APP).d \
  753. $(APP)/ebin/$(APP).app \
  754. $(APP)/ebin/erlang_scan.beam \
  755. $(APP)/src/erlang_scan.erl | sort > $(APP)/EXPECT
  756. $t touch $(APP)/src/erlang_scan.xrl
  757. $t $(MAKE) -C $(APP) $v
  758. $t find $(APP) -type f -newer $(APP)/src/erlang_scan.xrl | sort | diff $(APP)/EXPECT -
  759. $t rm $(APP)/EXPECT
  760. $i "Check that the application was compiled correctly"
  761. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  762. ok = application:start($(APP)), \
  763. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  764. = application:get_key($(APP), modules), \
  765. [{module, M} = code:load_file(M) || M <- Mods], \
  766. halt()"
  767. $i "Clean the application"
  768. $t $(MAKE) -C $(APP) clean $v
  769. $i "Check that source files still exist"
  770. $t test -f $(APP)/Makefile
  771. $t test -f $(APP)/erlang.mk
  772. $t test -f $(APP)/src/$(APP).app.src
  773. $t test -f $(APP)/src/boy.erl
  774. $t test -f $(APP)/src/erlang_scan.xrl
  775. $t test -f $(APP)/src/girl.erl
  776. $t test -f $(APP)/src/lfe_scan.xrl
  777. $i "Check that all build artifacts are removed, including intermediates"
  778. $t test ! -e $(APP)/$(APP).d
  779. $t test ! -e $(APP)/ebin/
  780. $t test ! -e $(APP)/src/erlang_scan.erl
  781. $t test ! -e $(APP)/src/lfe_scan.erl
  782. $i "Build the application again"
  783. $t $(MAKE) -C $(APP) $v
  784. $i "Check that all compiled files exist"
  785. $t test -f $(APP)/$(APP).d
  786. $t test -f $(APP)/ebin/$(APP).app
  787. $t test -f $(APP)/ebin/boy.beam
  788. $t test -f $(APP)/ebin/erlang_scan.beam
  789. $t test -f $(APP)/ebin/girl.beam
  790. $t test -f $(APP)/ebin/lfe_scan.beam
  791. $t test -f $(APP)/src/erlang_scan.erl
  792. $t test -f $(APP)/src/lfe_scan.erl
  793. $i "Check that the application was compiled correctly"
  794. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  795. ok = application:start($(APP)), \
  796. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  797. = application:get_key($(APP), modules), \
  798. [{module, M} = code:load_file(M) || M <- Mods], \
  799. halt()"
  800. core-app-xrl-include: build clean-core-app-xrl-include
  801. $i "Bootstrap a new OTP library named $(APP)"
  802. $t mkdir $(APP)/
  803. $t cp ../erlang.mk $(APP)/
  804. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  805. $i "Download a .xrl file with numerous includes from Gordon"
  806. $t curl -s -o $(APP)/src/xfl_lexer.xrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/formula_engine-1.0/priv/xfl_lexer.xrl
  807. $t curl -s -o $(APP)/src/errvals.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/errvals.hrl
  808. $t curl -s -o $(APP)/src/muin_proc_dict.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/muin_proc_dict.hrl
  809. $t curl -s -o $(APP)/src/muin_records.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/muin_records.hrl
  810. $t curl -s -o $(APP)/src/typechecks.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/typechecks.hrl
  811. $i "Generate unrelated .erl files"
  812. $t echo "-module(boy)." > $(APP)/src/boy.erl
  813. $t echo "-module(girl)." > $(APP)/src/girl.erl
  814. $i "Disable warnings; our test .xrl files aren't perfect"
  815. $t echo "ERLC_OPTS=+debug_info" >> $(APP)/Makefile
  816. $i "Build the application"
  817. $t $(MAKE) -C $(APP) $v
  818. $i "Check that all compiled files exist"
  819. $t test -f $(APP)/$(APP).d
  820. $t test -f $(APP)/ebin/$(APP).app
  821. $t test -f $(APP)/ebin/boy.beam
  822. $t test -f $(APP)/ebin/girl.beam
  823. $t test -f $(APP)/ebin/xfl_lexer.beam
  824. $t test -f $(APP)/src/xfl_lexer.erl
  825. $i "Check that the application was compiled correctly"
  826. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  827. ok = application:start($(APP)), \
  828. {ok, Mods = [boy, girl, xfl_lexer]} \
  829. = application:get_key($(APP), modules), \
  830. [{module, M} = code:load_file(M) || M <- Mods], \
  831. halt()"
  832. $i "Touch the .xrl file; check that only required files are rebuilt"
  833. $t printf "%s\n" \
  834. $(APP)/$(APP).d \
  835. $(APP)/ebin/$(APP).app \
  836. $(APP)/ebin/xfl_lexer.beam \
  837. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  838. $t touch $(APP)/src/xfl_lexer.xrl
  839. $t $(MAKE) -C $(APP) $v
  840. $t find $(APP) -type f -newer $(APP)/src/xfl_lexer.xrl | sort | diff $(APP)/EXPECT -
  841. $t rm $(APP)/EXPECT
  842. $i "Check that the application was compiled correctly"
  843. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  844. ok = application:start($(APP)), \
  845. {ok, Mods = [boy, girl, xfl_lexer]} \
  846. = application:get_key($(APP), modules), \
  847. [{module, M} = code:load_file(M) || M <- Mods], \
  848. halt()"
  849. $i "Touch a .hrl file included directly; check that only required files are rebuilt"
  850. $t printf "%s\n" \
  851. $(APP)/$(APP).d \
  852. $(APP)/ebin/$(APP).app \
  853. $(APP)/ebin/xfl_lexer.beam \
  854. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  855. $t touch $(APP)/src/typechecks.hrl
  856. $t $(MAKE) -C $(APP) $v
  857. $t find $(APP) -type f -newer $(APP)/src/typechecks.hrl | sort | diff $(APP)/EXPECT -
  858. $t rm $(APP)/EXPECT
  859. $i "Check that the application was compiled correctly"
  860. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  861. ok = application:start($(APP)), \
  862. {ok, Mods = [boy, girl, xfl_lexer]} \
  863. = application:get_key($(APP), modules), \
  864. [{module, M} = code:load_file(M) || M <- Mods], \
  865. halt()"
  866. $i "Touch a .hrl file included indirectly; check that only required files are rebuilt"
  867. $t printf "%s\n" \
  868. $(APP)/$(APP).d \
  869. $(APP)/ebin/$(APP).app \
  870. $(APP)/ebin/xfl_lexer.beam \
  871. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  872. $t touch $(APP)/src/errvals.hrl
  873. $t $(MAKE) -C $(APP) $v
  874. $t find $(APP) -type f -newer $(APP)/src/errvals.hrl | sort | diff $(APP)/EXPECT -
  875. $t rm $(APP)/EXPECT
  876. $i "Check that the application was compiled correctly"
  877. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  878. ok = application:start($(APP)), \
  879. {ok, Mods = [boy, girl, xfl_lexer]} \
  880. = application:get_key($(APP), modules), \
  881. [{module, M} = code:load_file(M) || M <- Mods], \
  882. halt()"
  883. $i "Clean the application"
  884. $t $(MAKE) -C $(APP) clean $v
  885. $i "Check that source files still exist"
  886. $t test -f $(APP)/Makefile
  887. $t test -f $(APP)/erlang.mk
  888. $t test -f $(APP)/src/$(APP).app.src
  889. $t test -f $(APP)/src/boy.erl
  890. $t test -f $(APP)/src/girl.erl
  891. $t test -f $(APP)/src/errvals.hrl
  892. $t test -f $(APP)/src/muin_proc_dict.hrl
  893. $t test -f $(APP)/src/muin_records.hrl
  894. $t test -f $(APP)/src/typechecks.hrl
  895. $t test -f $(APP)/src/xfl_lexer.xrl
  896. $i "Check that all build artifacts are removed, including intermediates"
  897. $t test ! -e $(APP)/$(APP).d
  898. $t test ! -e $(APP)/ebin/
  899. $t test ! -e $(APP)/src/xfl_lexer.erl
  900. $i "Build the application again"
  901. $t $(MAKE) -C $(APP) $v
  902. $i "Check that all compiled files exist"
  903. $t test -f $(APP)/$(APP).d
  904. $t test -f $(APP)/ebin/$(APP).app
  905. $t test -f $(APP)/ebin/boy.beam
  906. $t test -f $(APP)/ebin/girl.beam
  907. $t test -f $(APP)/ebin/xfl_lexer.beam
  908. $t test -f $(APP)/src/xfl_lexer.erl
  909. $i "Check that the application was compiled correctly"
  910. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  911. ok = application:start($(APP)), \
  912. {ok, Mods = [boy, girl, xfl_lexer]} \
  913. = application:get_key($(APP), modules), \
  914. [{module, M} = code:load_file(M) || M <- Mods], \
  915. halt()"
  916. core-app-yrl: build clean-core-app-yrl
  917. $i "Bootstrap a new OTP library named $(APP)"
  918. $t mkdir $(APP)/
  919. $t cp ../erlang.mk $(APP)/
  920. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  921. $i "Download .yrl files from Erlang/OTP"
  922. $t curl -s -o $(APP)/src/xmerl_xpath_parse.yrl $(OTP_MASTER)/lib/xmerl/src/xmerl_xpath_parse.yrl
  923. $t curl -s -o $(APP)/src/xref_parser.yrl $(OTP_MASTER)/lib/tools/src/xref_parser.yrl
  924. $i "Generate unrelated .erl files"
  925. $t echo "-module(boy)." > $(APP)/src/boy.erl
  926. $t echo "-module(girl)." > $(APP)/src/girl.erl
  927. $i "Build the application"
  928. $t $(MAKE) -C $(APP) $v
  929. $i "Check that all compiled files exist"
  930. $t test -f $(APP)/$(APP).d
  931. $t test -f $(APP)/ebin/$(APP).app
  932. $t test -f $(APP)/ebin/boy.beam
  933. $t test -f $(APP)/ebin/girl.beam
  934. $t test -f $(APP)/ebin/xmerl_xpath_parse.beam
  935. $t test -f $(APP)/ebin/xref_parser.beam
  936. $t test -f $(APP)/src/xmerl_xpath_parse.erl
  937. $t test -f $(APP)/src/xref_parser.erl
  938. $i "Check that the application was compiled correctly"
  939. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  940. ok = application:start($(APP)), \
  941. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  942. = application:get_key($(APP), modules), \
  943. [{module, M} = code:load_file(M) || M <- Mods], \
  944. halt()"
  945. $i "Touch one .yrl file; check that only required files are rebuilt"
  946. $t printf "%s\n" \
  947. $(APP)/$(APP).d \
  948. $(APP)/ebin/$(APP).app \
  949. $(APP)/ebin/xref_parser.beam \
  950. $(APP)/src/xref_parser.erl | sort > $(APP)/EXPECT
  951. $t touch $(APP)/src/xref_parser.yrl
  952. $t $(MAKE) -C $(APP) $v
  953. $t find $(APP) -type f -newer $(APP)/src/xref_parser.yrl | sort | diff $(APP)/EXPECT -
  954. $t rm $(APP)/EXPECT
  955. $i "Check that the application was compiled correctly"
  956. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  957. ok = application:start($(APP)), \
  958. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  959. = application:get_key($(APP), modules), \
  960. [{module, M} = code:load_file(M) || M <- Mods], \
  961. halt()"
  962. $i "Clean the application"
  963. $t $(MAKE) -C $(APP) clean $v
  964. $i "Check that source files still exist"
  965. $t test -f $(APP)/Makefile
  966. $t test -f $(APP)/erlang.mk
  967. $t test -f $(APP)/src/$(APP).app.src
  968. $t test -f $(APP)/src/boy.erl
  969. $t test -f $(APP)/src/girl.erl
  970. $t test -f $(APP)/src/xmerl_xpath_parse.yrl
  971. $t test -f $(APP)/src/xref_parser.yrl
  972. $i "Check that all build artifacts are removed, including intermediates"
  973. $t test ! -e $(APP)/$(APP).d
  974. $t test ! -e $(APP)/ebin/
  975. $t test ! -e $(APP)/src/xmerl_xpath_parse.erl
  976. $t test ! -e $(APP)/src/xref_parser.erl
  977. $i "Build the application again"
  978. $t $(MAKE) -C $(APP) $v
  979. $i "Check that all compiled files exist"
  980. $t test -f $(APP)/$(APP).d
  981. $t test -f $(APP)/ebin/$(APP).app
  982. $t test -f $(APP)/ebin/boy.beam
  983. $t test -f $(APP)/ebin/girl.beam
  984. $t test -f $(APP)/ebin/xmerl_xpath_parse.beam
  985. $t test -f $(APP)/ebin/xref_parser.beam
  986. $t test -f $(APP)/src/xmerl_xpath_parse.erl
  987. $t test -f $(APP)/src/xref_parser.erl
  988. $i "Check that the application was compiled correctly"
  989. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  990. ok = application:start($(APP)), \
  991. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  992. = application:get_key($(APP), modules), \
  993. [{module, M} = code:load_file(M) || M <- Mods], \
  994. halt()"
  995. core-app-yrl-include: build clean-core-app-yrl-include
  996. $i "Bootstrap a new OTP library named $(APP)"
  997. $t mkdir $(APP)/
  998. $t cp ../erlang.mk $(APP)/
  999. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1000. $i "Download a .yrl file with includes from Erlang/OTP"
  1001. $t curl -s -o $(APP)/src/core_parse.yrl $(OTP_MASTER)/lib/compiler/src/core_parse.yrl
  1002. $t curl -s -o $(APP)/src/core_parse.hrl $(OTP_MASTER)/lib/compiler/src/core_parse.hrl
  1003. $i "Generate unrelated .erl files"
  1004. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1005. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1006. $i "Build the application"
  1007. $t $(MAKE) -C $(APP) $v
  1008. $i "Check that all compiled files exist"
  1009. $t test -f $(APP)/$(APP).d
  1010. $t test -f $(APP)/ebin/$(APP).app
  1011. $t test -f $(APP)/ebin/boy.beam
  1012. $t test -f $(APP)/ebin/core_parse.beam
  1013. $t test -f $(APP)/ebin/girl.beam
  1014. $t test -f $(APP)/src/core_parse.erl
  1015. $i "Check that the application was compiled correctly"
  1016. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1017. ok = application:start($(APP)), \
  1018. {ok, Mods = [boy, core_parse, girl]} \
  1019. = application:get_key($(APP), modules), \
  1020. [{module, M} = code:load_file(M) || M <- Mods], \
  1021. halt()"
  1022. $i "Touch the .yrl file; check that only required files are rebuilt"
  1023. $t printf "%s\n" \
  1024. $(APP)/$(APP).d \
  1025. $(APP)/ebin/$(APP).app \
  1026. $(APP)/ebin/core_parse.beam \
  1027. $(APP)/src/core_parse.erl | sort > $(APP)/EXPECT
  1028. $t touch $(APP)/src/core_parse.yrl
  1029. $t $(MAKE) -C $(APP) $v
  1030. $t find $(APP) -type f -newer $(APP)/src/core_parse.yrl | sort | diff $(APP)/EXPECT -
  1031. $t rm $(APP)/EXPECT
  1032. $i "Check that the application was compiled correctly"
  1033. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1034. ok = application:start($(APP)), \
  1035. {ok, Mods = [boy, core_parse, girl]} \
  1036. = application:get_key($(APP), modules), \
  1037. [{module, M} = code:load_file(M) || M <- Mods], \
  1038. halt()"
  1039. $i "Touch the .hrl file included; check that only required files are rebuilt"
  1040. $t printf "%s\n" \
  1041. $(APP)/$(APP).d \
  1042. $(APP)/ebin/$(APP).app \
  1043. $(APP)/ebin/core_parse.beam \
  1044. $(APP)/src/core_parse.erl | sort > $(APP)/EXPECT
  1045. $t touch $(APP)/src/core_parse.hrl
  1046. $t $(MAKE) -C $(APP) $v
  1047. $t find $(APP) -type f -newer $(APP)/src/core_parse.hrl | sort | diff $(APP)/EXPECT -
  1048. $t rm $(APP)/EXPECT
  1049. $i "Check that the application was compiled correctly"
  1050. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1051. ok = application:start($(APP)), \
  1052. {ok, Mods = [boy, core_parse, girl]} \
  1053. = application:get_key($(APP), modules), \
  1054. [{module, M} = code:load_file(M) || M <- Mods], \
  1055. halt()"
  1056. $i "Clean the application"
  1057. $t $(MAKE) -C $(APP) clean $v
  1058. $i "Check that source files still exist"
  1059. $t test -f $(APP)/Makefile
  1060. $t test -f $(APP)/erlang.mk
  1061. $t test -f $(APP)/src/$(APP).app.src
  1062. $t test -f $(APP)/src/boy.erl
  1063. $t test -f $(APP)/src/core_parse.hrl
  1064. $t test -f $(APP)/src/core_parse.yrl
  1065. $t test -f $(APP)/src/girl.erl
  1066. $i "Check that all build artifacts are removed, including intermediates"
  1067. $t test ! -e $(APP)/$(APP).d
  1068. $t test ! -e $(APP)/ebin/
  1069. $t test ! -e $(APP)/src/core_parse.erl
  1070. $i "Build the application again"
  1071. $t $(MAKE) -C $(APP) $v
  1072. $i "Check that all compiled files exist"
  1073. $t test -f $(APP)/$(APP).d
  1074. $t test -f $(APP)/ebin/$(APP).app
  1075. $t test -f $(APP)/ebin/boy.beam
  1076. $t test -f $(APP)/ebin/core_parse.beam
  1077. $t test -f $(APP)/ebin/girl.beam
  1078. $t test -f $(APP)/src/core_parse.erl
  1079. $i "Check that the application was compiled correctly"
  1080. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1081. ok = application:start($(APP)), \
  1082. {ok, Mods = [boy, core_parse, girl]} \
  1083. = application:get_key($(APP), modules), \
  1084. [{module, M} = code:load_file(M) || M <- Mods], \
  1085. halt()"
  1086. clean-core-app: $(CORE_APP_CLEAN_TARGETS)
  1087. $(CORE_APP_CLEAN_TARGETS):
  1088. $t rm -rf $(APP_TO_CLEAN)/
  1089. # Core: Erlang.mk upgrade.
  1090. CORE_UPGRADE_CASES = alt-erlangmk-repo no-config custom-config renamed-config custom-build-dir
  1091. CORE_UPGRADE_TARGETS = $(addprefix core-upgrade-,$(CORE_UPGRADE_CASES))
  1092. CORE_UPGRADE_CLEAN_TARGETS = $(addprefix clean-,$(CORE_UPGRADE_TARGETS))
  1093. .PHONY: core-upgrade $(CORE_UPGRADE_TARGETS) $(CORE_UPGRADE_CLEAN_TARGETS)
  1094. core-upgrade: $(CORE_UPGRADE_TARGETS)
  1095. core-upgrade-alt-erlangmk-repo: build clean-core-upgrade-alt-erlangmk-repo
  1096. $i "Bootstrap a new OTP library named $(APP)"
  1097. $t mkdir $(APP)/
  1098. $t cp ../erlang.mk $(APP)/
  1099. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1100. $i "Fork erlang.mk locally and modify it"
  1101. $t git clone -q https://github.com/ninenines/erlang.mk $(APP)/alt-erlangmk-repo
  1102. $t sed -i.bak '1i\
  1103. # Copyright (c) erlang.mk Testsuite!\
  1104. ' $(APP)/alt-erlangmk-repo/core/core.mk
  1105. $t (cd $(APP)/alt-erlangmk-repo && \
  1106. git checkout -q -b test-copyright && \
  1107. git config user.email "testsuite@erlang.mk" && \
  1108. git config user.name "test suite" && \
  1109. git commit -q -a -m 'Add Testsuite copyright')
  1110. $i "Point application to an alternate erlang.mk repository"
  1111. $t sed -i.bak '2i\
  1112. ERLANG_MK_REPO = file://$(abspath $(APP)/alt-erlangmk-repo)\
  1113. ERLANG_MK_COMMIT = test-copyright\
  1114. ' $(APP)/Makefile
  1115. $i "Update erlang.mk"
  1116. $t $(MAKE) -C $(APP) erlang-mk $v
  1117. $i "Check our modification is there"
  1118. $t grep -q "# Copyright (c) erlang.mk Testsuite!" $(APP)/erlang.mk
  1119. core-upgrade-no-config: build clean-core-upgrade-no-config
  1120. $i "Bootstrap a new OTP library named $(APP)"
  1121. $t mkdir $(APP)/
  1122. $t cp ../erlang.mk $(APP)/
  1123. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1124. $i "Append a rule to the Erlang.mk file for testing purposes"
  1125. $t echo "erlang_mk_upgrade_test_rule: ; @echo FAIL" >> $(APP)/erlang.mk
  1126. $i "Check that the test rule works as intended"
  1127. $t test "FAIL" = "`$(MAKE) -C $(APP) --no-print-directory erlang_mk_upgrade_test_rule V=0`"
  1128. $i "Upgrade Erlang.mk"
  1129. $t $(MAKE) -C $(APP) erlang-mk $v
  1130. $i "Check that the rule is gone"
  1131. $t if $(MAKE) -C $(APP) erlang_mk_upgrade_test_rule $v; then false; fi
  1132. core-upgrade-custom-config: build clean-core-upgrade-custom-config
  1133. $i "Bootstrap a new OTP library named $(APP)"
  1134. $t mkdir $(APP)/
  1135. $t cp ../erlang.mk $(APP)/
  1136. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1137. $i "Create a custom build.config file without plugins"
  1138. $t echo "core/*" > $(APP)/build.config
  1139. $i "Upgrade Erlang.mk"
  1140. $t $(MAKE) -C $(APP) erlang-mk $v
  1141. $i "Check that the bootstrap plugin is gone"
  1142. $t if $(MAKE) -C $(APP) list-templates $v; then false; fi
  1143. core-upgrade-renamed-config: build clean-core-upgrade-renamed-config
  1144. $i "Bootstrap a new OTP library named $(APP)"
  1145. $t mkdir $(APP)/
  1146. $t cp ../erlang.mk $(APP)/
  1147. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1148. $i "Create a custom build.config file without plugins; name it my.build.config"
  1149. $t echo "core/*" > $(APP)/my.build.config
  1150. $i "Set ERLANG_MK_BUILD_CONFIG=my.build.config in the Makefile"
  1151. $t echo "ERLANG_MK_BUILD_CONFIG = my.build.config" >> $(APP)/Makefile
  1152. $i "Upgrade Erlang.mk"
  1153. $t $(MAKE) -C $(APP) erlang-mk $v
  1154. $i "Check that the bootstrap plugin is gone"
  1155. $t if $(MAKE) -C $(APP) list-templates $v; then false; fi
  1156. core-upgrade-custom-build-dir: build clean-core-upgrade-custom-build-dir
  1157. $i "Bootstrap a new OTP library named $(APP)"
  1158. $t mkdir $(APP)/
  1159. $t cp ../erlang.mk $(APP)/
  1160. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1161. $i "Append a rule to the Erlang.mk file for testing purposes"
  1162. $t echo "erlang_mk_upgrade_test_rule: ; @echo FAIL" >> $(APP)/erlang.mk
  1163. $i "Check that the test rule works as intended"
  1164. $t test "FAIL" = "`$(MAKE) -C $(APP) --no-print-directory erlang_mk_upgrade_test_rule V=0`"
  1165. $i "Create the custom build directory"
  1166. $t mkdir $(APP)/custom/
  1167. $t test -d $(APP)/custom/
  1168. $i "Upgrade Erlang.mk with a custom build directory"
  1169. $t ERLANG_MK_BUILD_DIR=custom $(MAKE) -C $(APP) erlang-mk $v
  1170. $i "Check that the rule is gone"
  1171. $t if $(MAKE) -C $(APP) erlang_mk_upgrade_test_rule $v; then false; fi
  1172. $i "Check that the custom build directory is gone"
  1173. $t test ! -d $(APP)/custom/
  1174. clean-core-upgrade: $(CORE_UPGRADE_CLEAN_TARGETS)
  1175. $(CORE_UPGRADE_CLEAN_TARGETS):
  1176. $t rm -rf $(APP_TO_CLEAN)/
  1177. # Bootstrap plugin.
  1178. BOOTSTRAP_CASES = app lib rel templates
  1179. BOOTSTRAP_TARGETS = $(addprefix bootstrap-,$(BOOTSTRAP_CASES))
  1180. BOOTSTRAP_CLEAN_TARGETS = $(addprefix clean-,$(BOOTSTRAP_TARGETS))
  1181. .PHONY: bootstrap $(BOOTSTRAP_TARGETS) $(BOOTSTRAP_CLEAN_TARGETS)
  1182. bootstrap: $(BOOTSTRAP_TARGETS)
  1183. bootstrap-app: build clean-bootstrap-app
  1184. $i "Bootstrap a new OTP application named $(APP)"
  1185. $t mkdir $(APP)/
  1186. $t cp ../erlang.mk $(APP)/
  1187. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  1188. $i "Check that all bootstrapped files exist"
  1189. $t test -f $(APP)/Makefile
  1190. $t test -f $(APP)/src/$(APP).app.src
  1191. $t test -f $(APP)/src/$(APP)_app.erl
  1192. $t test -f $(APP)/src/$(APP)_sup.erl
  1193. $i "Build the application"
  1194. $t $(MAKE) -C $(APP) $v
  1195. $i "Check that all compiled files exist"
  1196. $t test -f $(APP)/ebin/$(APP).app
  1197. $t test -f $(APP)/ebin/$(APP)_app.beam
  1198. $t test -f $(APP)/ebin/$(APP)_sup.beam
  1199. $i "Check that the application was compiled correctly"
  1200. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1201. ok = application:start($(APP)), \
  1202. {ok, [$(APP)_app, $(APP)_sup]} = application:get_key($(APP), modules), \
  1203. {module, $(APP)_app} = code:load_file($(APP)_app), \
  1204. {module, $(APP)_sup} = code:load_file($(APP)_sup), \
  1205. halt()"
  1206. bootstrap-lib: build clean-bootstrap-lib
  1207. $i "Bootstrap a new OTP library named $(APP)"
  1208. $t mkdir $(APP)/
  1209. $t cp ../erlang.mk $(APP)/
  1210. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1211. $i "Check that all bootstrapped files exist"
  1212. $t test -f $(APP)/Makefile
  1213. $t test -f $(APP)/src/$(APP).app.src
  1214. $i "Build the application"
  1215. $t $(MAKE) -C $(APP) $v
  1216. $i "Check that all compiled files exist"
  1217. $t test -f $(APP)/ebin/$(APP).app
  1218. $i "Check that the application was compiled correctly"
  1219. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1220. ok = application:start($(APP)), \
  1221. {ok, []} = application:get_key($(APP), modules), \
  1222. halt()"
  1223. bootstrap-rel: build clean-bootstrap-rel
  1224. $i "Bootstrap a new release-enabled OTP application named $(APP)"
  1225. $t mkdir $(APP)/
  1226. $t cp ../erlang.mk $(APP)/
  1227. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap bootstrap-rel $v
  1228. $i "Check that all bootstrapped files exist"
  1229. $t test -f $(APP)/Makefile
  1230. $t test -f $(APP)/relx.config
  1231. $t test -f $(APP)/rel/sys.config
  1232. $t test -f $(APP)/rel/vm.args
  1233. $t test -f $(APP)/src/$(APP).app.src
  1234. $t test -f $(APP)/src/$(APP)_app.erl
  1235. $t test -f $(APP)/src/$(APP)_sup.erl
  1236. $i "Build the application and the release"
  1237. $t $(MAKE) -C $(APP) $v
  1238. $i "Check that all compiled files exist"
  1239. $t test -f $(APP)/ebin/$(APP).app
  1240. $t test -f $(APP)/ebin/$(APP)_app.beam
  1241. $t test -f $(APP)/ebin/$(APP)_sup.beam
  1242. $i "Check that the release was generated"
  1243. $t test -f $(APP)/_rel/$(APP)_release/bin/$(APP)_release
  1244. $i "Check that the release can be started and stopped"
  1245. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release start $v
  1246. $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release stop $v
  1247. $i "Check that there's no erl_crash.dump file"
  1248. $t test ! -f $(APP)/_rel/$(APP)_release/erl_crash.dump
  1249. bootstrap-templates: build clean-bootstrap-templates
  1250. $i "Bootstrap a new OTP library named $(APP)"
  1251. $t mkdir $(APP)/
  1252. $t cp ../erlang.mk $(APP)/
  1253. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1254. $i "Check that we can get the list of templates"
  1255. $t test `$(MAKE) -C $(APP) --no-print-directory list-templates V=0 | wc -l` -eq 1
  1256. $i "Generate one of each template"
  1257. $t $(MAKE) -C $(APP) --no-print-directory new t=gen_fsm n=my_fsm
  1258. $t $(MAKE) -C $(APP) --no-print-directory new t=gen_server n=my_server
  1259. $t $(MAKE) -C $(APP) --no-print-directory new t=supervisor n=my_sup
  1260. $t $(MAKE) -C $(APP) --no-print-directory new t=cowboy_http n=my_http
  1261. $t $(MAKE) -C $(APP) --no-print-directory new t=cowboy_loop n=my_loop
  1262. $t $(MAKE) -C $(APP) --no-print-directory new t=cowboy_rest n=my_rest
  1263. $t $(MAKE) -C $(APP) --no-print-directory new t=cowboy_ws n=my_ws
  1264. $t $(MAKE) -C $(APP) --no-print-directory new t=ranch_protocol n=my_protocol
  1265. # Here we disable warnings because templates contain missing behaviors.
  1266. $i "Build the application"
  1267. $t $(MAKE) -C $(APP) ERLC_OPTS=+debug_info $v
  1268. $i "Check that all compiled files exist"
  1269. $t test -f $(APP)/ebin/$(APP).app
  1270. $t test -f $(APP)/ebin/my_fsm.beam
  1271. $t test -f $(APP)/ebin/my_server.beam
  1272. $t test -f $(APP)/ebin/my_sup.beam
  1273. $i "Check that all the modules can be loaded"
  1274. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1275. ok = application:start($(APP)), \
  1276. {ok, Mods = [my_fsm, my_http, my_loop, my_protocol, my_rest, my_server, my_sup, my_ws]} \
  1277. = application:get_key($(APP), modules), \
  1278. [{module, M} = code:load_file(M) || M <- Mods], \
  1279. halt()"
  1280. clean-bootstrap: $(BOOTSTRAP_CLEAN_TARGETS)
  1281. $(BOOTSTRAP_CLEAN_TARGETS):
  1282. $t rm -rf $(APP_TO_CLEAN)/
  1283. ########################################
  1284. # Legacy tests.
  1285. ct: app1
  1286. $i "ct: Testing ct and related targets."
  1287. $i "Setting up test suite."
  1288. $t mkdir -p app1/test
  1289. $t printf "%s\n" \
  1290. "-module(m_SUITE)." \
  1291. "-export([all/0, testcase1/1])." \
  1292. "all() -> [testcase1]." \
  1293. "testcase1(_) -> 2 = m:succ(1)." \
  1294. > app1/test/m_SUITE.erl
  1295. $t $(MAKE) -C app1 ct $v
  1296. $i "Checking files created by '$(MAKE) ct'."
  1297. $t [ -e app1/test/m_SUITE.beam ]
  1298. $t [ -e app1/ebin/m.beam ]
  1299. $t [ -e app1/logs ]
  1300. $i "Checking that '$(MAKE) clean' does not delete logs."
  1301. $t $(MAKE) -C app1 clean $v
  1302. $t [ -e app1/logs ]
  1303. $i "Testing target 'ct-mysuite' where mysuite_SUITE is a test suite."
  1304. $t $(MAKE) -C app1 ct-m $v
  1305. $i "Checking that '$(MAKE) ct' returns non-zero for a failing suite."
  1306. $t printf "%s\n" \
  1307. "-module(failing_SUITE)." \
  1308. "-export([all/0, testcase1/1])." \
  1309. "all() -> [testcase1]." \
  1310. "testcase1(_) -> 42 = m:succ(1)." \
  1311. > app1/test/failing_SUITE.erl
  1312. $t if $(MAKE) -C app1 ct-failing $v ; then false ; fi
  1313. $i "Checking that '$(MAKE) distclean-ct' deletes logs."
  1314. $t $(MAKE) -C app1 distclean-ct $v
  1315. $t [ ! -e app1/logs ]
  1316. $t [ -e app1/ebin/m.beam ]
  1317. $i "Cleaning up test data."
  1318. $t rm -rf app1/test
  1319. $i "Test 'ct' passed."
  1320. eunit: app1
  1321. $i "eunit: Testing the 'eunit' target."
  1322. $i "Running eunit test case inside module src/t.erl"
  1323. $t $(call create-module-t)
  1324. $t $(MAKE) -C app1 distclean $v
  1325. $t $(MAKE) -C app1 eunit $v
  1326. $i "Checking that the eunit test in module t."
  1327. $t echo t | cmp app1/test-eunit.log -
  1328. $t rm app1/test-eunit.log
  1329. $i "Running eunit tests in a separate directory."
  1330. $t mkdir -p app1/eunit
  1331. $t printf '%s\n' \
  1332. '-module(t_tests).' \
  1333. '-include_lib("eunit/include/eunit.hrl").' \
  1334. 'succ_test() ->' \
  1335. ' ?assertEqual(2, t:succ(1)),' \
  1336. ' os:cmd("echo t_tests >> test-eunit.log").' \
  1337. > app1/eunit/t_tests.erl
  1338. $t printf '%s\n' \
  1339. '-module(x_tests).' \
  1340. '-include_lib("eunit/include/eunit.hrl").' \
  1341. 'succ_test() ->' \
  1342. ' ?assertEqual(2, t:succ(1)),' \
  1343. ' os:cmd("echo x_tests >> test-eunit.log").' \
  1344. > app1/eunit/x_tests.erl
  1345. $t $(MAKE) -C app1 distclean TEST_DIR=eunit $v
  1346. $t $(MAKE) -C app1 eunit TEST_DIR=eunit $v
  1347. $i "Checking that '$(MAKE) eunit' didn't run the tests in t_tests twice, etc."
  1348. $t printf "%s\n" t t_tests x_tests | cmp app1/test-eunit.log -
  1349. $t rm app1/test-eunit.log
  1350. $i "Checking that '$(MAKE) eunit' returns non-zero for a failing test."
  1351. $t rm -f app1/eunit/*
  1352. $t printf "%s\n" \
  1353. "-module(t_tests)." \
  1354. '-include_lib("eunit/include/eunit.hrl").' \
  1355. "succ_test() ->" \
  1356. " ?assertEqual(42, t:succ(1))." \
  1357. > app1/eunit/t_tests.erl
  1358. $t $(MAKE) -C app1 distclean TEST_DIR=eunit $v
  1359. $t if $(MAKE) -C app1 eunit TEST_DIR=eunit $v ; then false ; fi
  1360. $t rm -rf app1/eunit app1/src/t.erl app1/test-eunit.log
  1361. $i "Test 'eunit' passed."
  1362. # TODO: do coverage for 'tests' instead of 'eunit ct' when triq is fixed
  1363. tests-cover: app1
  1364. $i "tests-cover: Testing 'eunit' and 'ct' with COVER=1"
  1365. $i "Setting up eunit and ct suites."
  1366. $t $(call create-module-t)
  1367. $t mkdir -p app1/test
  1368. $t printf "%s\n" \
  1369. "-module(m_SUITE)." \
  1370. "-export([all/0, testcase1/1])." \
  1371. "all() -> [testcase1]." \
  1372. "testcase1(_) -> 2 = m:succ(1)." \
  1373. > app1/test/m_SUITE.erl
  1374. $i "Running tests with coverage analysis."
  1375. $t $(MAKE) -C app1 eunit ct COVER=1 $v
  1376. $t [ -e app1/test-eunit.log ]
  1377. $t [ -e app1/eunit.coverdata ]
  1378. $t [ -e app1/ct.coverdata ]
  1379. $i "Generating coverage report."
  1380. $t $(MAKE) -C app1 cover-report COVER=1 $v
  1381. $t [ -e app1/cover/m.COVER.html ]
  1382. $t [ -e app1/cover/t.COVER.html ]
  1383. $t [ -e app1/cover/index.html ]
  1384. $i "Checking combined coverage from eunit and ct."
  1385. $t [ `grep 'Total: 100%' app1/cover/index.html | wc -l` -eq 1 ]
  1386. $i "Checking that cover-report-clean removes cover report."
  1387. $t $(MAKE) -C app1 cover-report-clean $v
  1388. $t [ ! -e app1/cover ]
  1389. $i "Checking that coverdata-clean removes cover data."
  1390. $t $(MAKE) -C app1 coverdata-clean $v
  1391. $t [ ! -e app1/eunit.coverdata ]
  1392. @# clean up
  1393. $t rm -rf app1/src/t.erl app1/test app1/test-eunit.log
  1394. $t $(MAKE) -C app1 clean $v
  1395. $i "Test 'tests-cover' passed."
  1396. docs: app1
  1397. $i "docs: Testing EDoc including DOC_DEPS."
  1398. $t printf "%s\n" \
  1399. "PROJECT = app1" \
  1400. "DOC_DEPS = edown" \
  1401. "dep_edown = git https://github.com/uwiger/edown.git 0.7" \
  1402. "EDOC_OPTS = {doclet, edown_doclet}" \
  1403. "include erlang.mk" \
  1404. "distclean:: distclean-doc-md" \
  1405. "distclean-doc-md:" \
  1406. " rm -rf doc/*.md" \
  1407. > app1/Makefile-doc
  1408. $i "Downloading doc deps (edown) and building docs."
  1409. $t $(MAKE) -C app1 -f Makefile-doc docs $v
  1410. $i "Checking that '$(MAKE) docs' using edown generated a markdown file."
  1411. $t [ -e app1/doc/m.md ]
  1412. $i "Checking that '$(MAKE) distclean' deletes all generated doc files."
  1413. $t $(MAKE) -C app1 -f Makefile-doc distclean $v
  1414. $t [ "`ls app1/doc/`" = "" ]
  1415. $i "Cleaning up test data."
  1416. $t rm app1/Makefile-doc
  1417. $i "Test 'docs' passed."
  1418. define app1_setup
  1419. $i "Setting up app."
  1420. $t mkdir -p app1
  1421. $t cd .. && $(MAKE)
  1422. $t cp ../erlang.mk app1/
  1423. $t $(MAKE) -C app1 -f erlang.mk bootstrap-lib
  1424. $t printf "%s\n" \
  1425. "-module(m)." \
  1426. "-export([succ/1])." \
  1427. "succ(N) -> N + 1." \
  1428. > app1/src/m.erl
  1429. endef
  1430. define pkg_test_target
  1431. pkg-$(1)-clean:
  1432. $t rm -rf app1 erl_crash.dump
  1433. pkg-$(1)-app1:
  1434. $(call app1_setup)
  1435. # Running 'make' twice to make sure it recompiles fine.
  1436. pkg-$(1): pkg-$(1)-clean pkg-$(1)-app1
  1437. $i
  1438. $i " pkgs: Checking that '$(1)' builds correctly"
  1439. $i
  1440. $t printf "%s\n" \
  1441. "PROJECT = app1" \
  1442. "DEPS = $(1)" \
  1443. "include erlang.mk" \
  1444. > app1/Makefile
  1445. $t \
  1446. if [ "$(1)" = "amqp_client" ]; then \
  1447. $(MAKE) -C app1 RABBITMQ_CLIENT_PATCH=1; \
  1448. elif [ "$(1)" = "rabbit" ]; then \
  1449. $(MAKE) -C app1 RABBITMQ_SERVER_PATCH=1; \
  1450. else \
  1451. $(MAKE) -C app1; \
  1452. fi; \
  1453. if [ $$$$? -ne 0 ]; then \
  1454. echo "$(1): make error" >> pkgs.log; \
  1455. else \
  1456. $(MAKE) -C app1; if [ $$$$? -ne 0 ]; then \
  1457. echo "$(1): re-make error" >> pkgs.log; \
  1458. else \
  1459. find . -type f -name erl_crash.dump; if [ $$$$? -ne 0 ]; then \
  1460. echo "$(1): erl_crash.dump found" >> pkgs.log; \
  1461. else \
  1462. erl +A0 -noinput -boot start_clean -pa app1/deps/*/ebin -eval " \
  1463. Apps = [list_to_atom(App) || \"app1/deps/\" ++ App \
  1464. <- filelib:wildcard(\"app1/deps/*\")], \
  1465. [begin \
  1466. io:format(\"Loading application ~p~n\", [App]), \
  1467. case application:load(App) of \
  1468. {error, _} -> ok; \
  1469. ok -> \
  1470. {ok, Mods} = application:get_key(App, modules), \
  1471. [try io:format(\" Loading module ~p~n\", [Mod]), \
  1472. {module, Mod} = code:load_file(Mod) \
  1473. catch C:R -> timer:sleep(500), erlang:C(R) \
  1474. end || Mod <- Mods] \
  1475. end \
  1476. end || App <- Apps], \
  1477. halt()."; if [ $$$$? -ne 0 ]; then \
  1478. echo "$(1): load error" >> pkgs.log; \
  1479. fi \
  1480. fi \
  1481. fi \
  1482. fi
  1483. endef
  1484. PACKAGES = $(foreach pkg,$(sort $(wildcard ../index/*.mk)),$(notdir $(basename $(pkg))))
  1485. $(foreach pkg,$(PACKAGES),$(eval $(call pkg_test_target,$(pkg))))
  1486. pkgs: $(addprefix pkg-,$(PACKAGES))
  1487. @if [ -f pkgs.log ]; then \
  1488. echo "+-------------------------------+"; \
  1489. echo "| ERRORS WHILE TESTING PACKAGES |"; \
  1490. echo "+-------------------------------+"; \
  1491. cat pkgs.log; \
  1492. exit 33; \
  1493. fi
  1494. # Test application used for testing.
  1495. app1:
  1496. $(call app1_setup)
  1497. # Extra module in app1 used for testing eunit
  1498. define create-module-t
  1499. printf '%s\n' \
  1500. '-module(t).' \
  1501. '-export([succ/1]).' \
  1502. 'succ(N) -> N + 1.' \
  1503. '-ifdef(TEST).' \
  1504. '-include_lib("eunit/include/eunit.hrl").' \
  1505. 'succ_test() ->' \
  1506. ' ?assertEqual(2, succ(1)),' \
  1507. ' os:cmd("echo t >> test-eunit.log").' \
  1508. '-endif.' \
  1509. > app1/src/t.erl
  1510. endef