core_app.mk 49 KB

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