core_app.mk 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661
  1. # Core: Building applications.
  2. CORE_APP_CASES = appsrc-change asn1 auto-git-id env erlc-exclude erlc-opts erlc-opts-filter error generate-erl generate-erl-include generate-erl-prepend hrl hrl-recursive makefile-change mib no-app no-makedep project-mod pt pt-erlc-opts xrl xrl-include yrl yrl-header 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. ifndef LEGACY
  169. core-app-env: build clean
  170. $i "Bootstrap a new OTP library named $(APP)"
  171. $t mkdir $(APP)/
  172. $t cp ../erlang.mk $(APP)/
  173. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  174. $i "Define PROJECT_ENV"
  175. $t echo "PROJECT_ENV = [{test_key, test_value}]" >> $(APP)/Makefile
  176. $i "Build the application"
  177. $t $(MAKE) -C $(APP) $v
  178. $i "Check that the application was compiled correctly"
  179. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  180. ok = application:load($(APP)), \
  181. {ok, test_value} = application:get_env($(APP), test_key), \
  182. halt()"
  183. $i "Define PROJECT_ENV with escape in string, special char"
  184. $t echo "PROJECT_ENV = [{test_atom, '\\\$$\$$test'}, {test_key, \"\\\"test_\\tvalue\\\"\"}]" >> $(APP)/Makefile
  185. $i "Build the application"
  186. $t $(MAKE) -C $(APP) $v
  187. $i "Check that the application was compiled correctly"
  188. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  189. ok = application:load($(APP)), \
  190. {ok, \"\\\"test_\\tvalue\\\"\"} = application:get_env($(APP), test_key), \
  191. {ok, '\\\$$test'} = application:get_env($(APP), test_atom), \
  192. halt()"
  193. endif
  194. core-app-erlc-exclude: build clean
  195. $i "Bootstrap a new OTP library named $(APP)"
  196. $t mkdir $(APP)/
  197. $t cp ../erlang.mk $(APP)/
  198. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  199. $i "Generate .erl files"
  200. $t echo "-module(boy)." > $(APP)/src/boy.erl
  201. $t echo "-module(girl)." > $(APP)/src/girl.erl
  202. $i "Exclude boy.erl from the compilation"
  203. $t echo "ERLC_EXCLUDE = boy" >> $(APP)/Makefile
  204. $i "Build the application"
  205. $t $(MAKE) -C $(APP) $v
  206. $i "Check that boy.erl was not compiled"
  207. $t test ! -e $(APP)/ebin/boy.beam
  208. $i "Check that the application was compiled correctly (without boy.erl)"
  209. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  210. ok = application:start($(APP)), \
  211. {ok, Mods = [girl]} \
  212. = application:get_key($(APP), modules), \
  213. [{module, M} = code:load_file(M) || M <- Mods], \
  214. halt()"
  215. core-app-erlc-opts: build clean
  216. $i "Bootstrap a new OTP library named $(APP)"
  217. $t mkdir $(APP)/
  218. $t cp ../erlang.mk $(APP)/
  219. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  220. $i "Define an empty ERLC_OPTS (without debug_info)"
  221. $t echo "ERLC_OPTS =" >> $(APP)/Makefile
  222. $i "Generate .erl files"
  223. $t echo "-module(boy)." > $(APP)/src/boy.erl
  224. $t echo "-module(girl)." > $(APP)/src/girl.erl
  225. $i "Build the application"
  226. $t $(MAKE) -C $(APP) $v
  227. $i "Check that the application was compiled correctly (without debug_info)"
  228. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  229. ok = application:start($(APP)), \
  230. {ok, Mods = [boy, girl]} \
  231. = application:get_key($(APP), modules), \
  232. [{module, M} = code:load_file(M) || M <- Mods], \
  233. false = proplists:is_defined(debug_info, proplists:get_value(options, boy:module_info(compile))), \
  234. false = proplists:is_defined(debug_info, proplists:get_value(options, girl:module_info(compile))), \
  235. halt()"
  236. core-app-erlc-opts-filter: build clean
  237. $i "Bootstrap a new OTP library named $(APP)"
  238. $t mkdir $(APP)/
  239. $t cp ../erlang.mk $(APP)/
  240. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  241. $i "Define ERLC_OPTS filtering out debug_info"
  242. $t echo "ERLC_OPTS := \$$(filter-out +debug_info,\$$(ERLC_OPTS))" >> $(APP)/Makefile
  243. $i "Generate .erl files"
  244. $t echo "-module(boy)." > $(APP)/src/boy.erl
  245. $t echo "-module(girl)." > $(APP)/src/girl.erl
  246. $i "Build the application"
  247. $t $(MAKE) -C $(APP) $v
  248. $i "Check that the application was compiled correctly (without debug_info)"
  249. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  250. ok = application:start($(APP)), \
  251. {ok, Mods = [boy, girl]} \
  252. = application:get_key($(APP), modules), \
  253. [{module, M} = code:load_file(M) || M <- Mods], \
  254. false = proplists:is_defined(debug_info, proplists:get_value(options, boy:module_info(compile))), \
  255. false = proplists:is_defined(debug_info, proplists:get_value(options, girl:module_info(compile))), \
  256. halt()"
  257. core-app-error: build clean
  258. $i "Bootstrap a new OTP library named $(APP)"
  259. $t mkdir $(APP)/
  260. $t cp ../erlang.mk $(APP)/
  261. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  262. $i "Generate a bad .erl files"
  263. $t touch $(APP)/src/breaking.erl
  264. $i "Generate unrelated .erl files"
  265. $t echo "-module(boy)." > $(APP)/src/boy.erl
  266. $t echo "-module(girl)." > $(APP)/src/girl.erl
  267. $i "Check that trying to build returns non-zero"
  268. $t ! $(MAKE) -C $(APP) $v
  269. core-app-generate-erl: build clean
  270. $i "Bootstrap a new OTP library named $(APP)"
  271. $t mkdir $(APP)/
  272. $t cp ../erlang.mk $(APP)/
  273. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  274. $i "Create a fake script file to be used as dependency"
  275. $t touch $(APP)/script.sh
  276. $i "Append rules to the Makefile to generate a .erl module"
  277. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  278. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@" >> $(APP)/Makefile
  279. $i "Generate unrelated .erl files"
  280. $t echo "-module(boy)." > $(APP)/src/boy.erl
  281. $t echo "-module(girl)." > $(APP)/src/girl.erl
  282. $i "Build the application"
  283. $t $(MAKE) -C $(APP) $v
  284. $i "Check that all compiled files exist"
  285. $t test -f $(APP)/$(APP).d
  286. $t test -f $(APP)/ebin/$(APP).app
  287. $t test -f $(APP)/ebin/boy.beam
  288. $t test -f $(APP)/ebin/generated.beam
  289. $t test -f $(APP)/ebin/girl.beam
  290. $t test -f $(APP)/src/generated.erl
  291. $i "Check that the application was compiled correctly"
  292. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  293. ok = application:start($(APP)), \
  294. {ok, Mods = [boy, generated, girl]} \
  295. = application:get_key($(APP), modules), \
  296. [{module, M} = code:load_file(M) || M <- Mods], \
  297. halt()"
  298. $i "Touch the script file; check that only required files are rebuilt"
  299. $t printf "%s\n" \
  300. $(APP)/$(APP).d \
  301. $(APP)/ebin/$(APP).app \
  302. $(APP)/ebin/generated.beam \
  303. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  304. $t $(SLEEP)
  305. $t touch $(APP)/script.sh
  306. $t $(SLEEP)
  307. $t $(MAKE) -C $(APP) $v
  308. $t find $(APP) -type f -newer $(APP)/script.sh | sort | diff $(APP)/EXPECT -
  309. $t rm $(APP)/EXPECT
  310. $i "Check that the application was compiled correctly"
  311. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  312. ok = application:start($(APP)), \
  313. {ok, Mods = [boy, generated, girl]} \
  314. = application:get_key($(APP), modules), \
  315. [{module, M} = code:load_file(M) || M <- Mods], \
  316. halt()"
  317. $i "Clean the application"
  318. $t $(MAKE) -C $(APP) clean $v
  319. $i "Check that source files still exist"
  320. $t test -f $(APP)/Makefile
  321. $t test -f $(APP)/erlang.mk
  322. $t test -f $(APP)/script.sh
  323. ifdef LEGACY
  324. $t test -f $(APP)/src/$(APP).app.src
  325. endif
  326. $t test -f $(APP)/src/boy.erl
  327. $t test -f $(APP)/src/girl.erl
  328. $i "Check that the generated .erl file still exists"
  329. $t test -f $(APP)/src/generated.erl
  330. $i "Check that all build artifacts are removed"
  331. $t test ! -e $(APP)/$(APP).d
  332. $t test ! -e $(APP)/ebin/
  333. $i "Add a rule to remove the generated .erl file on clean"
  334. $t echo "clean:: ; rm src/generated.erl" >> $(APP)/Makefile
  335. $i "Clean the application again"
  336. $t $(MAKE) -C $(APP) clean $v
  337. $i "Check that the generated .erl file was removed"
  338. $t test ! -e $(APP)/src/generated.erl
  339. $i "Build the application again"
  340. $t $(MAKE) -C $(APP) $v
  341. $i "Check that all compiled files exist"
  342. $t test -f $(APP)/$(APP).d
  343. $t test -f $(APP)/ebin/$(APP).app
  344. $t test -f $(APP)/ebin/boy.beam
  345. $t test -f $(APP)/ebin/generated.beam
  346. $t test -f $(APP)/ebin/girl.beam
  347. $t test -f $(APP)/src/generated.erl
  348. $i "Check that the application was compiled correctly"
  349. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  350. ok = application:start($(APP)), \
  351. {ok, Mods = [boy, generated, girl]} \
  352. = application:get_key($(APP), modules), \
  353. [{module, M} = code:load_file(M) || M <- Mods], \
  354. halt()"
  355. core-app-generate-erl-include: build clean
  356. $i "Bootstrap a new OTP library named $(APP)"
  357. $t mkdir $(APP)/
  358. $t cp ../erlang.mk $(APP)/
  359. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  360. $i "Create a fake script file to be used as dependency"
  361. $t touch $(APP)/script.sh
  362. $i "Append rules to the Makefile to generate a .erl module"
  363. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  364. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@; echo \"-include(\\\"included.hrl\\\").\" >> \$$@" >> $(APP)/Makefile
  365. $i "Generate the .hrl file"
  366. $t mkdir $(APP)/include/
  367. $t touch $(APP)/include/included.hrl
  368. $i "Generate unrelated .erl files"
  369. $t echo "-module(boy)." > $(APP)/src/boy.erl
  370. $t echo "-module(girl)." > $(APP)/src/girl.erl
  371. $i "Build the application"
  372. $t $(MAKE) -C $(APP) $v
  373. $i "Check that all compiled files exist"
  374. $t test -f $(APP)/$(APP).d
  375. $t test -f $(APP)/ebin/$(APP).app
  376. $t test -f $(APP)/ebin/boy.beam
  377. $t test -f $(APP)/ebin/generated.beam
  378. $t test -f $(APP)/ebin/girl.beam
  379. $t test -f $(APP)/src/generated.erl
  380. $i "Check that the application was compiled correctly"
  381. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  382. ok = application:start($(APP)), \
  383. {ok, Mods = [boy, generated, girl]} \
  384. = application:get_key($(APP), modules), \
  385. [{module, M} = code:load_file(M) || M <- Mods], \
  386. halt()"
  387. $i "Touch the .hrl file; check that only required files are rebuilt"
  388. $t printf "%s\n" \
  389. $(APP)/$(APP).d \
  390. $(APP)/ebin/$(APP).app \
  391. $(APP)/ebin/generated.beam \
  392. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  393. $t $(SLEEP)
  394. $t touch $(APP)/include/included.hrl
  395. $t $(SLEEP)
  396. $t $(MAKE) -C $(APP) $v
  397. $t find $(APP) -type f -newer $(APP)/include/included.hrl | sort | diff $(APP)/EXPECT -
  398. $t rm $(APP)/EXPECT
  399. $i "Check that the application was compiled correctly"
  400. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  401. ok = application:start($(APP)), \
  402. {ok, Mods = [boy, generated, girl]} \
  403. = application:get_key($(APP), modules), \
  404. [{module, M} = code:load_file(M) || M <- Mods], \
  405. halt()"
  406. core-app-generate-erl-prepend: build clean
  407. $i "Bootstrap a new OTP library named $(APP)"
  408. $t mkdir $(APP)/
  409. $t cp ../erlang.mk $(APP)/
  410. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  411. $i "Create a fake script file to be used as dependency"
  412. $t touch $(APP)/script.sh
  413. $i "Generate a Makefile and prepend rules that generate a .erl module"
  414. $t echo "PROJECT = $(APP)" > $(APP)/Makefile
  415. $t echo ".DEFAULT_GOAL = all" >> $(APP)/Makefile
  416. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  417. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@" >> $(APP)/Makefile
  418. $t echo "include erlang.mk" >> $(APP)/Makefile
  419. $i "Generate unrelated .erl files"
  420. $t echo "-module(boy)." > $(APP)/src/boy.erl
  421. $t echo "-module(girl)." > $(APP)/src/girl.erl
  422. $i "Build the application"
  423. $t $(MAKE) -C $(APP) $v
  424. $i "Check that all compiled files exist"
  425. $t test -f $(APP)/$(APP).d
  426. $t test -f $(APP)/ebin/$(APP).app
  427. $t test -f $(APP)/ebin/boy.beam
  428. $t test -f $(APP)/ebin/generated.beam
  429. $t test -f $(APP)/ebin/girl.beam
  430. $t test -f $(APP)/src/generated.erl
  431. $i "Check that the application was compiled correctly"
  432. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  433. ok = application:start($(APP)), \
  434. {ok, Mods = [boy, generated, girl]} \
  435. = application:get_key($(APP), modules), \
  436. [{module, M} = code:load_file(M) || M <- Mods], \
  437. halt()"
  438. $i "Touch the script file; check that only required files are rebuilt"
  439. $t printf "%s\n" \
  440. $(APP)/$(APP).d \
  441. $(APP)/ebin/$(APP).app \
  442. $(APP)/ebin/generated.beam \
  443. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  444. $t $(SLEEP)
  445. $t touch $(APP)/script.sh
  446. $t $(SLEEP)
  447. $t $(MAKE) -C $(APP) $v
  448. $t find $(APP) -type f -newer $(APP)/script.sh | sort | diff $(APP)/EXPECT -
  449. $t rm $(APP)/EXPECT
  450. $i "Check that the application was compiled correctly"
  451. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  452. ok = application:start($(APP)), \
  453. {ok, Mods = [boy, generated, girl]} \
  454. = application:get_key($(APP), modules), \
  455. [{module, M} = code:load_file(M) || M <- Mods], \
  456. halt()"
  457. $i "Clean the application"
  458. $t $(MAKE) -C $(APP) clean $v
  459. $i "Check that source files still exist"
  460. $t test -f $(APP)/Makefile
  461. $t test -f $(APP)/erlang.mk
  462. $t test -f $(APP)/script.sh
  463. ifdef LEGACY
  464. $t test -f $(APP)/src/$(APP).app.src
  465. endif
  466. $t test -f $(APP)/src/boy.erl
  467. $t test -f $(APP)/src/girl.erl
  468. $i "Check that the generated .erl file still exists"
  469. $t test -f $(APP)/src/generated.erl
  470. $i "Check that all build artifacts are removed"
  471. $t test ! -e $(APP)/$(APP).d
  472. $t test ! -e $(APP)/ebin/
  473. $i "Add a rule to remove the generated .erl file on clean"
  474. $t echo "clean:: ; rm src/generated.erl" >> $(APP)/Makefile
  475. $i "Clean the application again"
  476. $t $(MAKE) -C $(APP) clean $v
  477. $i "Check that the generated .erl file was removed"
  478. $t test ! -e $(APP)/src/generated.erl
  479. $i "Build the application again"
  480. $t $(MAKE) -C $(APP) $v
  481. $i "Check that all compiled files exist"
  482. $t test -f $(APP)/$(APP).d
  483. $t test -f $(APP)/ebin/$(APP).app
  484. $t test -f $(APP)/ebin/boy.beam
  485. $t test -f $(APP)/ebin/generated.beam
  486. $t test -f $(APP)/ebin/girl.beam
  487. $t test -f $(APP)/src/generated.erl
  488. $i "Check that the application was compiled correctly"
  489. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  490. ok = application:start($(APP)), \
  491. {ok, Mods = [boy, generated, girl]} \
  492. = application:get_key($(APP), modules), \
  493. [{module, M} = code:load_file(M) || M <- Mods], \
  494. halt()"
  495. core-app-hrl: build clean
  496. $i "Bootstrap a new OTP library named $(APP)"
  497. $t mkdir $(APP)/
  498. $t cp ../erlang.mk $(APP)/
  499. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  500. $i "Generate .hrl files"
  501. $t mkdir $(APP)/include/
  502. $t touch $(APP)/include/blue.hrl $(APP)/include/red.hrl
  503. $i "Generate .erl files dependent from headers"
  504. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  505. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  506. $i "Build the application"
  507. $t $(MAKE) -C $(APP) $v
  508. $i "Check that all compiled files exist"
  509. $t test -f $(APP)/$(APP).d
  510. $t test -f $(APP)/ebin/$(APP).app
  511. $t test -f $(APP)/ebin/use_blue.beam
  512. $t test -f $(APP)/ebin/use_red.beam
  513. $i "Check that the application was compiled correctly"
  514. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  515. ok = application:start($(APP)), \
  516. {ok, Mods = [use_blue, use_red]} \
  517. = application:get_key($(APP), modules), \
  518. [{module, M} = code:load_file(M) || M <- Mods], \
  519. halt()"
  520. $i "Touch one .hrl file; check that only required files are rebuilt"
  521. # The use_red.erl gets touched because of its dependency to red.hrl.
  522. $t printf "%s\n" \
  523. $(APP)/$(APP).d \
  524. $(APP)/ebin/$(APP).app \
  525. $(APP)/ebin/use_red.beam \
  526. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  527. $t $(SLEEP)
  528. $t touch $(APP)/include/red.hrl
  529. $t $(SLEEP)
  530. $t $(MAKE) -C $(APP) $v
  531. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  532. $t rm $(APP)/EXPECT
  533. $i "Check that the application was compiled correctly"
  534. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  535. ok = application:start($(APP)), \
  536. {ok, Mods = [use_blue, use_red]} \
  537. = application:get_key($(APP), modules), \
  538. [{module, M} = code:load_file(M) || M <- Mods], \
  539. halt()"
  540. $i "Clean the application"
  541. $t $(MAKE) -C $(APP) clean $v
  542. $i "Check that source files still exist"
  543. $t test -f $(APP)/Makefile
  544. $t test -f $(APP)/erlang.mk
  545. $t test -f $(APP)/include/blue.hrl
  546. $t test -f $(APP)/include/red.hrl
  547. ifdef LEGACY
  548. $t test -f $(APP)/src/$(APP).app.src
  549. endif
  550. $t test -f $(APP)/src/use_blue.erl
  551. $t test -f $(APP)/src/use_red.erl
  552. $i "Check that all build artifacts are removed"
  553. $t test ! -e $(APP)/$(APP).d
  554. $t test ! -e $(APP)/ebin/
  555. $i "Build the application again"
  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. core-app-hrl-recursive: build clean
  570. $i "Bootstrap a new OTP library named $(APP)"
  571. $t mkdir $(APP)/
  572. $t cp ../erlang.mk $(APP)/
  573. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  574. $i "Generate .hrl files"
  575. $t mkdir $(APP)/include/
  576. $t touch $(APP)/include/blue.hrl $(APP)/include/pill.hrl
  577. $t echo "-include(\"pill.hrl\")." > $(APP)/include/red.hrl
  578. $i "Generate .erl files dependent from headers"
  579. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  580. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  581. $i "Build the application"
  582. $t $(MAKE) -C $(APP) $v
  583. $i "Check that all compiled files exist"
  584. $t test -f $(APP)/$(APP).d
  585. $t test -f $(APP)/ebin/$(APP).app
  586. $t test -f $(APP)/ebin/use_blue.beam
  587. $t test -f $(APP)/ebin/use_red.beam
  588. $i "Check that the application was compiled correctly"
  589. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  590. ok = application:start($(APP)), \
  591. {ok, Mods = [use_blue, use_red]} \
  592. = application:get_key($(APP), modules), \
  593. [{module, M} = code:load_file(M) || M <- Mods], \
  594. halt()"
  595. $i "Touch the deepest .hrl file; check that only required files are rebuilt"
  596. # The use_red.erl gets touched because of its dependency to red.hrl and pill.hrl.
  597. $t printf "%s\n" \
  598. $(APP)/$(APP).d \
  599. $(APP)/ebin/$(APP).app \
  600. $(APP)/ebin/use_red.beam \
  601. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  602. $t $(SLEEP)
  603. $t touch $(APP)/include/pill.hrl
  604. $t $(SLEEP)
  605. $t $(MAKE) -C $(APP) $v
  606. $t find $(APP) -type f -newer $(APP)/include/pill.hrl | sort | diff $(APP)/EXPECT -
  607. $t rm $(APP)/EXPECT
  608. $i "Check that the application was compiled correctly"
  609. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  610. ok = application:start($(APP)), \
  611. {ok, Mods = [use_blue, use_red]} \
  612. = application:get_key($(APP), modules), \
  613. [{module, M} = code:load_file(M) || M <- Mods], \
  614. halt()"
  615. $i "Clean the application"
  616. $t $(MAKE) -C $(APP) clean $v
  617. $i "Check that source files still exist"
  618. $t test -f $(APP)/Makefile
  619. $t test -f $(APP)/erlang.mk
  620. $t test -f $(APP)/include/blue.hrl
  621. $t test -f $(APP)/include/pill.hrl
  622. $t test -f $(APP)/include/red.hrl
  623. ifdef LEGACY
  624. $t test -f $(APP)/src/$(APP).app.src
  625. endif
  626. $t test -f $(APP)/src/use_blue.erl
  627. $t test -f $(APP)/src/use_red.erl
  628. $i "Check that all build artifacts are removed"
  629. $t test ! -e $(APP)/$(APP).d
  630. $t test ! -e $(APP)/ebin/
  631. $i "Build the application again"
  632. $t $(MAKE) -C $(APP) $v
  633. $i "Check that all compiled files exist"
  634. $t test -f $(APP)/$(APP).d
  635. $t test -f $(APP)/ebin/$(APP).app
  636. $t test -f $(APP)/ebin/use_blue.beam
  637. $t test -f $(APP)/ebin/use_red.beam
  638. $i "Check that the application was compiled correctly"
  639. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  640. ok = application:start($(APP)), \
  641. {ok, Mods = [use_blue, use_red]} \
  642. = application:get_key($(APP), modules), \
  643. [{module, M} = code:load_file(M) || M <- Mods], \
  644. halt()"
  645. core-app-makefile-change: build clean
  646. $i "Bootstrap a new OTP application named $(APP)"
  647. $t mkdir $(APP)/
  648. $t cp ../erlang.mk $(APP)/
  649. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  650. $i "Build the application"
  651. $t $(MAKE) -C $(APP) $v
  652. $i "Touch the Makefile; check that all files get rebuilt"
  653. $t printf "%s\n" \
  654. $(APP)/$(APP).d \
  655. $(APP)/ebin/$(APP).app \
  656. $(APP)/ebin/$(APP)_app.beam \
  657. $(APP)/ebin/$(APP)_sup.beam \
  658. $(APP)/src/$(APP)_app.erl \
  659. $(APP)/src/$(APP)_sup.erl | sort > $(APP)/EXPECT
  660. $t $(SLEEP)
  661. $t touch $(APP)/Makefile
  662. $t $(SLEEP)
  663. $t $(MAKE) -C $(APP) $v
  664. $t find $(APP) -type f -newer $(APP)/Makefile | sort | diff $(APP)/EXPECT -
  665. $t rm $(APP)/EXPECT
  666. core-app-mib: build clean
  667. $i "Bootstrap a new OTP library named $(APP)"
  668. $t mkdir $(APP)/
  669. $t cp ../erlang.mk $(APP)/
  670. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  671. $i "Download .mib files from Erlang/OTP"
  672. $t mkdir $(APP)/mibs/
  673. $t curl -s -o $(APP)/mibs/EX1-MIB.mib $(OTP_MASTER)/lib/snmp/examples/ex1/EX1-MIB.mib
  674. $t curl -s -o $(APP)/mibs/OTP-REG.mib $(OTP_MASTER)/lib/otp_mibs/mibs/OTP-REG.mib
  675. $i "Generate .erl files dependent from headers generated by .mib files"
  676. $t printf "%s\n" "-module(use_v1)." "-include(\"EX1-MIB.hrl\")." > $(APP)/src/use_v1.erl
  677. $t printf "%s\n" "-module(use_v2)." "-include(\"OTP-REG.hrl\")." > $(APP)/src/use_v2.erl
  678. $i "Generate an unrelated .hrl file"
  679. $t mkdir $(APP)/include/
  680. $t touch $(APP)/include/unrelated.hrl
  681. $i "Build the application"
  682. $t $(MAKE) -C $(APP) $v
  683. $i "Check that all compiled files exist"
  684. $t test -f $(APP)/$(APP).d
  685. $t test -f $(APP)/ebin/$(APP).app
  686. $t test -f $(APP)/ebin/use_v1.beam
  687. $t test -f $(APP)/ebin/use_v2.beam
  688. $t test -f $(APP)/include/EX1-MIB.hrl
  689. $t test -f $(APP)/include/OTP-REG.hrl
  690. $t test -f $(APP)/priv/mibs/EX1-MIB.bin
  691. $t test -f $(APP)/priv/mibs/OTP-REG.bin
  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 "Touch one .mib file; check that only required files are rebuilt"
  700. # The use_v1.erl gets touched because of its dependency to EX1-MIB.hrl.
  701. $t printf "%s\n" \
  702. $(APP)/$(APP).d \
  703. $(APP)/ebin/$(APP).app \
  704. $(APP)/ebin/use_v1.beam \
  705. $(APP)/include/EX1-MIB.hrl \
  706. $(APP)/priv/mibs/EX1-MIB.bin \
  707. $(APP)/src/use_v1.erl | sort > $(APP)/EXPECT
  708. $t $(SLEEP)
  709. $t touch $(APP)/mibs/EX1-MIB.mib
  710. $t $(SLEEP)
  711. $t $(MAKE) -C $(APP) $v
  712. $t find $(APP) -type f -newer $(APP)/mibs/EX1-MIB.mib | sort | diff $(APP)/EXPECT -
  713. $t rm $(APP)/EXPECT
  714. $i "Check that the application was compiled correctly"
  715. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  716. ok = application:start($(APP)), \
  717. {ok, Mods = [use_v1, use_v2]} \
  718. = application:get_key($(APP), modules), \
  719. [{module, M} = code:load_file(M) || M <- Mods], \
  720. halt()"
  721. $i "Clean the application"
  722. $t $(MAKE) -C $(APP) clean $v
  723. $i "Check that source files still exist"
  724. $t test -f $(APP)/Makefile
  725. $t test -f $(APP)/erlang.mk
  726. $t test -f $(APP)/include/unrelated.hrl
  727. $t test -f $(APP)/mibs/EX1-MIB.mib
  728. $t test -f $(APP)/mibs/OTP-REG.mib
  729. ifdef LEGACY
  730. $t test -f $(APP)/src/$(APP).app.src
  731. endif
  732. $t test -f $(APP)/src/use_v1.erl
  733. $t test -f $(APP)/src/use_v2.erl
  734. $i "Check that all build artifacts are removed, including intermediates"
  735. $t test ! -e $(APP)/$(APP).d
  736. $t test ! -e $(APP)/ebin/
  737. $t test ! -e $(APP)/include/EX1-MIB.hrl
  738. $t test ! -e $(APP)/include/OTP-REG.hrl
  739. $t test ! -e $(APP)/priv/mibs/
  740. $i "Build the application again"
  741. $t $(MAKE) -C $(APP) $v
  742. $i "Check that all compiled files exist"
  743. $t test -f $(APP)/$(APP).d
  744. $t test -f $(APP)/ebin/$(APP).app
  745. $t test -f $(APP)/ebin/use_v1.beam
  746. $t test -f $(APP)/ebin/use_v2.beam
  747. $t test -f $(APP)/include/EX1-MIB.hrl
  748. $t test -f $(APP)/include/OTP-REG.hrl
  749. $t test -f $(APP)/priv/mibs/EX1-MIB.bin
  750. $t test -f $(APP)/priv/mibs/OTP-REG.bin
  751. $i "Check that the application was compiled correctly"
  752. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  753. ok = application:start($(APP)), \
  754. {ok, Mods = [use_v1, use_v2]} \
  755. = application:get_key($(APP), modules), \
  756. [{module, M} = code:load_file(M) || M <- Mods], \
  757. halt()"
  758. core-app-no-app: build clean
  759. $i "Bootstrap a project without an OTP library"
  760. $t mkdir $(APP)/
  761. $t cp ../erlang.mk $(APP)/
  762. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  763. $t rm -rf $(APP)/src
  764. $i "Build the project"
  765. $t $(MAKE) -C $(APP) $v
  766. core-app-no-makedep: build clean
  767. $i "Bootstrap a new OTP library named $(APP)"
  768. $t mkdir $(APP)/
  769. $t cp ../erlang.mk $(APP)/
  770. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  771. $i "Set NO_MAKEDEP ?= 1 in the Makefile"
  772. $t perl -ni.bak -e 'print;if ($$.==1) {print "NO_MAKEDEP ?= 1\n"}' $(APP)/Makefile
  773. $i "Generate .hrl files"
  774. $t mkdir $(APP)/include/
  775. $t touch $(APP)/include/blue.hrl $(APP)/include/red.hrl
  776. $i "Generate .erl files dependent from headers"
  777. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  778. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  779. $i "Build the application"
  780. $t $(MAKE) -C $(APP) $v
  781. $i "Check that all compiled files exist"
  782. $t test -f $(APP)/$(APP).d
  783. $t test -f $(APP)/ebin/$(APP).app
  784. $t test -f $(APP)/ebin/use_blue.beam
  785. $t test -f $(APP)/ebin/use_red.beam
  786. $i "Check that the application was compiled correctly"
  787. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  788. ok = application:start($(APP)), \
  789. {ok, Mods = [use_blue, use_red]} \
  790. = application:get_key($(APP), modules), \
  791. [{module, M} = code:load_file(M) || M <- Mods], \
  792. halt()"
  793. $i "Touch one .hrl file; check that only required files are rebuilt"
  794. # The use_red.erl gets touched because of its dependency to red.hrl.
  795. $t printf "%s\n" \
  796. $(APP)/ebin/$(APP).app \
  797. $(APP)/ebin/use_red.beam \
  798. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  799. $t $(SLEEP)
  800. $t touch $(APP)/include/red.hrl
  801. $t $(SLEEP)
  802. $t $(MAKE) -C $(APP) $v
  803. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  804. $t rm $(APP)/EXPECT
  805. $i "Check that the application was compiled correctly"
  806. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  807. ok = application:start($(APP)), \
  808. {ok, Mods = [use_blue, use_red]} \
  809. = application:get_key($(APP), modules), \
  810. [{module, M} = code:load_file(M) || M <- Mods], \
  811. halt()"
  812. $i "Touch one .hrl file; disable NO_MAKEDEP and check that only required files are rebuilt"
  813. # The use_red.erl gets touched because of its dependency to red.hrl.
  814. $t printf "%s\n" \
  815. $(APP)/$(APP).d \
  816. $(APP)/ebin/$(APP).app \
  817. $(APP)/ebin/use_red.beam \
  818. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  819. $t $(SLEEP)
  820. $t touch $(APP)/include/red.hrl
  821. $t $(SLEEP)
  822. $t NO_MAKEDEP= $(MAKE) -C $(APP) $v
  823. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  824. $t rm $(APP)/EXPECT
  825. $i "Check that the application was compiled correctly"
  826. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  827. ok = application:start($(APP)), \
  828. {ok, Mods = [use_blue, use_red]} \
  829. = application:get_key($(APP), modules), \
  830. [{module, M} = code:load_file(M) || M <- Mods], \
  831. halt()"
  832. $i "Clean the application"
  833. $t $(MAKE) -C $(APP) clean $v
  834. $i "Check that source files still exist"
  835. $t test -f $(APP)/Makefile
  836. $t test -f $(APP)/erlang.mk
  837. $t test -f $(APP)/include/blue.hrl
  838. $t test -f $(APP)/include/red.hrl
  839. ifdef LEGACY
  840. $t test -f $(APP)/src/$(APP).app.src
  841. endif
  842. $t test -f $(APP)/src/use_blue.erl
  843. $t test -f $(APP)/src/use_red.erl
  844. $i "Check that all build artifacts are removed"
  845. $t test ! -e $(APP)/$(APP).d
  846. $t test ! -e $(APP)/ebin/
  847. $i "Build the application again"
  848. $t $(MAKE) -C $(APP) $v
  849. $i "Check that all compiled files exist"
  850. $t test -f $(APP)/$(APP).d
  851. $t test -f $(APP)/ebin/$(APP).app
  852. $t test -f $(APP)/ebin/use_blue.beam
  853. $t test -f $(APP)/ebin/use_red.beam
  854. $i "Check that the application was compiled correctly"
  855. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  856. ok = application:start($(APP)), \
  857. {ok, Mods = [use_blue, use_red]} \
  858. = application:get_key($(APP), modules), \
  859. [{module, M} = code:load_file(M) || M <- Mods], \
  860. halt()"
  861. core-app-project-mod: 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 "Generate an application module"
  867. $t printf "%s\n" \
  868. "-module(app_mod)." \
  869. "-export([start/2, stop/1])." \
  870. "start(_StartType, _StartArgs) -> {ok, self()}." \
  871. "stop(_State) -> ok." > $(APP)/src/app_mod.erl
  872. $i "Build the application with PROJECT_MOD"
  873. $t $(MAKE) -C $(APP) PROJECT_MOD=app_mod $v
  874. $i "Check that the application starts correctly"
  875. $t $(ERL) -pa $(APP)/ebin/ -eval "ok = application:start($(APP)), halt()"
  876. core-app-pt: build clean
  877. $i "Bootstrap a new OTP library named $(APP)"
  878. $t mkdir $(APP)/
  879. $t cp ../erlang.mk $(APP)/
  880. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  881. $i "Generate a parse_transform module"
  882. $t printf "%s\n" \
  883. "-module(my_pt)." \
  884. "-export([parse_transform/2])." \
  885. "parse_transform(Forms, _) ->" \
  886. " io:format(\"*** Running my_pt parse_transform.~n\")," \
  887. " Forms." > $(APP)/src/my_pt.erl
  888. $i "Generate a .erl file that uses the my_pt parse_transform"
  889. $t printf "%s\n" \
  890. "-module(my_user)." \
  891. "-compile({parse_transform, my_pt})." > $(APP)/src/my_user.erl
  892. $i "Compile my_pt first"
  893. $t echo "COMPILE_FIRST += my_pt" >> $(APP)/Makefile
  894. $i "Build the application; confirm the parse_transform is used"
  895. $t $(MAKE) -C $(APP) | grep "Running my_pt parse_transform."
  896. $i "Check that the application was compiled correctly"
  897. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  898. ok = application:start($(APP)), \
  899. {ok, Mods = [my_pt, my_user]} = application:get_key($(APP), modules), \
  900. [{module, M} = code:load_file(M) || M <- Mods], \
  901. halt()"
  902. core-app-pt-erlc-opts: build clean
  903. $i "Bootstrap a new OTP library named $(APP)"
  904. $t mkdir $(APP)/
  905. $t cp ../erlang.mk $(APP)/
  906. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  907. $i "Bootstrap a new OTP library in $(APP)/deps/my_pt_dep"
  908. $t mkdir -p $(APP)/deps/my_pt_dep/
  909. $t cp ../erlang.mk $(APP)/deps/my_pt_dep/
  910. $t $(MAKE) -C $(APP)/deps/my_pt_dep/ -f erlang.mk bootstrap-lib $v
  911. $i "Generate a parse_transform module in my_pt_dep"
  912. $t printf "%s\n" \
  913. "-module(my_pt)." \
  914. "-export([parse_transform/2])." \
  915. "parse_transform(Forms, _) ->" \
  916. " io:format(\"*** Running my_pt parse_transform.~n\")," \
  917. " Forms." > $(APP)/deps/my_pt_dep/src/my_pt.erl
  918. $i "Add my_pt_dep to the list of dependencies"
  919. $t perl -ni.bak -e 'print;if ($$.==1) {print "BUILD_DEPS = my_pt_dep\n"}' $(APP)/Makefile
  920. $i "Generate .erl files"
  921. $t echo "-module(boy)." > $(APP)/src/boy.erl
  922. $t echo "-module(girl)." > $(APP)/src/girl.erl
  923. $i "Add the my_pt parse_transform to ERLC_OPTS"
  924. $t echo "ERLC_OPTS += +'{parse_transform, my_pt}'" >> $(APP)/Makefile
  925. $i "Build the application; confirm the parse_transform is used"
  926. $t $(MAKE) -C $(APP) | grep "Running my_pt parse_transform."
  927. $i "Check that the application was compiled correctly"
  928. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  929. ok = application:start($(APP)), \
  930. {ok, Mods = [boy, girl]} = application:get_key($(APP), modules), \
  931. [{module, M} = code:load_file(M) || M <- Mods], \
  932. halt()"
  933. core-app-xrl: build clean
  934. $i "Bootstrap a new OTP library named $(APP)"
  935. $t mkdir $(APP)/
  936. $t cp ../erlang.mk $(APP)/
  937. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  938. $i "Download .xrl files from Robert"
  939. $t curl -s -o $(APP)/src/erlang_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/erlang_scan.xrl
  940. $t curl -s -o $(APP)/src/lfe_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/lfe_scan.xrl
  941. $i "Generate unrelated .erl files"
  942. $t echo "-module(boy)." > $(APP)/src/boy.erl
  943. $t echo "-module(girl)." > $(APP)/src/girl.erl
  944. $i "Disable warnings; our test .xrl files aren't perfect"
  945. $t echo "ERLC_OPTS=+debug_info" >> $(APP)/Makefile
  946. $i "Build the application"
  947. $t $(MAKE) -C $(APP) $v
  948. $i "Check that all compiled files exist"
  949. $t test -f $(APP)/$(APP).d
  950. $t test -f $(APP)/ebin/$(APP).app
  951. $t test -f $(APP)/ebin/boy.beam
  952. $t test -f $(APP)/ebin/erlang_scan.beam
  953. $t test -f $(APP)/ebin/girl.beam
  954. $t test -f $(APP)/ebin/lfe_scan.beam
  955. $t test -f $(APP)/src/erlang_scan.erl
  956. $t test -f $(APP)/src/lfe_scan.erl
  957. $i "Check that the application was compiled correctly"
  958. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  959. ok = application:start($(APP)), \
  960. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  961. = application:get_key($(APP), modules), \
  962. [{module, M} = code:load_file(M) || M <- Mods], \
  963. halt()"
  964. $i "Touch one .xrl file; check that only required files are rebuilt"
  965. $t printf "%s\n" \
  966. $(APP)/$(APP).d \
  967. $(APP)/ebin/$(APP).app \
  968. $(APP)/ebin/erlang_scan.beam \
  969. $(APP)/src/erlang_scan.erl | sort > $(APP)/EXPECT
  970. $t $(SLEEP)
  971. $t touch $(APP)/src/erlang_scan.xrl
  972. $t $(SLEEP)
  973. $t $(MAKE) -C $(APP) $v
  974. $t find $(APP) -type f -newer $(APP)/src/erlang_scan.xrl | sort | diff $(APP)/EXPECT -
  975. $t rm $(APP)/EXPECT
  976. $i "Check that the application was compiled correctly"
  977. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  978. ok = application:start($(APP)), \
  979. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  980. = application:get_key($(APP), modules), \
  981. [{module, M} = code:load_file(M) || M <- Mods], \
  982. halt()"
  983. $i "Clean the application"
  984. $t $(MAKE) -C $(APP) clean $v
  985. $i "Check that source files still exist"
  986. $t test -f $(APP)/Makefile
  987. $t test -f $(APP)/erlang.mk
  988. ifdef LEGACY
  989. $t test -f $(APP)/src/$(APP).app.src
  990. endif
  991. $t test -f $(APP)/src/boy.erl
  992. $t test -f $(APP)/src/erlang_scan.xrl
  993. $t test -f $(APP)/src/girl.erl
  994. $t test -f $(APP)/src/lfe_scan.xrl
  995. $i "Check that all build artifacts are removed, including intermediates"
  996. $t test ! -e $(APP)/$(APP).d
  997. $t test ! -e $(APP)/ebin/
  998. $t test ! -e $(APP)/src/erlang_scan.erl
  999. $t test ! -e $(APP)/src/lfe_scan.erl
  1000. $i "Build the application again"
  1001. $t $(MAKE) -C $(APP) $v
  1002. $i "Check that all compiled files exist"
  1003. $t test -f $(APP)/$(APP).d
  1004. $t test -f $(APP)/ebin/$(APP).app
  1005. $t test -f $(APP)/ebin/boy.beam
  1006. $t test -f $(APP)/ebin/erlang_scan.beam
  1007. $t test -f $(APP)/ebin/girl.beam
  1008. $t test -f $(APP)/ebin/lfe_scan.beam
  1009. $t test -f $(APP)/src/erlang_scan.erl
  1010. $t test -f $(APP)/src/lfe_scan.erl
  1011. $i "Check that the application was compiled correctly"
  1012. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1013. ok = application:start($(APP)), \
  1014. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  1015. = application:get_key($(APP), modules), \
  1016. [{module, M} = code:load_file(M) || M <- Mods], \
  1017. halt()"
  1018. core-app-xrl-include: build clean
  1019. $i "Bootstrap a new OTP library named $(APP)"
  1020. $t mkdir $(APP)/
  1021. $t cp ../erlang.mk $(APP)/
  1022. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1023. $i "Download a .xrl file with numerous includes from Gordon"
  1024. $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
  1025. $t curl -s -o $(APP)/src/errvals.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/errvals.hrl
  1026. $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
  1027. $t curl -s -o $(APP)/src/muin_records.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/muin_records.hrl
  1028. $t curl -s -o $(APP)/src/typechecks.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/typechecks.hrl
  1029. $i "Generate unrelated .erl files"
  1030. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1031. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1032. $i "Disable warnings; our test .xrl files aren't perfect"
  1033. $t echo "ERLC_OPTS=+debug_info" >> $(APP)/Makefile
  1034. $i "Build the application"
  1035. $t $(MAKE) -C $(APP) $v
  1036. $i "Check that all compiled files exist"
  1037. $t test -f $(APP)/$(APP).d
  1038. $t test -f $(APP)/ebin/$(APP).app
  1039. $t test -f $(APP)/ebin/boy.beam
  1040. $t test -f $(APP)/ebin/girl.beam
  1041. $t test -f $(APP)/ebin/xfl_lexer.beam
  1042. $t test -f $(APP)/src/xfl_lexer.erl
  1043. $i "Check that the application was compiled correctly"
  1044. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1045. ok = application:start($(APP)), \
  1046. {ok, Mods = [boy, girl, xfl_lexer]} \
  1047. = application:get_key($(APP), modules), \
  1048. [{module, M} = code:load_file(M) || M <- Mods], \
  1049. halt()"
  1050. $i "Touch the .xrl file; check that only required files are rebuilt"
  1051. $t printf "%s\n" \
  1052. $(APP)/$(APP).d \
  1053. $(APP)/ebin/$(APP).app \
  1054. $(APP)/ebin/xfl_lexer.beam \
  1055. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  1056. $t $(SLEEP)
  1057. $t touch $(APP)/src/xfl_lexer.xrl
  1058. $t $(SLEEP)
  1059. $t $(MAKE) -C $(APP) $v
  1060. $t find $(APP) -type f -newer $(APP)/src/xfl_lexer.xrl | sort | diff $(APP)/EXPECT -
  1061. $t rm $(APP)/EXPECT
  1062. $i "Check that the application was compiled correctly"
  1063. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1064. ok = application:start($(APP)), \
  1065. {ok, Mods = [boy, girl, xfl_lexer]} \
  1066. = application:get_key($(APP), modules), \
  1067. [{module, M} = code:load_file(M) || M <- Mods], \
  1068. halt()"
  1069. $i "Touch a .hrl file included directly; check that only required files are rebuilt"
  1070. $t printf "%s\n" \
  1071. $(APP)/$(APP).d \
  1072. $(APP)/ebin/$(APP).app \
  1073. $(APP)/ebin/xfl_lexer.beam \
  1074. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  1075. $t $(SLEEP)
  1076. $t touch $(APP)/src/typechecks.hrl
  1077. $t $(SLEEP)
  1078. $t $(MAKE) -C $(APP) $v
  1079. $t find $(APP) -type f -newer $(APP)/src/typechecks.hrl | sort | diff $(APP)/EXPECT -
  1080. $t rm $(APP)/EXPECT
  1081. $i "Check that the application was compiled correctly"
  1082. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1083. ok = application:start($(APP)), \
  1084. {ok, Mods = [boy, girl, xfl_lexer]} \
  1085. = application:get_key($(APP), modules), \
  1086. [{module, M} = code:load_file(M) || M <- Mods], \
  1087. halt()"
  1088. $i "Touch a .hrl file included indirectly; check that only required files are rebuilt"
  1089. $t printf "%s\n" \
  1090. $(APP)/$(APP).d \
  1091. $(APP)/ebin/$(APP).app \
  1092. $(APP)/ebin/xfl_lexer.beam \
  1093. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  1094. $t $(SLEEP)
  1095. $t touch $(APP)/src/errvals.hrl
  1096. $t $(SLEEP)
  1097. $t $(MAKE) -C $(APP) $v
  1098. $t find $(APP) -type f -newer $(APP)/src/errvals.hrl | sort | diff $(APP)/EXPECT -
  1099. $t rm $(APP)/EXPECT
  1100. $i "Check that the application was compiled correctly"
  1101. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1102. ok = application:start($(APP)), \
  1103. {ok, Mods = [boy, girl, xfl_lexer]} \
  1104. = application:get_key($(APP), modules), \
  1105. [{module, M} = code:load_file(M) || M <- Mods], \
  1106. halt()"
  1107. $i "Clean the application"
  1108. $t $(MAKE) -C $(APP) clean $v
  1109. $i "Check that source files still exist"
  1110. $t test -f $(APP)/Makefile
  1111. $t test -f $(APP)/erlang.mk
  1112. ifdef LEGACY
  1113. $t test -f $(APP)/src/$(APP).app.src
  1114. endif
  1115. $t test -f $(APP)/src/boy.erl
  1116. $t test -f $(APP)/src/girl.erl
  1117. $t test -f $(APP)/src/errvals.hrl
  1118. $t test -f $(APP)/src/muin_proc_dict.hrl
  1119. $t test -f $(APP)/src/muin_records.hrl
  1120. $t test -f $(APP)/src/typechecks.hrl
  1121. $t test -f $(APP)/src/xfl_lexer.xrl
  1122. $i "Check that all build artifacts are removed, including intermediates"
  1123. $t test ! -e $(APP)/$(APP).d
  1124. $t test ! -e $(APP)/ebin/
  1125. $t test ! -e $(APP)/src/xfl_lexer.erl
  1126. $i "Build the application again"
  1127. $t $(MAKE) -C $(APP) $v
  1128. $i "Check that all compiled files exist"
  1129. $t test -f $(APP)/$(APP).d
  1130. $t test -f $(APP)/ebin/$(APP).app
  1131. $t test -f $(APP)/ebin/boy.beam
  1132. $t test -f $(APP)/ebin/girl.beam
  1133. $t test -f $(APP)/ebin/xfl_lexer.beam
  1134. $t test -f $(APP)/src/xfl_lexer.erl
  1135. $i "Check that the application was compiled correctly"
  1136. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1137. ok = application:start($(APP)), \
  1138. {ok, Mods = [boy, girl, xfl_lexer]} \
  1139. = application:get_key($(APP), modules), \
  1140. [{module, M} = code:load_file(M) || M <- Mods], \
  1141. halt()"
  1142. core-app-yrl: build clean
  1143. $i "Bootstrap a new OTP library named $(APP)"
  1144. $t mkdir $(APP)/
  1145. $t cp ../erlang.mk $(APP)/
  1146. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1147. $i "Download .yrl files from Erlang/OTP"
  1148. $t curl -s -o $(APP)/src/xmerl_xpath_parse.yrl $(OTP_MASTER)/lib/xmerl/src/xmerl_xpath_parse.yrl
  1149. $t curl -s -o $(APP)/src/xref_parser.yrl $(OTP_MASTER)/lib/tools/src/xref_parser.yrl
  1150. $i "Generate unrelated .erl files"
  1151. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1152. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1153. $i "Build the application"
  1154. $t $(MAKE) -C $(APP) $v
  1155. $i "Check that all compiled files exist"
  1156. $t test -f $(APP)/$(APP).d
  1157. $t test -f $(APP)/ebin/$(APP).app
  1158. $t test -f $(APP)/ebin/boy.beam
  1159. $t test -f $(APP)/ebin/girl.beam
  1160. $t test -f $(APP)/ebin/xmerl_xpath_parse.beam
  1161. $t test -f $(APP)/ebin/xref_parser.beam
  1162. $t test -f $(APP)/src/xmerl_xpath_parse.erl
  1163. $t test -f $(APP)/src/xref_parser.erl
  1164. $i "Check that the application was compiled correctly"
  1165. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1166. ok = application:start($(APP)), \
  1167. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  1168. = application:get_key($(APP), modules), \
  1169. [{module, M} = code:load_file(M) || M <- Mods], \
  1170. halt()"
  1171. $i "Touch one .yrl file; check that only required files are rebuilt"
  1172. $t printf "%s\n" \
  1173. $(APP)/$(APP).d \
  1174. $(APP)/ebin/$(APP).app \
  1175. $(APP)/ebin/xref_parser.beam \
  1176. $(APP)/src/xref_parser.erl | sort > $(APP)/EXPECT
  1177. $t $(SLEEP)
  1178. $t touch $(APP)/src/xref_parser.yrl
  1179. $t $(SLEEP)
  1180. $t $(MAKE) -C $(APP) $v
  1181. $t find $(APP) -type f -newer $(APP)/src/xref_parser.yrl | sort | diff $(APP)/EXPECT -
  1182. $t rm $(APP)/EXPECT
  1183. $i "Check that the application was compiled correctly"
  1184. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1185. ok = application:start($(APP)), \
  1186. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  1187. = application:get_key($(APP), modules), \
  1188. [{module, M} = code:load_file(M) || M <- Mods], \
  1189. halt()"
  1190. $i "Clean the application"
  1191. $t $(MAKE) -C $(APP) clean $v
  1192. $i "Check that source files still exist"
  1193. $t test -f $(APP)/Makefile
  1194. $t test -f $(APP)/erlang.mk
  1195. ifdef LEGACY
  1196. $t test -f $(APP)/src/$(APP).app.src
  1197. endif
  1198. $t test -f $(APP)/src/boy.erl
  1199. $t test -f $(APP)/src/girl.erl
  1200. $t test -f $(APP)/src/xmerl_xpath_parse.yrl
  1201. $t test -f $(APP)/src/xref_parser.yrl
  1202. $i "Check that all build artifacts are removed, including intermediates"
  1203. $t test ! -e $(APP)/$(APP).d
  1204. $t test ! -e $(APP)/ebin/
  1205. $t test ! -e $(APP)/src/xmerl_xpath_parse.erl
  1206. $t test ! -e $(APP)/src/xref_parser.erl
  1207. $i "Build the application again"
  1208. $t $(MAKE) -C $(APP) $v
  1209. $i "Check that all compiled files exist"
  1210. $t test -f $(APP)/$(APP).d
  1211. $t test -f $(APP)/ebin/$(APP).app
  1212. $t test -f $(APP)/ebin/boy.beam
  1213. $t test -f $(APP)/ebin/girl.beam
  1214. $t test -f $(APP)/ebin/xmerl_xpath_parse.beam
  1215. $t test -f $(APP)/ebin/xref_parser.beam
  1216. $t test -f $(APP)/src/xmerl_xpath_parse.erl
  1217. $t test -f $(APP)/src/xref_parser.erl
  1218. $i "Check that the application was compiled correctly"
  1219. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1220. ok = application:start($(APP)), \
  1221. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  1222. = application:get_key($(APP), modules), \
  1223. [{module, M} = code:load_file(M) || M <- Mods], \
  1224. halt()"
  1225. core-app-yrl-header: build clean
  1226. $i "Bootstrap a new OTP library named $(APP)"
  1227. $t mkdir $(APP)/
  1228. $t cp ../erlang.mk $(APP)/
  1229. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1230. $i "Create a .yrl file"
  1231. $t echo "Nonterminals E T F." > $(APP)/src/y_parse.yrl
  1232. $t echo "Terminals '+' '*' '(' ')' number." >> $(APP)/src/y_parse.yrl
  1233. $t echo "Rootsymbol E." >> $(APP)/src/y_parse.yrl
  1234. $t echo "E -> E '+' T: {'\$$2', '\$$1', '\$$3'}." >> $(APP)/src/y_parse.yrl
  1235. $t echo "E -> T : '\$$1'." >> $(APP)/src/y_parse.yrl
  1236. $t echo "T -> T '*' F: {'\$$2', '\$$1', '\$$3'}." >> $(APP)/src/y_parse.yrl
  1237. $t echo "T -> F : '\$$1'." >> $(APP)/src/y_parse.yrl
  1238. $t echo "F -> '(' E ')' : '\$$2'." >> $(APP)/src/y_parse.yrl
  1239. $t echo "F -> number : '\$$1'. " >> $(APP)/src/y_parse.yrl
  1240. $i "Create the yrl header file"
  1241. $t mkdir $(APP)/include
  1242. $t echo "-export([forty_two/0])." > $(APP)/include/yecc_header.hrl
  1243. # A bunch of gobbldygook we don't actually care about, they just
  1244. # need to exist so we don't get errors.
  1245. $t echo "-export([yeccpars1/5, yeccerror/1, yeccpars2/7, yeccpars2_0/7, yeccpars2_1/7, yeccpars2_2/7, yeccpars2_3/7, yeccpars2_5/7, yeccpars2_6/7, yeccpars2_7/7, yeccpars2_9/7, yeccpars2_11/7, 'yeccgoto_\'E\''/7, 'yeccgoto_\'F\''/7, 'yeccgoto_\'T\''/7, yeccpars2_9_/1, yeccpars2_11_/1, yeccpars2_7_/1])." >> $(APP)/include/yecc_header.hrl
  1246. $t echo "yeccpars1(_,_,_,_,_) -> throw(not_implemented)." >> $(APP)/include/yecc_header.hrl
  1247. $t echo "yeccerror(_) -> throw(not_implemented)." >> $(APP)/include/yecc_header.hrl
  1248. # Required bits done, now part we'll actually test for.
  1249. $t echo "forty_two() -> 42." >> $(APP)/include/yecc_header.hrl
  1250. $i "Generate unrelated .erl files"
  1251. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1252. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1253. $i "Build the application"
  1254. $t YRL_ERLC_OPTS="-I include/yecc_header.hrl" $(MAKE) -C $(APP) $v
  1255. $i "Check that all compiled files exist"
  1256. $t test -f $(APP)/$(APP).d
  1257. $t test -f $(APP)/ebin/$(APP).app
  1258. $t test -f $(APP)/ebin/boy.beam
  1259. $t test -f $(APP)/ebin/girl.beam
  1260. $t test -f $(APP)/ebin/y_parse.beam
  1261. $t test -f $(APP)/src/y_parse.erl
  1262. $i "Check that the application was compiled correctly"
  1263. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1264. ok = application:start($(APP)), \
  1265. {ok, Mods = [boy, girl, y_parse]} \
  1266. = application:get_key($(APP), modules), \
  1267. [{module, M} = code:load_file(M) || M <- Mods], \
  1268. halt()"
  1269. $i "Check the built yecc module used the header"
  1270. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1271. {module, y_parse} = code:load_file(y_parse), \
  1272. 42 = y_parse:forty_two(), \
  1273. halt()"
  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, girl, y_parse]} \
  1278. = application:get_key($(APP), modules), \
  1279. [{module, M} = code:load_file(M) || M <- Mods], \
  1280. halt()"
  1281. core-app-yrl-include: build clean
  1282. $i "Bootstrap a new OTP library named $(APP)"
  1283. $t mkdir $(APP)/
  1284. $t cp ../erlang.mk $(APP)/
  1285. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1286. $i "Download a .yrl file with includes from Erlang/OTP"
  1287. $t curl -s -o $(APP)/src/core_parse.yrl $(OTP_MASTER)/lib/compiler/src/core_parse.yrl
  1288. $t curl -s -o $(APP)/src/core_parse.hrl $(OTP_MASTER)/lib/compiler/src/core_parse.hrl
  1289. $i "Generate unrelated .erl files"
  1290. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1291. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1292. $i "Build the application"
  1293. $t $(MAKE) -C $(APP) $v
  1294. $i "Check that all compiled files exist"
  1295. $t test -f $(APP)/$(APP).d
  1296. $t test -f $(APP)/ebin/$(APP).app
  1297. $t test -f $(APP)/ebin/boy.beam
  1298. $t test -f $(APP)/ebin/core_parse.beam
  1299. $t test -f $(APP)/ebin/girl.beam
  1300. $t test -f $(APP)/src/core_parse.erl
  1301. $i "Check that the application was compiled correctly"
  1302. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1303. ok = application:start($(APP)), \
  1304. {ok, Mods = [boy, core_parse, girl]} \
  1305. = application:get_key($(APP), modules), \
  1306. [{module, M} = code:load_file(M) || M <- Mods], \
  1307. halt()"
  1308. $i "Touch the .yrl file; check that only required files are rebuilt"
  1309. $t printf "%s\n" \
  1310. $(APP)/$(APP).d \
  1311. $(APP)/ebin/$(APP).app \
  1312. $(APP)/ebin/core_parse.beam \
  1313. $(APP)/src/core_parse.erl | sort > $(APP)/EXPECT
  1314. $t $(SLEEP)
  1315. $t touch $(APP)/src/core_parse.yrl
  1316. $t $(SLEEP)
  1317. $t $(MAKE) -C $(APP) $v
  1318. $t find $(APP) -type f -newer $(APP)/src/core_parse.yrl | sort | diff $(APP)/EXPECT -
  1319. $t rm $(APP)/EXPECT
  1320. $i "Check that the application was compiled correctly"
  1321. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1322. ok = application:start($(APP)), \
  1323. {ok, Mods = [boy, core_parse, girl]} \
  1324. = application:get_key($(APP), modules), \
  1325. [{module, M} = code:load_file(M) || M <- Mods], \
  1326. halt()"
  1327. $i "Touch the .hrl file included; check that only required files are rebuilt"
  1328. $t printf "%s\n" \
  1329. $(APP)/$(APP).d \
  1330. $(APP)/ebin/$(APP).app \
  1331. $(APP)/ebin/core_parse.beam \
  1332. $(APP)/src/core_parse.erl | sort > $(APP)/EXPECT
  1333. $t $(SLEEP)
  1334. $t touch $(APP)/src/core_parse.hrl
  1335. $t $(SLEEP)
  1336. $t $(MAKE) -C $(APP) $v
  1337. $t find $(APP) -type f -newer $(APP)/src/core_parse.hrl | sort | diff $(APP)/EXPECT -
  1338. $t rm $(APP)/EXPECT
  1339. $i "Check that the application was compiled correctly"
  1340. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1341. ok = application:start($(APP)), \
  1342. {ok, Mods = [boy, core_parse, girl]} \
  1343. = application:get_key($(APP), modules), \
  1344. [{module, M} = code:load_file(M) || M <- Mods], \
  1345. halt()"
  1346. $i "Clean the application"
  1347. $t $(MAKE) -C $(APP) clean $v
  1348. $i "Check that source files still exist"
  1349. $t test -f $(APP)/Makefile
  1350. $t test -f $(APP)/erlang.mk
  1351. ifdef LEGACY
  1352. $t test -f $(APP)/src/$(APP).app.src
  1353. endif
  1354. $t test -f $(APP)/src/boy.erl
  1355. $t test -f $(APP)/src/core_parse.hrl
  1356. $t test -f $(APP)/src/core_parse.yrl
  1357. $t test -f $(APP)/src/girl.erl
  1358. $i "Check that all build artifacts are removed, including intermediates"
  1359. $t test ! -e $(APP)/$(APP).d
  1360. $t test ! -e $(APP)/ebin/
  1361. $t test ! -e $(APP)/src/core_parse.erl
  1362. $i "Build the application again"
  1363. $t $(MAKE) -C $(APP) $v
  1364. $i "Check that all compiled files exist"
  1365. $t test -f $(APP)/$(APP).d
  1366. $t test -f $(APP)/ebin/$(APP).app
  1367. $t test -f $(APP)/ebin/boy.beam
  1368. $t test -f $(APP)/ebin/core_parse.beam
  1369. $t test -f $(APP)/ebin/girl.beam
  1370. $t test -f $(APP)/src/core_parse.erl
  1371. $i "Check that the application was compiled correctly"
  1372. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1373. ok = application:start($(APP)), \
  1374. {ok, Mods = [boy, core_parse, girl]} \
  1375. = application:get_key($(APP), modules), \
  1376. [{module, M} = code:load_file(M) || M <- Mods], \
  1377. halt()"