core_app.mk 49 KB

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