core_app.mk 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561
  1. # Core: Building applications.
  2. CORE_APP_CASES = appsrc-change asn1 auto-git-id erlc-exclude erlc-opts erlc-opts-filter error generate-erl generate-erl-include generate-erl-prepend hrl hrl-recursive makefile-change mib no-app no-makedep project-mod pt pt-erlc-opts xrl xrl-include yrl yrl-include
  3. CORE_APP_TARGETS = $(addprefix core-app-,$(CORE_APP_CASES))
  4. .PHONY: core-app $(CORE_APP_TARGETS)
  5. core-app: $(CORE_APP_TARGETS)
  6. ifdef LEGACY
  7. core-app-appsrc-change: build clean
  8. $i "Bootstrap a new OTP application named $(APP)"
  9. $t mkdir $(APP)/
  10. $t cp ../erlang.mk $(APP)/
  11. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  12. $i "Build the application"
  13. $t $(MAKE) -C $(APP) $v
  14. $i "Touch the .app.src file; check that only the .app file gets rebuilt"
  15. $t printf "%s\n" $(APP)/ebin/$(APP).app > $(APP)/EXPECT
  16. $t $(SLEEP)
  17. $t touch $(APP)/src/$(APP).app.src
  18. $t $(SLEEP)
  19. $t $(MAKE) -C $(APP) $v
  20. $t find $(APP) -type f -newer $(APP)/src/$(APP).app.src | sort | diff $(APP)/EXPECT -
  21. $t rm $(APP)/EXPECT
  22. endif
  23. core-app-asn1: build clean
  24. $i "Bootstrap a new OTP library named $(APP)"
  25. $t mkdir $(APP)/
  26. $t cp ../erlang.mk $(APP)/
  27. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  28. $i "Download .asn1 files from Erlang/OTP"
  29. $t mkdir $(APP)/asn1/
  30. $t curl -s -o $(APP)/asn1/CAP.asn1 $(OTP_MASTER)/lib/asn1/test/asn1_SUITE_data/CAP.asn1
  31. $t curl -s -o $(APP)/asn1/Def.asn1 $(OTP_MASTER)/lib/asn1/test/asn1_SUITE_data/Def.asn1
  32. $i "Generate .erl files dependent from headers generated by .asn1 files"
  33. $t printf "%s\n" "-module(use_cap)." "-include(\"CAP.hrl\")." > $(APP)/src/use_cap.erl
  34. $t printf "%s\n" "-module(use_def)." "-include(\"Def.hrl\")." > $(APP)/src/use_def.erl
  35. $i "Generate an unrelated .hrl file"
  36. $t mkdir $(APP)/include/
  37. $t touch $(APP)/include/unrelated.hrl
  38. $i "Build the application"
  39. $t $(MAKE) -C $(APP) $v
  40. $i "Check that all compiled files exist"
  41. $t test -f $(APP)/$(APP).d
  42. $t test -f $(APP)/ebin/$(APP).app
  43. $t test -f $(APP)/ebin/CAP.beam
  44. $t test -f $(APP)/ebin/Def.beam
  45. $t test -f $(APP)/ebin/use_cap.beam
  46. $t test -f $(APP)/ebin/use_def.beam
  47. $t test -f $(APP)/include/CAP.asn1db
  48. $t test -f $(APP)/include/CAP.hrl
  49. $t test -f $(APP)/include/Def.asn1db
  50. $t test -f $(APP)/include/Def.hrl
  51. $t test -f $(APP)/src/CAP.erl
  52. $t test -f $(APP)/src/Def.erl
  53. $i "Check that the application was compiled correctly"
  54. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  55. ok = application:start($(APP)), \
  56. {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
  57. = application:get_key($(APP), modules), \
  58. [{module, M} = code:load_file(M) || M <- Mods], \
  59. halt()"
  60. $i "Touch one .asn1 file; check that only required files are rebuilt"
  61. # The use_cap.erl gets touched because of its dependency to CAP.hrl.
  62. $t printf "%s\n" \
  63. $(APP)/$(APP).d \
  64. $(APP)/ebin/$(APP).app \
  65. $(APP)/ebin/CAP.beam \
  66. $(APP)/ebin/use_cap.beam \
  67. $(APP)/include/CAP.asn1db \
  68. $(APP)/include/CAP.hrl \
  69. $(APP)/src/CAP.erl \
  70. $(APP)/src/use_cap.erl | sort > $(APP)/EXPECT
  71. $t $(SLEEP)
  72. $t touch $(APP)/asn1/CAP.asn1
  73. $t $(SLEEP)
  74. $t $(MAKE) -C $(APP) $v
  75. $t find $(APP) -type f -newer $(APP)/asn1/CAP.asn1 | sort | diff $(APP)/EXPECT -
  76. $t rm $(APP)/EXPECT
  77. $i "Check that the application was compiled correctly"
  78. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  79. ok = application:start($(APP)), \
  80. {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
  81. = application:get_key($(APP), modules), \
  82. [{module, M} = code:load_file(M) || M <- Mods], \
  83. halt()"
  84. $i "Clean the application"
  85. $t $(MAKE) -C $(APP) clean $v
  86. $i "Check that source files still exist"
  87. $t test -f $(APP)/Makefile
  88. $t test -f $(APP)/erlang.mk
  89. $t test -f $(APP)/asn1/CAP.asn1
  90. $t test -f $(APP)/asn1/Def.asn1
  91. $t test -f $(APP)/include/unrelated.hrl
  92. ifdef LEGACY
  93. $t test -f $(APP)/src/$(APP).app.src
  94. endif
  95. $t test -f $(APP)/src/use_cap.erl
  96. $t test -f $(APP)/src/use_def.erl
  97. $i "Check that all build artifacts are removed, including intermediates"
  98. $t test ! -e $(APP)/$(APP).d
  99. $t test ! -e $(APP)/ebin/
  100. $t test ! -e $(APP)/include/CAP.asn1db
  101. $t test ! -e $(APP)/include/CAP.hrl
  102. $t test ! -e $(APP)/include/Def.asn1db
  103. $t test ! -e $(APP)/include/Def.hrl
  104. $t test ! -e $(APP)/src/CAP.erl
  105. $t test ! -e $(APP)/src/Def.erl
  106. $i "Build the application again"
  107. $t $(MAKE) -C $(APP) $v
  108. $i "Check that all compiled files exist"
  109. $t test -f $(APP)/$(APP).d
  110. $t test -f $(APP)/ebin/$(APP).app
  111. $t test -f $(APP)/ebin/CAP.beam
  112. $t test -f $(APP)/ebin/Def.beam
  113. $t test -f $(APP)/ebin/use_cap.beam
  114. $t test -f $(APP)/ebin/use_def.beam
  115. $t test -f $(APP)/include/CAP.asn1db
  116. $t test -f $(APP)/include/CAP.hrl
  117. $t test -f $(APP)/include/Def.asn1db
  118. $t test -f $(APP)/include/Def.hrl
  119. $t test -f $(APP)/src/CAP.erl
  120. $t test -f $(APP)/src/Def.erl
  121. $i "Check that the application was compiled correctly"
  122. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  123. ok = application:start($(APP)), \
  124. {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
  125. = application:get_key($(APP), modules), \
  126. [{module, M} = code:load_file(M) || M <- Mods], \
  127. halt()"
  128. core-app-auto-git-id: build clean
  129. $i "Bootstrap a new OTP library named $(APP)"
  130. $t mkdir $(APP)/
  131. $t cp ../erlang.mk $(APP)/
  132. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  133. $i "Make it a git repository"
  134. $t cd $(APP) && \
  135. git init -q && \
  136. git config user.email "testsuite@erlang.mk" && \
  137. git config user.name "test suite" && \
  138. git add . && \
  139. git commit -q -m "Tests"
  140. $i "Build the application"
  141. $t $(MAKE) -C $(APP) $v
  142. ifdef LEGACY
  143. # Legacy replaces {id, "git"} always regardless of built as a dependency.
  144. $i "Check that the generated .app file has an id key"
  145. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  146. ok = application:start($(APP)), \
  147. {ok, ID} = application:get_key($(APP), id), \
  148. true = ID =/= [], \
  149. halt()"
  150. else
  151. # If there is no .app.src though, only fill in id when built as a dependency.
  152. $i "Check that the generated .app file has no id key"
  153. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  154. ok = application:start($(APP)), \
  155. {ok, []} = application:get_key($(APP), id), \
  156. halt()"
  157. endif
  158. $i "Clean the application"
  159. $t $(MAKE) -C $(APP) clean $v
  160. $i "Build the application with IS_DEP=1"
  161. $t $(MAKE) -C $(APP) IS_DEP=1 $v
  162. $i "Check that the generated .app file has an id key"
  163. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  164. ok = application:start($(APP)), \
  165. {ok, ID} = application:get_key($(APP), id), \
  166. true = ID =/= [], \
  167. halt()"
  168. core-app-erlc-exclude: build clean
  169. $i "Bootstrap a new OTP library named $(APP)"
  170. $t mkdir $(APP)/
  171. $t cp ../erlang.mk $(APP)/
  172. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  173. $i "Generate .erl files"
  174. $t echo "-module(boy)." > $(APP)/src/boy.erl
  175. $t echo "-module(girl)." > $(APP)/src/girl.erl
  176. $i "Exclude boy.erl from the compilation"
  177. $t echo "ERLC_EXCLUDE = boy" >> $(APP)/Makefile
  178. $i "Build the application"
  179. $t $(MAKE) -C $(APP) $v
  180. $i "Check that boy.erl was not compiled"
  181. $t test ! -e $(APP)/ebin/boy.beam
  182. $i "Check that the application was compiled correctly (without boy.erl)"
  183. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  184. ok = application:start($(APP)), \
  185. {ok, Mods = [girl]} \
  186. = application:get_key($(APP), modules), \
  187. [{module, M} = code:load_file(M) || M <- Mods], \
  188. halt()"
  189. core-app-erlc-opts: build clean
  190. $i "Bootstrap a new OTP library named $(APP)"
  191. $t mkdir $(APP)/
  192. $t cp ../erlang.mk $(APP)/
  193. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  194. $i "Define an empty ERLC_OPTS (without debug_info)"
  195. $t echo "ERLC_OPTS =" >> $(APP)/Makefile
  196. $i "Generate .erl files"
  197. $t echo "-module(boy)." > $(APP)/src/boy.erl
  198. $t echo "-module(girl)." > $(APP)/src/girl.erl
  199. $i "Build the application"
  200. $t $(MAKE) -C $(APP) $v
  201. $i "Check that the application was compiled correctly (without debug_info)"
  202. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  203. ok = application:start($(APP)), \
  204. {ok, Mods = [boy, girl]} \
  205. = application:get_key($(APP), modules), \
  206. [{module, M} = code:load_file(M) || M <- Mods], \
  207. false = proplists:is_defined(debug_info, proplists:get_value(options, boy:module_info(compile))), \
  208. false = proplists:is_defined(debug_info, proplists:get_value(options, girl:module_info(compile))), \
  209. halt()"
  210. core-app-erlc-opts-filter: build clean
  211. $i "Bootstrap a new OTP library named $(APP)"
  212. $t mkdir $(APP)/
  213. $t cp ../erlang.mk $(APP)/
  214. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  215. $i "Define ERLC_OPTS filtering out debug_info"
  216. $t echo "ERLC_OPTS := \$$(filter-out +debug_info,\$$(ERLC_OPTS))" >> $(APP)/Makefile
  217. $i "Generate .erl files"
  218. $t echo "-module(boy)." > $(APP)/src/boy.erl
  219. $t echo "-module(girl)." > $(APP)/src/girl.erl
  220. $i "Build the application"
  221. $t $(MAKE) -C $(APP) $v
  222. $i "Check that the application was compiled correctly (without debug_info)"
  223. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  224. ok = application:start($(APP)), \
  225. {ok, Mods = [boy, girl]} \
  226. = application:get_key($(APP), modules), \
  227. [{module, M} = code:load_file(M) || M <- Mods], \
  228. false = proplists:is_defined(debug_info, proplists:get_value(options, boy:module_info(compile))), \
  229. false = proplists:is_defined(debug_info, proplists:get_value(options, girl:module_info(compile))), \
  230. halt()"
  231. core-app-error: build clean
  232. $i "Bootstrap a new OTP library named $(APP)"
  233. $t mkdir $(APP)/
  234. $t cp ../erlang.mk $(APP)/
  235. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  236. $i "Generate a bad .erl files"
  237. $t touch $(APP)/src/breaking.erl
  238. $i "Generate unrelated .erl files"
  239. $t echo "-module(boy)." > $(APP)/src/boy.erl
  240. $t echo "-module(girl)." > $(APP)/src/girl.erl
  241. $i "Check that trying to build returns non-zero"
  242. $t ! $(MAKE) -C $(APP) $v
  243. core-app-generate-erl: build clean
  244. $i "Bootstrap a new OTP library named $(APP)"
  245. $t mkdir $(APP)/
  246. $t cp ../erlang.mk $(APP)/
  247. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  248. $i "Create a fake script file to be used as dependency"
  249. $t touch $(APP)/script.sh
  250. $i "Append rules to the Makefile to generate a .erl module"
  251. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  252. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@" >> $(APP)/Makefile
  253. $i "Generate unrelated .erl files"
  254. $t echo "-module(boy)." > $(APP)/src/boy.erl
  255. $t echo "-module(girl)." > $(APP)/src/girl.erl
  256. $i "Build the application"
  257. $t $(MAKE) -C $(APP) $v
  258. $i "Check that all compiled files exist"
  259. $t test -f $(APP)/$(APP).d
  260. $t test -f $(APP)/ebin/$(APP).app
  261. $t test -f $(APP)/ebin/boy.beam
  262. $t test -f $(APP)/ebin/generated.beam
  263. $t test -f $(APP)/ebin/girl.beam
  264. $t test -f $(APP)/src/generated.erl
  265. $i "Check that the application was compiled correctly"
  266. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  267. ok = application:start($(APP)), \
  268. {ok, Mods = [boy, generated, girl]} \
  269. = application:get_key($(APP), modules), \
  270. [{module, M} = code:load_file(M) || M <- Mods], \
  271. halt()"
  272. $i "Touch the script file; check that only required files are rebuilt"
  273. $t printf "%s\n" \
  274. $(APP)/$(APP).d \
  275. $(APP)/ebin/$(APP).app \
  276. $(APP)/ebin/generated.beam \
  277. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  278. $t $(SLEEP)
  279. $t touch $(APP)/script.sh
  280. $t $(SLEEP)
  281. $t $(MAKE) -C $(APP) $v
  282. $t find $(APP) -type f -newer $(APP)/script.sh | sort | diff $(APP)/EXPECT -
  283. $t rm $(APP)/EXPECT
  284. $i "Check that the application was compiled correctly"
  285. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  286. ok = application:start($(APP)), \
  287. {ok, Mods = [boy, generated, girl]} \
  288. = application:get_key($(APP), modules), \
  289. [{module, M} = code:load_file(M) || M <- Mods], \
  290. halt()"
  291. $i "Clean the application"
  292. $t $(MAKE) -C $(APP) clean $v
  293. $i "Check that source files still exist"
  294. $t test -f $(APP)/Makefile
  295. $t test -f $(APP)/erlang.mk
  296. $t test -f $(APP)/script.sh
  297. ifdef LEGACY
  298. $t test -f $(APP)/src/$(APP).app.src
  299. endif
  300. $t test -f $(APP)/src/boy.erl
  301. $t test -f $(APP)/src/girl.erl
  302. $i "Check that the generated .erl file still exists"
  303. $t test -f $(APP)/src/generated.erl
  304. $i "Check that all build artifacts are removed"
  305. $t test ! -e $(APP)/$(APP).d
  306. $t test ! -e $(APP)/ebin/
  307. $i "Add a rule to remove the generated .erl file on clean"
  308. $t echo "clean:: ; rm src/generated.erl" >> $(APP)/Makefile
  309. $i "Clean the application again"
  310. $t $(MAKE) -C $(APP) clean $v
  311. $i "Check that the generated .erl file was removed"
  312. $t test ! -e $(APP)/src/generated.erl
  313. $i "Build the application again"
  314. $t $(MAKE) -C $(APP) $v
  315. $i "Check that all compiled files exist"
  316. $t test -f $(APP)/$(APP).d
  317. $t test -f $(APP)/ebin/$(APP).app
  318. $t test -f $(APP)/ebin/boy.beam
  319. $t test -f $(APP)/ebin/generated.beam
  320. $t test -f $(APP)/ebin/girl.beam
  321. $t test -f $(APP)/src/generated.erl
  322. $i "Check that the application was compiled correctly"
  323. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  324. ok = application:start($(APP)), \
  325. {ok, Mods = [boy, generated, girl]} \
  326. = application:get_key($(APP), modules), \
  327. [{module, M} = code:load_file(M) || M <- Mods], \
  328. halt()"
  329. core-app-generate-erl-include: build clean
  330. $i "Bootstrap a new OTP library named $(APP)"
  331. $t mkdir $(APP)/
  332. $t cp ../erlang.mk $(APP)/
  333. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  334. $i "Create a fake script file to be used as dependency"
  335. $t touch $(APP)/script.sh
  336. $i "Append rules to the Makefile to generate a .erl module"
  337. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  338. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@; echo \"-include(\\\"included.hrl\\\").\" >> \$$@" >> $(APP)/Makefile
  339. $i "Generate the .hrl file"
  340. $t mkdir $(APP)/include/
  341. $t touch $(APP)/include/included.hrl
  342. $i "Generate unrelated .erl files"
  343. $t echo "-module(boy)." > $(APP)/src/boy.erl
  344. $t echo "-module(girl)." > $(APP)/src/girl.erl
  345. $i "Build the application"
  346. $t $(MAKE) -C $(APP) $v
  347. $i "Check that all compiled files exist"
  348. $t test -f $(APP)/$(APP).d
  349. $t test -f $(APP)/ebin/$(APP).app
  350. $t test -f $(APP)/ebin/boy.beam
  351. $t test -f $(APP)/ebin/generated.beam
  352. $t test -f $(APP)/ebin/girl.beam
  353. $t test -f $(APP)/src/generated.erl
  354. $i "Check that the application was compiled correctly"
  355. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  356. ok = application:start($(APP)), \
  357. {ok, Mods = [boy, generated, girl]} \
  358. = application:get_key($(APP), modules), \
  359. [{module, M} = code:load_file(M) || M <- Mods], \
  360. halt()"
  361. $i "Touch the .hrl file; check that only required files are rebuilt"
  362. $t printf "%s\n" \
  363. $(APP)/$(APP).d \
  364. $(APP)/ebin/$(APP).app \
  365. $(APP)/ebin/generated.beam \
  366. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  367. $t $(SLEEP)
  368. $t touch $(APP)/include/included.hrl
  369. $t $(SLEEP)
  370. $t $(MAKE) -C $(APP) $v
  371. $t find $(APP) -type f -newer $(APP)/include/included.hrl | sort | diff $(APP)/EXPECT -
  372. $t rm $(APP)/EXPECT
  373. $i "Check that the application was compiled correctly"
  374. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  375. ok = application:start($(APP)), \
  376. {ok, Mods = [boy, generated, girl]} \
  377. = application:get_key($(APP), modules), \
  378. [{module, M} = code:load_file(M) || M <- Mods], \
  379. halt()"
  380. core-app-generate-erl-prepend: build clean
  381. $i "Bootstrap a new OTP library named $(APP)"
  382. $t mkdir $(APP)/
  383. $t cp ../erlang.mk $(APP)/
  384. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  385. $i "Create a fake script file to be used as dependency"
  386. $t touch $(APP)/script.sh
  387. $i "Generate a Makefile and prepend rules that generate a .erl module"
  388. $t echo "PROJECT = $(APP)" > $(APP)/Makefile
  389. $t echo ".DEFAULT_GOAL = all" >> $(APP)/Makefile
  390. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  391. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@" >> $(APP)/Makefile
  392. $t echo "include erlang.mk" >> $(APP)/Makefile
  393. $i "Generate unrelated .erl files"
  394. $t echo "-module(boy)." > $(APP)/src/boy.erl
  395. $t echo "-module(girl)." > $(APP)/src/girl.erl
  396. $i "Build the application"
  397. $t $(MAKE) -C $(APP) $v
  398. $i "Check that all compiled files exist"
  399. $t test -f $(APP)/$(APP).d
  400. $t test -f $(APP)/ebin/$(APP).app
  401. $t test -f $(APP)/ebin/boy.beam
  402. $t test -f $(APP)/ebin/generated.beam
  403. $t test -f $(APP)/ebin/girl.beam
  404. $t test -f $(APP)/src/generated.erl
  405. $i "Check that the application was compiled correctly"
  406. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  407. ok = application:start($(APP)), \
  408. {ok, Mods = [boy, generated, girl]} \
  409. = application:get_key($(APP), modules), \
  410. [{module, M} = code:load_file(M) || M <- Mods], \
  411. halt()"
  412. $i "Touch the script file; check that only required files are rebuilt"
  413. $t printf "%s\n" \
  414. $(APP)/$(APP).d \
  415. $(APP)/ebin/$(APP).app \
  416. $(APP)/ebin/generated.beam \
  417. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  418. $t $(SLEEP)
  419. $t touch $(APP)/script.sh
  420. $t $(SLEEP)
  421. $t $(MAKE) -C $(APP) $v
  422. $t find $(APP) -type f -newer $(APP)/script.sh | sort | diff $(APP)/EXPECT -
  423. $t rm $(APP)/EXPECT
  424. $i "Check that the application was compiled correctly"
  425. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  426. ok = application:start($(APP)), \
  427. {ok, Mods = [boy, generated, girl]} \
  428. = application:get_key($(APP), modules), \
  429. [{module, M} = code:load_file(M) || M <- Mods], \
  430. halt()"
  431. $i "Clean the application"
  432. $t $(MAKE) -C $(APP) clean $v
  433. $i "Check that source files still exist"
  434. $t test -f $(APP)/Makefile
  435. $t test -f $(APP)/erlang.mk
  436. $t test -f $(APP)/script.sh
  437. ifdef LEGACY
  438. $t test -f $(APP)/src/$(APP).app.src
  439. endif
  440. $t test -f $(APP)/src/boy.erl
  441. $t test -f $(APP)/src/girl.erl
  442. $i "Check that the generated .erl file still exists"
  443. $t test -f $(APP)/src/generated.erl
  444. $i "Check that all build artifacts are removed"
  445. $t test ! -e $(APP)/$(APP).d
  446. $t test ! -e $(APP)/ebin/
  447. $i "Add a rule to remove the generated .erl file on clean"
  448. $t echo "clean:: ; rm src/generated.erl" >> $(APP)/Makefile
  449. $i "Clean the application again"
  450. $t $(MAKE) -C $(APP) clean $v
  451. $i "Check that the generated .erl file was removed"
  452. $t test ! -e $(APP)/src/generated.erl
  453. $i "Build the application again"
  454. $t $(MAKE) -C $(APP) $v
  455. $i "Check that all compiled files exist"
  456. $t test -f $(APP)/$(APP).d
  457. $t test -f $(APP)/ebin/$(APP).app
  458. $t test -f $(APP)/ebin/boy.beam
  459. $t test -f $(APP)/ebin/generated.beam
  460. $t test -f $(APP)/ebin/girl.beam
  461. $t test -f $(APP)/src/generated.erl
  462. $i "Check that the application was compiled correctly"
  463. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  464. ok = application:start($(APP)), \
  465. {ok, Mods = [boy, generated, girl]} \
  466. = application:get_key($(APP), modules), \
  467. [{module, M} = code:load_file(M) || M <- Mods], \
  468. halt()"
  469. core-app-hrl: build clean
  470. $i "Bootstrap a new OTP library named $(APP)"
  471. $t mkdir $(APP)/
  472. $t cp ../erlang.mk $(APP)/
  473. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  474. $i "Generate .hrl files"
  475. $t mkdir $(APP)/include/
  476. $t touch $(APP)/include/blue.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 one .hrl file; check that only required files are rebuilt"
  495. # The use_red.erl gets touched because of its dependency to red.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 $(SLEEP)
  502. $t touch $(APP)/include/red.hrl
  503. $t $(SLEEP)
  504. $t $(MAKE) -C $(APP) $v
  505. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  506. $t rm $(APP)/EXPECT
  507. $i "Check that the application was compiled correctly"
  508. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  509. ok = application:start($(APP)), \
  510. {ok, Mods = [use_blue, use_red]} \
  511. = application:get_key($(APP), modules), \
  512. [{module, M} = code:load_file(M) || M <- Mods], \
  513. halt()"
  514. $i "Clean the application"
  515. $t $(MAKE) -C $(APP) clean $v
  516. $i "Check that source files still exist"
  517. $t test -f $(APP)/Makefile
  518. $t test -f $(APP)/erlang.mk
  519. $t test -f $(APP)/include/blue.hrl
  520. $t test -f $(APP)/include/red.hrl
  521. ifdef LEGACY
  522. $t test -f $(APP)/src/$(APP).app.src
  523. endif
  524. $t test -f $(APP)/src/use_blue.erl
  525. $t test -f $(APP)/src/use_red.erl
  526. $i "Check that all build artifacts are removed"
  527. $t test ! -e $(APP)/$(APP).d
  528. $t test ! -e $(APP)/ebin/
  529. $i "Build the application again"
  530. $t $(MAKE) -C $(APP) $v
  531. $i "Check that all compiled files exist"
  532. $t test -f $(APP)/$(APP).d
  533. $t test -f $(APP)/ebin/$(APP).app
  534. $t test -f $(APP)/ebin/use_blue.beam
  535. $t test -f $(APP)/ebin/use_red.beam
  536. $i "Check that the application was compiled correctly"
  537. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  538. ok = application:start($(APP)), \
  539. {ok, Mods = [use_blue, use_red]} \
  540. = application:get_key($(APP), modules), \
  541. [{module, M} = code:load_file(M) || M <- Mods], \
  542. halt()"
  543. core-app-hrl-recursive: build clean
  544. $i "Bootstrap a new OTP library named $(APP)"
  545. $t mkdir $(APP)/
  546. $t cp ../erlang.mk $(APP)/
  547. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  548. $i "Generate .hrl files"
  549. $t mkdir $(APP)/include/
  550. $t touch $(APP)/include/blue.hrl $(APP)/include/pill.hrl
  551. $t echo "-include(\"pill.hrl\")." > $(APP)/include/red.hrl
  552. $i "Generate .erl files dependent from headers"
  553. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  554. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  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_blue.beam
  561. $t test -f $(APP)/ebin/use_red.beam
  562. $i "Check that the application was compiled correctly"
  563. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  564. ok = application:start($(APP)), \
  565. {ok, Mods = [use_blue, use_red]} \
  566. = application:get_key($(APP), modules), \
  567. [{module, M} = code:load_file(M) || M <- Mods], \
  568. halt()"
  569. $i "Touch the deepest .hrl file; check that only required files are rebuilt"
  570. # The use_red.erl gets touched because of its dependency to red.hrl and pill.hrl.
  571. $t printf "%s\n" \
  572. $(APP)/$(APP).d \
  573. $(APP)/ebin/$(APP).app \
  574. $(APP)/ebin/use_red.beam \
  575. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  576. $t $(SLEEP)
  577. $t touch $(APP)/include/pill.hrl
  578. $t $(SLEEP)
  579. $t $(MAKE) -C $(APP) $v
  580. $t find $(APP) -type f -newer $(APP)/include/pill.hrl | sort | diff $(APP)/EXPECT -
  581. $t rm $(APP)/EXPECT
  582. $i "Check that the application was compiled correctly"
  583. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  584. ok = application:start($(APP)), \
  585. {ok, Mods = [use_blue, use_red]} \
  586. = application:get_key($(APP), modules), \
  587. [{module, M} = code:load_file(M) || M <- Mods], \
  588. halt()"
  589. $i "Clean the application"
  590. $t $(MAKE) -C $(APP) clean $v
  591. $i "Check that source files still exist"
  592. $t test -f $(APP)/Makefile
  593. $t test -f $(APP)/erlang.mk
  594. $t test -f $(APP)/include/blue.hrl
  595. $t test -f $(APP)/include/pill.hrl
  596. $t test -f $(APP)/include/red.hrl
  597. ifdef LEGACY
  598. $t test -f $(APP)/src/$(APP).app.src
  599. endif
  600. $t test -f $(APP)/src/use_blue.erl
  601. $t test -f $(APP)/src/use_red.erl
  602. $i "Check that all build artifacts are removed"
  603. $t test ! -e $(APP)/$(APP).d
  604. $t test ! -e $(APP)/ebin/
  605. $i "Build the application again"
  606. $t $(MAKE) -C $(APP) $v
  607. $i "Check that all compiled files exist"
  608. $t test -f $(APP)/$(APP).d
  609. $t test -f $(APP)/ebin/$(APP).app
  610. $t test -f $(APP)/ebin/use_blue.beam
  611. $t test -f $(APP)/ebin/use_red.beam
  612. $i "Check that the application was compiled correctly"
  613. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  614. ok = application:start($(APP)), \
  615. {ok, Mods = [use_blue, use_red]} \
  616. = application:get_key($(APP), modules), \
  617. [{module, M} = code:load_file(M) || M <- Mods], \
  618. halt()"
  619. core-app-makefile-change: build clean
  620. $i "Bootstrap a new OTP application named $(APP)"
  621. $t mkdir $(APP)/
  622. $t cp ../erlang.mk $(APP)/
  623. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  624. $i "Build the application"
  625. $t $(MAKE) -C $(APP) $v
  626. $i "Touch the Makefile; check that all files get rebuilt"
  627. $t printf "%s\n" \
  628. $(APP)/$(APP).d \
  629. $(APP)/ebin/$(APP).app \
  630. $(APP)/ebin/$(APP)_app.beam \
  631. $(APP)/ebin/$(APP)_sup.beam \
  632. $(APP)/src/$(APP)_app.erl \
  633. $(APP)/src/$(APP)_sup.erl | sort > $(APP)/EXPECT
  634. $t $(SLEEP)
  635. $t touch $(APP)/Makefile
  636. $t $(SLEEP)
  637. $t $(MAKE) -C $(APP) $v
  638. $t find $(APP) -type f -newer $(APP)/Makefile | sort | diff $(APP)/EXPECT -
  639. $t rm $(APP)/EXPECT
  640. core-app-mib: build clean
  641. $i "Bootstrap a new OTP library named $(APP)"
  642. $t mkdir $(APP)/
  643. $t cp ../erlang.mk $(APP)/
  644. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  645. $i "Download .mib files from Erlang/OTP"
  646. $t mkdir $(APP)/mibs/
  647. $t curl -s -o $(APP)/mibs/EX1-MIB.mib $(OTP_MASTER)/lib/snmp/examples/ex1/EX1-MIB.mib
  648. $t curl -s -o $(APP)/mibs/OTP-REG.mib $(OTP_MASTER)/lib/otp_mibs/mibs/OTP-REG.mib
  649. $i "Generate .erl files dependent from headers generated by .mib files"
  650. $t printf "%s\n" "-module(use_v1)." "-include(\"EX1-MIB.hrl\")." > $(APP)/src/use_v1.erl
  651. $t printf "%s\n" "-module(use_v2)." "-include(\"OTP-REG.hrl\")." > $(APP)/src/use_v2.erl
  652. $i "Generate an unrelated .hrl file"
  653. $t mkdir $(APP)/include/
  654. $t touch $(APP)/include/unrelated.hrl
  655. $i "Build the application"
  656. $t $(MAKE) -C $(APP) $v
  657. $i "Check that all compiled files exist"
  658. $t test -f $(APP)/$(APP).d
  659. $t test -f $(APP)/ebin/$(APP).app
  660. $t test -f $(APP)/ebin/use_v1.beam
  661. $t test -f $(APP)/ebin/use_v2.beam
  662. $t test -f $(APP)/include/EX1-MIB.hrl
  663. $t test -f $(APP)/include/OTP-REG.hrl
  664. $t test -f $(APP)/priv/mibs/EX1-MIB.bin
  665. $t test -f $(APP)/priv/mibs/OTP-REG.bin
  666. $i "Check that the application was compiled correctly"
  667. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  668. ok = application:start($(APP)), \
  669. {ok, Mods = [use_v1, use_v2]} \
  670. = application:get_key($(APP), modules), \
  671. [{module, M} = code:load_file(M) || M <- Mods], \
  672. halt()"
  673. $i "Touch one .mib file; check that only required files are rebuilt"
  674. # The use_v1.erl gets touched because of its dependency to EX1-MIB.hrl.
  675. $t printf "%s\n" \
  676. $(APP)/$(APP).d \
  677. $(APP)/ebin/$(APP).app \
  678. $(APP)/ebin/use_v1.beam \
  679. $(APP)/include/EX1-MIB.hrl \
  680. $(APP)/priv/mibs/EX1-MIB.bin \
  681. $(APP)/src/use_v1.erl | sort > $(APP)/EXPECT
  682. $t $(SLEEP)
  683. $t touch $(APP)/mibs/EX1-MIB.mib
  684. $t $(SLEEP)
  685. $t $(MAKE) -C $(APP) $v
  686. $t find $(APP) -type f -newer $(APP)/mibs/EX1-MIB.mib | sort | diff $(APP)/EXPECT -
  687. $t rm $(APP)/EXPECT
  688. $i "Check that the application was compiled correctly"
  689. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  690. ok = application:start($(APP)), \
  691. {ok, Mods = [use_v1, use_v2]} \
  692. = application:get_key($(APP), modules), \
  693. [{module, M} = code:load_file(M) || M <- Mods], \
  694. halt()"
  695. $i "Clean the application"
  696. $t $(MAKE) -C $(APP) clean $v
  697. $i "Check that source files still exist"
  698. $t test -f $(APP)/Makefile
  699. $t test -f $(APP)/erlang.mk
  700. $t test -f $(APP)/include/unrelated.hrl
  701. $t test -f $(APP)/mibs/EX1-MIB.mib
  702. $t test -f $(APP)/mibs/OTP-REG.mib
  703. ifdef LEGACY
  704. $t test -f $(APP)/src/$(APP).app.src
  705. endif
  706. $t test -f $(APP)/src/use_v1.erl
  707. $t test -f $(APP)/src/use_v2.erl
  708. $i "Check that all build artifacts are removed, including intermediates"
  709. $t test ! -e $(APP)/$(APP).d
  710. $t test ! -e $(APP)/ebin/
  711. $t test ! -e $(APP)/include/EX1-MIB.hrl
  712. $t test ! -e $(APP)/include/OTP-REG.hrl
  713. $t test ! -e $(APP)/priv/mibs/
  714. $i "Build the application again"
  715. $t $(MAKE) -C $(APP) $v
  716. $i "Check that all compiled files exist"
  717. $t test -f $(APP)/$(APP).d
  718. $t test -f $(APP)/ebin/$(APP).app
  719. $t test -f $(APP)/ebin/use_v1.beam
  720. $t test -f $(APP)/ebin/use_v2.beam
  721. $t test -f $(APP)/include/EX1-MIB.hrl
  722. $t test -f $(APP)/include/OTP-REG.hrl
  723. $t test -f $(APP)/priv/mibs/EX1-MIB.bin
  724. $t test -f $(APP)/priv/mibs/OTP-REG.bin
  725. $i "Check that the application was compiled correctly"
  726. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  727. ok = application:start($(APP)), \
  728. {ok, Mods = [use_v1, use_v2]} \
  729. = application:get_key($(APP), modules), \
  730. [{module, M} = code:load_file(M) || M <- Mods], \
  731. halt()"
  732. core-app-no-app: build clean
  733. $i "Bootstrap a project without an OTP library"
  734. $t mkdir $(APP)/
  735. $t cp ../erlang.mk $(APP)/
  736. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  737. $t rm -rf $(APP)/src
  738. $i "Build the project"
  739. $t $(MAKE) -C $(APP) $v
  740. core-app-no-makedep: build clean
  741. $i "Bootstrap a new OTP library named $(APP)"
  742. $t mkdir $(APP)/
  743. $t cp ../erlang.mk $(APP)/
  744. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  745. $i "Set NO_MAKEDEP ?= 1 in the Makefile"
  746. $t perl -ni.bak -e 'print;if ($$.==1) {print "NO_MAKEDEP ?= 1\n"}' $(APP)/Makefile
  747. $i "Generate .hrl files"
  748. $t mkdir $(APP)/include/
  749. $t touch $(APP)/include/blue.hrl $(APP)/include/red.hrl
  750. $i "Generate .erl files dependent from headers"
  751. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  752. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  753. $i "Build the application"
  754. $t $(MAKE) -C $(APP) $v
  755. $i "Check that all compiled files exist"
  756. $t test -f $(APP)/$(APP).d
  757. $t test -f $(APP)/ebin/$(APP).app
  758. $t test -f $(APP)/ebin/use_blue.beam
  759. $t test -f $(APP)/ebin/use_red.beam
  760. $i "Check that the application was compiled correctly"
  761. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  762. ok = application:start($(APP)), \
  763. {ok, Mods = [use_blue, use_red]} \
  764. = application:get_key($(APP), modules), \
  765. [{module, M} = code:load_file(M) || M <- Mods], \
  766. halt()"
  767. $i "Touch one .hrl file; check that only required files are rebuilt"
  768. # The use_red.erl gets touched because of its dependency to red.hrl.
  769. $t printf "%s\n" \
  770. $(APP)/ebin/$(APP).app \
  771. $(APP)/ebin/use_red.beam \
  772. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  773. $t $(SLEEP)
  774. $t touch $(APP)/include/red.hrl
  775. $t $(SLEEP)
  776. $t $(MAKE) -C $(APP) $v
  777. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  778. $t rm $(APP)/EXPECT
  779. $i "Check that the application was compiled correctly"
  780. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  781. ok = application:start($(APP)), \
  782. {ok, Mods = [use_blue, use_red]} \
  783. = application:get_key($(APP), modules), \
  784. [{module, M} = code:load_file(M) || M <- Mods], \
  785. halt()"
  786. $i "Touch one .hrl file; disable NO_MAKEDEP and check that only required files are rebuilt"
  787. # The use_red.erl gets touched because of its dependency to red.hrl.
  788. $t printf "%s\n" \
  789. $(APP)/$(APP).d \
  790. $(APP)/ebin/$(APP).app \
  791. $(APP)/ebin/use_red.beam \
  792. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  793. $t $(SLEEP)
  794. $t touch $(APP)/include/red.hrl
  795. $t $(SLEEP)
  796. $t NO_MAKEDEP= $(MAKE) -C $(APP) $v
  797. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  798. $t rm $(APP)/EXPECT
  799. $i "Check that the application was compiled correctly"
  800. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  801. ok = application:start($(APP)), \
  802. {ok, Mods = [use_blue, use_red]} \
  803. = application:get_key($(APP), modules), \
  804. [{module, M} = code:load_file(M) || M <- Mods], \
  805. halt()"
  806. $i "Clean the application"
  807. $t $(MAKE) -C $(APP) clean $v
  808. $i "Check that source files still exist"
  809. $t test -f $(APP)/Makefile
  810. $t test -f $(APP)/erlang.mk
  811. $t test -f $(APP)/include/blue.hrl
  812. $t test -f $(APP)/include/red.hrl
  813. ifdef LEGACY
  814. $t test -f $(APP)/src/$(APP).app.src
  815. endif
  816. $t test -f $(APP)/src/use_blue.erl
  817. $t test -f $(APP)/src/use_red.erl
  818. $i "Check that all build artifacts are removed"
  819. $t test ! -e $(APP)/$(APP).d
  820. $t test ! -e $(APP)/ebin/
  821. $i "Build the application again"
  822. $t $(MAKE) -C $(APP) $v
  823. $i "Check that all compiled files exist"
  824. $t test -f $(APP)/$(APP).d
  825. $t test -f $(APP)/ebin/$(APP).app
  826. $t test -f $(APP)/ebin/use_blue.beam
  827. $t test -f $(APP)/ebin/use_red.beam
  828. $i "Check that the application was compiled correctly"
  829. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  830. ok = application:start($(APP)), \
  831. {ok, Mods = [use_blue, use_red]} \
  832. = application:get_key($(APP), modules), \
  833. [{module, M} = code:load_file(M) || M <- Mods], \
  834. halt()"
  835. core-app-project-mod: build clean
  836. $i "Bootstrap a new OTP library named $(APP)"
  837. $t mkdir $(APP)/
  838. $t cp ../erlang.mk $(APP)/
  839. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  840. $i "Generate an application module"
  841. $t printf "%s\n" \
  842. "-module(app_mod)." \
  843. "-export([start/2, stop/1])." \
  844. "start(_StartType, _StartArgs) -> {ok, self()}." \
  845. "stop(_State) -> ok." > $(APP)/src/app_mod.erl
  846. $i "Build the application with PROJECT_MOD"
  847. $t $(MAKE) -C $(APP) PROJECT_MOD=app_mod $v
  848. $i "Check that the application starts correctly"
  849. $t $(ERL) -pa $(APP)/ebin/ -eval "ok = application:start($(APP)), halt()"
  850. core-app-pt: build clean
  851. $i "Bootstrap a new OTP library named $(APP)"
  852. $t mkdir $(APP)/
  853. $t cp ../erlang.mk $(APP)/
  854. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  855. $i "Generate a parse_transform module"
  856. $t printf "%s\n" \
  857. "-module(my_pt)." \
  858. "-export([parse_transform/2])." \
  859. "parse_transform(Forms, _) ->" \
  860. " io:format(\"*** Running my_pt parse_transform.~n\")," \
  861. " Forms." > $(APP)/src/my_pt.erl
  862. $i "Generate a .erl file that uses the my_pt parse_transform"
  863. $t printf "%s\n" \
  864. "-module(my_user)." \
  865. "-compile({parse_transform, my_pt})." > $(APP)/src/my_user.erl
  866. $i "Compile my_pt first"
  867. $t echo "COMPILE_FIRST += my_pt" >> $(APP)/Makefile
  868. $i "Build the application; confirm the parse_transform is used"
  869. $t $(MAKE) -C $(APP) | grep "Running my_pt parse_transform."
  870. $i "Check that the application was compiled correctly"
  871. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  872. ok = application:start($(APP)), \
  873. {ok, Mods = [my_pt, my_user]} = application:get_key($(APP), modules), \
  874. [{module, M} = code:load_file(M) || M <- Mods], \
  875. halt()"
  876. core-app-pt-erlc-opts: build clean
  877. $i "Bootstrap a new OTP library named $(APP)"
  878. $t mkdir $(APP)/
  879. $t cp ../erlang.mk $(APP)/
  880. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  881. $i "Bootstrap a new OTP library in $(APP)/deps/my_pt_dep"
  882. $t mkdir -p $(APP)/deps/my_pt_dep/
  883. $t cp ../erlang.mk $(APP)/deps/my_pt_dep/
  884. $t $(MAKE) -C $(APP)/deps/my_pt_dep/ -f erlang.mk bootstrap-lib $v
  885. $i "Generate a parse_transform module in my_pt_dep"
  886. $t printf "%s\n" \
  887. "-module(my_pt)." \
  888. "-export([parse_transform/2])." \
  889. "parse_transform(Forms, _) ->" \
  890. " io:format(\"*** Running my_pt parse_transform.~n\")," \
  891. " Forms." > $(APP)/deps/my_pt_dep/src/my_pt.erl
  892. $i "Add my_pt_dep to the list of dependencies"
  893. $t perl -ni.bak -e 'print;if ($$.==1) {print "BUILD_DEPS = my_pt_dep\n"}' $(APP)/Makefile
  894. $i "Generate .erl files"
  895. $t echo "-module(boy)." > $(APP)/src/boy.erl
  896. $t echo "-module(girl)." > $(APP)/src/girl.erl
  897. $i "Add the my_pt parse_transform to ERLC_OPTS"
  898. $t echo "ERLC_OPTS += +'{parse_transform, my_pt}'" >> $(APP)/Makefile
  899. $i "Build the application; confirm the parse_transform is used"
  900. $t $(MAKE) -C $(APP) | grep "Running my_pt parse_transform."
  901. $i "Check that the application was compiled correctly"
  902. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  903. ok = application:start($(APP)), \
  904. {ok, Mods = [boy, girl]} = application:get_key($(APP), modules), \
  905. [{module, M} = code:load_file(M) || M <- Mods], \
  906. halt()"
  907. core-app-xrl: build clean
  908. $i "Bootstrap a new OTP library named $(APP)"
  909. $t mkdir $(APP)/
  910. $t cp ../erlang.mk $(APP)/
  911. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  912. $i "Download .xrl files from Robert"
  913. $t curl -s -o $(APP)/src/erlang_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/erlang_scan.xrl
  914. $t curl -s -o $(APP)/src/lfe_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/lfe_scan.xrl
  915. $i "Generate unrelated .erl files"
  916. $t echo "-module(boy)." > $(APP)/src/boy.erl
  917. $t echo "-module(girl)." > $(APP)/src/girl.erl
  918. $i "Disable warnings; our test .xrl files aren't perfect"
  919. $t echo "ERLC_OPTS=+debug_info" >> $(APP)/Makefile
  920. $i "Build the application"
  921. $t $(MAKE) -C $(APP) $v
  922. $i "Check that all compiled files exist"
  923. $t test -f $(APP)/$(APP).d
  924. $t test -f $(APP)/ebin/$(APP).app
  925. $t test -f $(APP)/ebin/boy.beam
  926. $t test -f $(APP)/ebin/erlang_scan.beam
  927. $t test -f $(APP)/ebin/girl.beam
  928. $t test -f $(APP)/ebin/lfe_scan.beam
  929. $t test -f $(APP)/src/erlang_scan.erl
  930. $t test -f $(APP)/src/lfe_scan.erl
  931. $i "Check that the application was compiled correctly"
  932. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  933. ok = application:start($(APP)), \
  934. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  935. = application:get_key($(APP), modules), \
  936. [{module, M} = code:load_file(M) || M <- Mods], \
  937. halt()"
  938. $i "Touch one .xrl file; check that only required files are rebuilt"
  939. $t printf "%s\n" \
  940. $(APP)/$(APP).d \
  941. $(APP)/ebin/$(APP).app \
  942. $(APP)/ebin/erlang_scan.beam \
  943. $(APP)/src/erlang_scan.erl | sort > $(APP)/EXPECT
  944. $t $(SLEEP)
  945. $t touch $(APP)/src/erlang_scan.xrl
  946. $t $(SLEEP)
  947. $t $(MAKE) -C $(APP) $v
  948. $t find $(APP) -type f -newer $(APP)/src/erlang_scan.xrl | sort | diff $(APP)/EXPECT -
  949. $t rm $(APP)/EXPECT
  950. $i "Check that the application was compiled correctly"
  951. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  952. ok = application:start($(APP)), \
  953. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  954. = application:get_key($(APP), modules), \
  955. [{module, M} = code:load_file(M) || M <- Mods], \
  956. halt()"
  957. $i "Clean the application"
  958. $t $(MAKE) -C $(APP) clean $v
  959. $i "Check that source files still exist"
  960. $t test -f $(APP)/Makefile
  961. $t test -f $(APP)/erlang.mk
  962. ifdef LEGACY
  963. $t test -f $(APP)/src/$(APP).app.src
  964. endif
  965. $t test -f $(APP)/src/boy.erl
  966. $t test -f $(APP)/src/erlang_scan.xrl
  967. $t test -f $(APP)/src/girl.erl
  968. $t test -f $(APP)/src/lfe_scan.xrl
  969. $i "Check that all build artifacts are removed, including intermediates"
  970. $t test ! -e $(APP)/$(APP).d
  971. $t test ! -e $(APP)/ebin/
  972. $t test ! -e $(APP)/src/erlang_scan.erl
  973. $t test ! -e $(APP)/src/lfe_scan.erl
  974. $i "Build the application again"
  975. $t $(MAKE) -C $(APP) $v
  976. $i "Check that all compiled files exist"
  977. $t test -f $(APP)/$(APP).d
  978. $t test -f $(APP)/ebin/$(APP).app
  979. $t test -f $(APP)/ebin/boy.beam
  980. $t test -f $(APP)/ebin/erlang_scan.beam
  981. $t test -f $(APP)/ebin/girl.beam
  982. $t test -f $(APP)/ebin/lfe_scan.beam
  983. $t test -f $(APP)/src/erlang_scan.erl
  984. $t test -f $(APP)/src/lfe_scan.erl
  985. $i "Check that the application was compiled correctly"
  986. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  987. ok = application:start($(APP)), \
  988. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  989. = application:get_key($(APP), modules), \
  990. [{module, M} = code:load_file(M) || M <- Mods], \
  991. halt()"
  992. core-app-xrl-include: build clean
  993. $i "Bootstrap a new OTP library named $(APP)"
  994. $t mkdir $(APP)/
  995. $t cp ../erlang.mk $(APP)/
  996. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  997. $i "Download a .xrl file with numerous includes from Gordon"
  998. $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
  999. $t curl -s -o $(APP)/src/errvals.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/errvals.hrl
  1000. $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
  1001. $t curl -s -o $(APP)/src/muin_records.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/muin_records.hrl
  1002. $t curl -s -o $(APP)/src/typechecks.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/typechecks.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 "Disable warnings; our test .xrl files aren't perfect"
  1007. $t echo "ERLC_OPTS=+debug_info" >> $(APP)/Makefile
  1008. $i "Build the application"
  1009. $t $(MAKE) -C $(APP) $v
  1010. $i "Check that all compiled files exist"
  1011. $t test -f $(APP)/$(APP).d
  1012. $t test -f $(APP)/ebin/$(APP).app
  1013. $t test -f $(APP)/ebin/boy.beam
  1014. $t test -f $(APP)/ebin/girl.beam
  1015. $t test -f $(APP)/ebin/xfl_lexer.beam
  1016. $t test -f $(APP)/src/xfl_lexer.erl
  1017. $i "Check that the application was compiled correctly"
  1018. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1019. ok = application:start($(APP)), \
  1020. {ok, Mods = [boy, girl, xfl_lexer]} \
  1021. = application:get_key($(APP), modules), \
  1022. [{module, M} = code:load_file(M) || M <- Mods], \
  1023. halt()"
  1024. $i "Touch the .xrl file; check that only required files are rebuilt"
  1025. $t printf "%s\n" \
  1026. $(APP)/$(APP).d \
  1027. $(APP)/ebin/$(APP).app \
  1028. $(APP)/ebin/xfl_lexer.beam \
  1029. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  1030. $t $(SLEEP)
  1031. $t touch $(APP)/src/xfl_lexer.xrl
  1032. $t $(SLEEP)
  1033. $t $(MAKE) -C $(APP) $v
  1034. $t find $(APP) -type f -newer $(APP)/src/xfl_lexer.xrl | sort | diff $(APP)/EXPECT -
  1035. $t rm $(APP)/EXPECT
  1036. $i "Check that the application was compiled correctly"
  1037. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1038. ok = application:start($(APP)), \
  1039. {ok, Mods = [boy, girl, xfl_lexer]} \
  1040. = application:get_key($(APP), modules), \
  1041. [{module, M} = code:load_file(M) || M <- Mods], \
  1042. halt()"
  1043. $i "Touch a .hrl file included directly; check that only required files are rebuilt"
  1044. $t printf "%s\n" \
  1045. $(APP)/$(APP).d \
  1046. $(APP)/ebin/$(APP).app \
  1047. $(APP)/ebin/xfl_lexer.beam \
  1048. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  1049. $t $(SLEEP)
  1050. $t touch $(APP)/src/typechecks.hrl
  1051. $t $(SLEEP)
  1052. $t $(MAKE) -C $(APP) $v
  1053. $t find $(APP) -type f -newer $(APP)/src/typechecks.hrl | sort | diff $(APP)/EXPECT -
  1054. $t rm $(APP)/EXPECT
  1055. $i "Check that the application was compiled correctly"
  1056. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1057. ok = application:start($(APP)), \
  1058. {ok, Mods = [boy, girl, xfl_lexer]} \
  1059. = application:get_key($(APP), modules), \
  1060. [{module, M} = code:load_file(M) || M <- Mods], \
  1061. halt()"
  1062. $i "Touch a .hrl file included indirectly; check that only required files are rebuilt"
  1063. $t printf "%s\n" \
  1064. $(APP)/$(APP).d \
  1065. $(APP)/ebin/$(APP).app \
  1066. $(APP)/ebin/xfl_lexer.beam \
  1067. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  1068. $t $(SLEEP)
  1069. $t touch $(APP)/src/errvals.hrl
  1070. $t $(SLEEP)
  1071. $t $(MAKE) -C $(APP) $v
  1072. $t find $(APP) -type f -newer $(APP)/src/errvals.hrl | sort | diff $(APP)/EXPECT -
  1073. $t rm $(APP)/EXPECT
  1074. $i "Check that the application was compiled correctly"
  1075. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1076. ok = application:start($(APP)), \
  1077. {ok, Mods = [boy, girl, xfl_lexer]} \
  1078. = application:get_key($(APP), modules), \
  1079. [{module, M} = code:load_file(M) || M <- Mods], \
  1080. halt()"
  1081. $i "Clean the application"
  1082. $t $(MAKE) -C $(APP) clean $v
  1083. $i "Check that source files still exist"
  1084. $t test -f $(APP)/Makefile
  1085. $t test -f $(APP)/erlang.mk
  1086. ifdef LEGACY
  1087. $t test -f $(APP)/src/$(APP).app.src
  1088. endif
  1089. $t test -f $(APP)/src/boy.erl
  1090. $t test -f $(APP)/src/girl.erl
  1091. $t test -f $(APP)/src/errvals.hrl
  1092. $t test -f $(APP)/src/muin_proc_dict.hrl
  1093. $t test -f $(APP)/src/muin_records.hrl
  1094. $t test -f $(APP)/src/typechecks.hrl
  1095. $t test -f $(APP)/src/xfl_lexer.xrl
  1096. $i "Check that all build artifacts are removed, including intermediates"
  1097. $t test ! -e $(APP)/$(APP).d
  1098. $t test ! -e $(APP)/ebin/
  1099. $t test ! -e $(APP)/src/xfl_lexer.erl
  1100. $i "Build the application again"
  1101. $t $(MAKE) -C $(APP) $v
  1102. $i "Check that all compiled files exist"
  1103. $t test -f $(APP)/$(APP).d
  1104. $t test -f $(APP)/ebin/$(APP).app
  1105. $t test -f $(APP)/ebin/boy.beam
  1106. $t test -f $(APP)/ebin/girl.beam
  1107. $t test -f $(APP)/ebin/xfl_lexer.beam
  1108. $t test -f $(APP)/src/xfl_lexer.erl
  1109. $i "Check that the application was compiled correctly"
  1110. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1111. ok = application:start($(APP)), \
  1112. {ok, Mods = [boy, girl, xfl_lexer]} \
  1113. = application:get_key($(APP), modules), \
  1114. [{module, M} = code:load_file(M) || M <- Mods], \
  1115. halt()"
  1116. core-app-yrl: build clean
  1117. $i "Bootstrap a new OTP library named $(APP)"
  1118. $t mkdir $(APP)/
  1119. $t cp ../erlang.mk $(APP)/
  1120. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1121. $i "Download .yrl files from Erlang/OTP"
  1122. $t curl -s -o $(APP)/src/xmerl_xpath_parse.yrl $(OTP_MASTER)/lib/xmerl/src/xmerl_xpath_parse.yrl
  1123. $t curl -s -o $(APP)/src/xref_parser.yrl $(OTP_MASTER)/lib/tools/src/xref_parser.yrl
  1124. $i "Generate unrelated .erl files"
  1125. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1126. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1127. $i "Build the application"
  1128. $t $(MAKE) -C $(APP) $v
  1129. $i "Check that all compiled files exist"
  1130. $t test -f $(APP)/$(APP).d
  1131. $t test -f $(APP)/ebin/$(APP).app
  1132. $t test -f $(APP)/ebin/boy.beam
  1133. $t test -f $(APP)/ebin/girl.beam
  1134. $t test -f $(APP)/ebin/xmerl_xpath_parse.beam
  1135. $t test -f $(APP)/ebin/xref_parser.beam
  1136. $t test -f $(APP)/src/xmerl_xpath_parse.erl
  1137. $t test -f $(APP)/src/xref_parser.erl
  1138. $i "Check that the application was compiled correctly"
  1139. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1140. ok = application:start($(APP)), \
  1141. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  1142. = application:get_key($(APP), modules), \
  1143. [{module, M} = code:load_file(M) || M <- Mods], \
  1144. halt()"
  1145. $i "Touch one .yrl file; check that only required files are rebuilt"
  1146. $t printf "%s\n" \
  1147. $(APP)/$(APP).d \
  1148. $(APP)/ebin/$(APP).app \
  1149. $(APP)/ebin/xref_parser.beam \
  1150. $(APP)/src/xref_parser.erl | sort > $(APP)/EXPECT
  1151. $t $(SLEEP)
  1152. $t touch $(APP)/src/xref_parser.yrl
  1153. $t $(SLEEP)
  1154. $t $(MAKE) -C $(APP) $v
  1155. $t find $(APP) -type f -newer $(APP)/src/xref_parser.yrl | sort | diff $(APP)/EXPECT -
  1156. $t rm $(APP)/EXPECT
  1157. $i "Check that the application was compiled correctly"
  1158. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1159. ok = application:start($(APP)), \
  1160. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  1161. = application:get_key($(APP), modules), \
  1162. [{module, M} = code:load_file(M) || M <- Mods], \
  1163. halt()"
  1164. $i "Clean the application"
  1165. $t $(MAKE) -C $(APP) clean $v
  1166. $i "Check that source files still exist"
  1167. $t test -f $(APP)/Makefile
  1168. $t test -f $(APP)/erlang.mk
  1169. ifdef LEGACY
  1170. $t test -f $(APP)/src/$(APP).app.src
  1171. endif
  1172. $t test -f $(APP)/src/boy.erl
  1173. $t test -f $(APP)/src/girl.erl
  1174. $t test -f $(APP)/src/xmerl_xpath_parse.yrl
  1175. $t test -f $(APP)/src/xref_parser.yrl
  1176. $i "Check that all build artifacts are removed, including intermediates"
  1177. $t test ! -e $(APP)/$(APP).d
  1178. $t test ! -e $(APP)/ebin/
  1179. $t test ! -e $(APP)/src/xmerl_xpath_parse.erl
  1180. $t test ! -e $(APP)/src/xref_parser.erl
  1181. $i "Build the application again"
  1182. $t $(MAKE) -C $(APP) $v
  1183. $i "Check that all compiled files exist"
  1184. $t test -f $(APP)/$(APP).d
  1185. $t test -f $(APP)/ebin/$(APP).app
  1186. $t test -f $(APP)/ebin/boy.beam
  1187. $t test -f $(APP)/ebin/girl.beam
  1188. $t test -f $(APP)/ebin/xmerl_xpath_parse.beam
  1189. $t test -f $(APP)/ebin/xref_parser.beam
  1190. $t test -f $(APP)/src/xmerl_xpath_parse.erl
  1191. $t test -f $(APP)/src/xref_parser.erl
  1192. $i "Check that the application was compiled correctly"
  1193. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1194. ok = application:start($(APP)), \
  1195. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  1196. = application:get_key($(APP), modules), \
  1197. [{module, M} = code:load_file(M) || M <- Mods], \
  1198. halt()"
  1199. core-app-yrl-include: build clean
  1200. $i "Bootstrap a new OTP library named $(APP)"
  1201. $t mkdir $(APP)/
  1202. $t cp ../erlang.mk $(APP)/
  1203. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1204. $i "Download a .yrl file with includes from Erlang/OTP"
  1205. $t curl -s -o $(APP)/src/core_parse.yrl $(OTP_MASTER)/lib/compiler/src/core_parse.yrl
  1206. $t curl -s -o $(APP)/src/core_parse.hrl $(OTP_MASTER)/lib/compiler/src/core_parse.hrl
  1207. $i "Generate unrelated .erl files"
  1208. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1209. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1210. $i "Build the application"
  1211. $t $(MAKE) -C $(APP) $v
  1212. $i "Check that all compiled files exist"
  1213. $t test -f $(APP)/$(APP).d
  1214. $t test -f $(APP)/ebin/$(APP).app
  1215. $t test -f $(APP)/ebin/boy.beam
  1216. $t test -f $(APP)/ebin/core_parse.beam
  1217. $t test -f $(APP)/ebin/girl.beam
  1218. $t test -f $(APP)/src/core_parse.erl
  1219. $i "Check that the application was compiled correctly"
  1220. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1221. ok = application:start($(APP)), \
  1222. {ok, Mods = [boy, core_parse, girl]} \
  1223. = application:get_key($(APP), modules), \
  1224. [{module, M} = code:load_file(M) || M <- Mods], \
  1225. halt()"
  1226. $i "Touch the .yrl file; check that only required files are rebuilt"
  1227. $t printf "%s\n" \
  1228. $(APP)/$(APP).d \
  1229. $(APP)/ebin/$(APP).app \
  1230. $(APP)/ebin/core_parse.beam \
  1231. $(APP)/src/core_parse.erl | sort > $(APP)/EXPECT
  1232. $t $(SLEEP)
  1233. $t touch $(APP)/src/core_parse.yrl
  1234. $t $(SLEEP)
  1235. $t $(MAKE) -C $(APP) $v
  1236. $t find $(APP) -type f -newer $(APP)/src/core_parse.yrl | sort | diff $(APP)/EXPECT -
  1237. $t rm $(APP)/EXPECT
  1238. $i "Check that the application was compiled correctly"
  1239. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1240. ok = application:start($(APP)), \
  1241. {ok, Mods = [boy, core_parse, girl]} \
  1242. = application:get_key($(APP), modules), \
  1243. [{module, M} = code:load_file(M) || M <- Mods], \
  1244. halt()"
  1245. $i "Touch the .hrl file included; check that only required files are rebuilt"
  1246. $t printf "%s\n" \
  1247. $(APP)/$(APP).d \
  1248. $(APP)/ebin/$(APP).app \
  1249. $(APP)/ebin/core_parse.beam \
  1250. $(APP)/src/core_parse.erl | sort > $(APP)/EXPECT
  1251. $t $(SLEEP)
  1252. $t touch $(APP)/src/core_parse.hrl
  1253. $t $(SLEEP)
  1254. $t $(MAKE) -C $(APP) $v
  1255. $t find $(APP) -type f -newer $(APP)/src/core_parse.hrl | sort | diff $(APP)/EXPECT -
  1256. $t rm $(APP)/EXPECT
  1257. $i "Check that the application was compiled correctly"
  1258. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1259. ok = application:start($(APP)), \
  1260. {ok, Mods = [boy, core_parse, girl]} \
  1261. = application:get_key($(APP), modules), \
  1262. [{module, M} = code:load_file(M) || M <- Mods], \
  1263. halt()"
  1264. $i "Clean the application"
  1265. $t $(MAKE) -C $(APP) clean $v
  1266. $i "Check that source files still exist"
  1267. $t test -f $(APP)/Makefile
  1268. $t test -f $(APP)/erlang.mk
  1269. ifdef LEGACY
  1270. $t test -f $(APP)/src/$(APP).app.src
  1271. endif
  1272. $t test -f $(APP)/src/boy.erl
  1273. $t test -f $(APP)/src/core_parse.hrl
  1274. $t test -f $(APP)/src/core_parse.yrl
  1275. $t test -f $(APP)/src/girl.erl
  1276. $i "Check that all build artifacts are removed, including intermediates"
  1277. $t test ! -e $(APP)/$(APP).d
  1278. $t test ! -e $(APP)/ebin/
  1279. $t test ! -e $(APP)/src/core_parse.erl
  1280. $i "Build the application again"
  1281. $t $(MAKE) -C $(APP) $v
  1282. $i "Check that all compiled files exist"
  1283. $t test -f $(APP)/$(APP).d
  1284. $t test -f $(APP)/ebin/$(APP).app
  1285. $t test -f $(APP)/ebin/boy.beam
  1286. $t test -f $(APP)/ebin/core_parse.beam
  1287. $t test -f $(APP)/ebin/girl.beam
  1288. $t test -f $(APP)/src/core_parse.erl
  1289. $i "Check that the application was compiled correctly"
  1290. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1291. ok = application:start($(APP)), \
  1292. {ok, Mods = [boy, core_parse, girl]} \
  1293. = application:get_key($(APP), modules), \
  1294. [{module, M} = code:load_file(M) || M <- Mods], \
  1295. halt()"