core_app.mk 48 KB

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