core_app.mk 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682
  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 name-special-char 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. ifndef LEGACY
  759. core-app-name-special-char: build clean
  760. $i "Bootstrap a new OTP library named $(APP)"
  761. $t mkdir $(APP)/
  762. $t cp ../erlang.mk $(APP)/
  763. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  764. $i "Set PROJECT_DESCRIPTION = test % in the Makefile"
  765. $t echo "PROJECT_DESCRIPTION = test %" >> $(APP)/Makefile
  766. $i "Build the application"
  767. $t $(MAKE) -C $(APP) $v
  768. $i "Check that the application was compiled correctly"
  769. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  770. ok = application:load($(APP)), \
  771. {ok,\"test %\"} = application:get_key($(APP), description), \
  772. halt()"
  773. endif
  774. core-app-no-app: build clean
  775. $i "Bootstrap a project without an OTP library"
  776. $t mkdir $(APP)/
  777. $t cp ../erlang.mk $(APP)/
  778. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  779. $t rm -rf $(APP)/src
  780. $i "Build the project"
  781. $t $(MAKE) -C $(APP) $v
  782. core-app-no-makedep: build clean
  783. $i "Bootstrap a new OTP library named $(APP)"
  784. $t mkdir $(APP)/
  785. $t cp ../erlang.mk $(APP)/
  786. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  787. $i "Set NO_MAKEDEP ?= 1 in the Makefile"
  788. $t perl -ni.bak -e 'print;if ($$.==1) {print "NO_MAKEDEP ?= 1\n"}' $(APP)/Makefile
  789. $i "Generate .hrl files"
  790. $t mkdir $(APP)/include/
  791. $t touch $(APP)/include/blue.hrl $(APP)/include/red.hrl
  792. $i "Generate .erl files dependent from headers"
  793. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  794. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  795. $i "Build the application"
  796. $t $(MAKE) -C $(APP) $v
  797. $i "Check that all compiled files exist"
  798. $t test -f $(APP)/$(APP).d
  799. $t test -f $(APP)/ebin/$(APP).app
  800. $t test -f $(APP)/ebin/use_blue.beam
  801. $t test -f $(APP)/ebin/use_red.beam
  802. $i "Check that the application was compiled correctly"
  803. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  804. ok = application:start($(APP)), \
  805. {ok, Mods = [use_blue, use_red]} \
  806. = application:get_key($(APP), modules), \
  807. [{module, M} = code:load_file(M) || M <- Mods], \
  808. halt()"
  809. $i "Touch one .hrl file; check that only required files are rebuilt"
  810. # The use_red.erl gets touched because of its dependency to red.hrl.
  811. $t printf "%s\n" \
  812. $(APP)/ebin/$(APP).app \
  813. $(APP)/ebin/use_red.beam \
  814. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  815. $t $(SLEEP)
  816. $t touch $(APP)/include/red.hrl
  817. $t $(SLEEP)
  818. $t $(MAKE) -C $(APP) $v
  819. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  820. $t rm $(APP)/EXPECT
  821. $i "Check that the application was compiled correctly"
  822. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  823. ok = application:start($(APP)), \
  824. {ok, Mods = [use_blue, use_red]} \
  825. = application:get_key($(APP), modules), \
  826. [{module, M} = code:load_file(M) || M <- Mods], \
  827. halt()"
  828. $i "Touch one .hrl file; disable NO_MAKEDEP and check that only required files are rebuilt"
  829. # The use_red.erl gets touched because of its dependency to red.hrl.
  830. $t printf "%s\n" \
  831. $(APP)/$(APP).d \
  832. $(APP)/ebin/$(APP).app \
  833. $(APP)/ebin/use_red.beam \
  834. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  835. $t $(SLEEP)
  836. $t touch $(APP)/include/red.hrl
  837. $t $(SLEEP)
  838. $t NO_MAKEDEP= $(MAKE) -C $(APP) $v
  839. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  840. $t rm $(APP)/EXPECT
  841. $i "Check that the application was compiled correctly"
  842. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  843. ok = application:start($(APP)), \
  844. {ok, Mods = [use_blue, use_red]} \
  845. = application:get_key($(APP), modules), \
  846. [{module, M} = code:load_file(M) || M <- Mods], \
  847. halt()"
  848. $i "Clean the application"
  849. $t $(MAKE) -C $(APP) clean $v
  850. $i "Check that source files still exist"
  851. $t test -f $(APP)/Makefile
  852. $t test -f $(APP)/erlang.mk
  853. $t test -f $(APP)/include/blue.hrl
  854. $t test -f $(APP)/include/red.hrl
  855. ifdef LEGACY
  856. $t test -f $(APP)/src/$(APP).app.src
  857. endif
  858. $t test -f $(APP)/src/use_blue.erl
  859. $t test -f $(APP)/src/use_red.erl
  860. $i "Check that all build artifacts are removed"
  861. $t test ! -e $(APP)/$(APP).d
  862. $t test ! -e $(APP)/ebin/
  863. $i "Build the application again"
  864. $t $(MAKE) -C $(APP) $v
  865. $i "Check that all compiled files exist"
  866. $t test -f $(APP)/$(APP).d
  867. $t test -f $(APP)/ebin/$(APP).app
  868. $t test -f $(APP)/ebin/use_blue.beam
  869. $t test -f $(APP)/ebin/use_red.beam
  870. $i "Check that the application was compiled correctly"
  871. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  872. ok = application:start($(APP)), \
  873. {ok, Mods = [use_blue, use_red]} \
  874. = application:get_key($(APP), modules), \
  875. [{module, M} = code:load_file(M) || M <- Mods], \
  876. halt()"
  877. core-app-project-mod: build clean
  878. $i "Bootstrap a new OTP library named $(APP)"
  879. $t mkdir $(APP)/
  880. $t cp ../erlang.mk $(APP)/
  881. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  882. $i "Generate an application module"
  883. $t printf "%s\n" \
  884. "-module(app_mod)." \
  885. "-export([start/2, stop/1])." \
  886. "start(_StartType, _StartArgs) -> {ok, self()}." \
  887. "stop(_State) -> ok." > $(APP)/src/app_mod.erl
  888. $i "Build the application with PROJECT_MOD"
  889. $t $(MAKE) -C $(APP) PROJECT_MOD=app_mod $v
  890. $i "Check that the application starts correctly"
  891. $t $(ERL) -pa $(APP)/ebin/ -eval "ok = application:start($(APP)), halt()"
  892. core-app-pt: 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 "Generate a parse_transform module"
  898. $t printf "%s\n" \
  899. "-module(my_pt)." \
  900. "-export([parse_transform/2])." \
  901. "parse_transform(Forms, _) ->" \
  902. " io:format(\"*** Running my_pt parse_transform.~n\")," \
  903. " Forms." > $(APP)/src/my_pt.erl
  904. $i "Generate a .erl file that uses the my_pt parse_transform"
  905. $t printf "%s\n" \
  906. "-module(my_user)." \
  907. "-compile({parse_transform, my_pt})." > $(APP)/src/my_user.erl
  908. $i "Compile my_pt first"
  909. $t echo "COMPILE_FIRST += my_pt" >> $(APP)/Makefile
  910. $i "Build the application; confirm the parse_transform is used"
  911. $t $(MAKE) -C $(APP) | grep "Running my_pt parse_transform."
  912. $i "Check that the application was compiled correctly"
  913. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  914. ok = application:start($(APP)), \
  915. {ok, Mods = [my_pt, my_user]} = application:get_key($(APP), modules), \
  916. [{module, M} = code:load_file(M) || M <- Mods], \
  917. halt()"
  918. core-app-pt-erlc-opts: build clean
  919. $i "Bootstrap a new OTP library named $(APP)"
  920. $t mkdir $(APP)/
  921. $t cp ../erlang.mk $(APP)/
  922. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  923. $i "Bootstrap a new OTP library in $(APP)/deps/my_pt_dep"
  924. $t mkdir -p $(APP)/deps/my_pt_dep/
  925. $t cp ../erlang.mk $(APP)/deps/my_pt_dep/
  926. $t $(MAKE) -C $(APP)/deps/my_pt_dep/ -f erlang.mk bootstrap-lib $v
  927. $i "Generate a parse_transform module in my_pt_dep"
  928. $t printf "%s\n" \
  929. "-module(my_pt)." \
  930. "-export([parse_transform/2])." \
  931. "parse_transform(Forms, _) ->" \
  932. " io:format(\"*** Running my_pt parse_transform.~n\")," \
  933. " Forms." > $(APP)/deps/my_pt_dep/src/my_pt.erl
  934. $i "Add my_pt_dep to the list of dependencies"
  935. $t perl -ni.bak -e 'print;if ($$.==1) {print "BUILD_DEPS = my_pt_dep\n"}' $(APP)/Makefile
  936. $i "Generate .erl files"
  937. $t echo "-module(boy)." > $(APP)/src/boy.erl
  938. $t echo "-module(girl)." > $(APP)/src/girl.erl
  939. $i "Add the my_pt parse_transform to ERLC_OPTS"
  940. $t echo "ERLC_OPTS += +'{parse_transform, my_pt}'" >> $(APP)/Makefile
  941. $i "Build the application; confirm the parse_transform is used"
  942. $t $(MAKE) -C $(APP) | grep "Running my_pt parse_transform."
  943. $i "Check that the application was compiled correctly"
  944. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  945. ok = application:start($(APP)), \
  946. {ok, Mods = [boy, girl]} = application:get_key($(APP), modules), \
  947. [{module, M} = code:load_file(M) || M <- Mods], \
  948. halt()"
  949. core-app-xrl: build clean
  950. $i "Bootstrap a new OTP library named $(APP)"
  951. $t mkdir $(APP)/
  952. $t cp ../erlang.mk $(APP)/
  953. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  954. $i "Download .xrl files from Robert"
  955. $t curl -s -o $(APP)/src/erlang_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/erlang_scan.xrl
  956. $t curl -s -o $(APP)/src/lfe_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/lfe_scan.xrl
  957. $i "Generate unrelated .erl files"
  958. $t echo "-module(boy)." > $(APP)/src/boy.erl
  959. $t echo "-module(girl)." > $(APP)/src/girl.erl
  960. $i "Disable warnings; our test .xrl files aren't perfect"
  961. $t echo "ERLC_OPTS=+debug_info" >> $(APP)/Makefile
  962. $i "Build the application"
  963. $t $(MAKE) -C $(APP) $v
  964. $i "Check that all compiled files exist"
  965. $t test -f $(APP)/$(APP).d
  966. $t test -f $(APP)/ebin/$(APP).app
  967. $t test -f $(APP)/ebin/boy.beam
  968. $t test -f $(APP)/ebin/erlang_scan.beam
  969. $t test -f $(APP)/ebin/girl.beam
  970. $t test -f $(APP)/ebin/lfe_scan.beam
  971. $t test -f $(APP)/src/erlang_scan.erl
  972. $t test -f $(APP)/src/lfe_scan.erl
  973. $i "Check that the application was compiled correctly"
  974. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  975. ok = application:start($(APP)), \
  976. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  977. = application:get_key($(APP), modules), \
  978. [{module, M} = code:load_file(M) || M <- Mods], \
  979. halt()"
  980. $i "Touch one .xrl file; check that only required files are rebuilt"
  981. $t printf "%s\n" \
  982. $(APP)/$(APP).d \
  983. $(APP)/ebin/$(APP).app \
  984. $(APP)/ebin/erlang_scan.beam \
  985. $(APP)/src/erlang_scan.erl | sort > $(APP)/EXPECT
  986. $t $(SLEEP)
  987. $t touch $(APP)/src/erlang_scan.xrl
  988. $t $(SLEEP)
  989. $t $(MAKE) -C $(APP) $v
  990. $t find $(APP) -type f -newer $(APP)/src/erlang_scan.xrl | sort | diff $(APP)/EXPECT -
  991. $t rm $(APP)/EXPECT
  992. $i "Check that the application was compiled correctly"
  993. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  994. ok = application:start($(APP)), \
  995. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  996. = application:get_key($(APP), modules), \
  997. [{module, M} = code:load_file(M) || M <- Mods], \
  998. halt()"
  999. $i "Clean the application"
  1000. $t $(MAKE) -C $(APP) clean $v
  1001. $i "Check that source files still exist"
  1002. $t test -f $(APP)/Makefile
  1003. $t test -f $(APP)/erlang.mk
  1004. ifdef LEGACY
  1005. $t test -f $(APP)/src/$(APP).app.src
  1006. endif
  1007. $t test -f $(APP)/src/boy.erl
  1008. $t test -f $(APP)/src/erlang_scan.xrl
  1009. $t test -f $(APP)/src/girl.erl
  1010. $t test -f $(APP)/src/lfe_scan.xrl
  1011. $i "Check that all build artifacts are removed, including intermediates"
  1012. $t test ! -e $(APP)/$(APP).d
  1013. $t test ! -e $(APP)/ebin/
  1014. $t test ! -e $(APP)/src/erlang_scan.erl
  1015. $t test ! -e $(APP)/src/lfe_scan.erl
  1016. $i "Build the application again"
  1017. $t $(MAKE) -C $(APP) $v
  1018. $i "Check that all compiled files exist"
  1019. $t test -f $(APP)/$(APP).d
  1020. $t test -f $(APP)/ebin/$(APP).app
  1021. $t test -f $(APP)/ebin/boy.beam
  1022. $t test -f $(APP)/ebin/erlang_scan.beam
  1023. $t test -f $(APP)/ebin/girl.beam
  1024. $t test -f $(APP)/ebin/lfe_scan.beam
  1025. $t test -f $(APP)/src/erlang_scan.erl
  1026. $t test -f $(APP)/src/lfe_scan.erl
  1027. $i "Check that the application was compiled correctly"
  1028. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1029. ok = application:start($(APP)), \
  1030. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  1031. = application:get_key($(APP), modules), \
  1032. [{module, M} = code:load_file(M) || M <- Mods], \
  1033. halt()"
  1034. core-app-xrl-include: build clean
  1035. $i "Bootstrap a new OTP library named $(APP)"
  1036. $t mkdir $(APP)/
  1037. $t cp ../erlang.mk $(APP)/
  1038. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1039. $i "Download a .xrl file with numerous includes from Gordon"
  1040. $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
  1041. $t curl -s -o $(APP)/src/errvals.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/errvals.hrl
  1042. $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
  1043. $t curl -s -o $(APP)/src/muin_records.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/muin_records.hrl
  1044. $t curl -s -o $(APP)/src/typechecks.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/typechecks.hrl
  1045. $i "Generate unrelated .erl files"
  1046. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1047. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1048. $i "Disable warnings; our test .xrl files aren't perfect"
  1049. $t echo "ERLC_OPTS=+debug_info" >> $(APP)/Makefile
  1050. $i "Build the application"
  1051. $t $(MAKE) -C $(APP) $v
  1052. $i "Check that all compiled files exist"
  1053. $t test -f $(APP)/$(APP).d
  1054. $t test -f $(APP)/ebin/$(APP).app
  1055. $t test -f $(APP)/ebin/boy.beam
  1056. $t test -f $(APP)/ebin/girl.beam
  1057. $t test -f $(APP)/ebin/xfl_lexer.beam
  1058. $t test -f $(APP)/src/xfl_lexer.erl
  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 "Touch the .xrl file; check that only required files are rebuilt"
  1067. $t printf "%s\n" \
  1068. $(APP)/$(APP).d \
  1069. $(APP)/ebin/$(APP).app \
  1070. $(APP)/ebin/xfl_lexer.beam \
  1071. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  1072. $t $(SLEEP)
  1073. $t touch $(APP)/src/xfl_lexer.xrl
  1074. $t $(SLEEP)
  1075. $t $(MAKE) -C $(APP) $v
  1076. $t find $(APP) -type f -newer $(APP)/src/xfl_lexer.xrl | sort | diff $(APP)/EXPECT -
  1077. $t rm $(APP)/EXPECT
  1078. $i "Check that the application was compiled correctly"
  1079. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1080. ok = application:start($(APP)), \
  1081. {ok, Mods = [boy, girl, xfl_lexer]} \
  1082. = application:get_key($(APP), modules), \
  1083. [{module, M} = code:load_file(M) || M <- Mods], \
  1084. halt()"
  1085. $i "Touch a .hrl file included directly; check that only required files are rebuilt"
  1086. $t printf "%s\n" \
  1087. $(APP)/$(APP).d \
  1088. $(APP)/ebin/$(APP).app \
  1089. $(APP)/ebin/xfl_lexer.beam \
  1090. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  1091. $t $(SLEEP)
  1092. $t touch $(APP)/src/typechecks.hrl
  1093. $t $(SLEEP)
  1094. $t $(MAKE) -C $(APP) $v
  1095. $t find $(APP) -type f -newer $(APP)/src/typechecks.hrl | sort | diff $(APP)/EXPECT -
  1096. $t rm $(APP)/EXPECT
  1097. $i "Check that the application was compiled correctly"
  1098. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1099. ok = application:start($(APP)), \
  1100. {ok, Mods = [boy, girl, xfl_lexer]} \
  1101. = application:get_key($(APP), modules), \
  1102. [{module, M} = code:load_file(M) || M <- Mods], \
  1103. halt()"
  1104. $i "Touch a .hrl file included indirectly; check that only required files are rebuilt"
  1105. $t printf "%s\n" \
  1106. $(APP)/$(APP).d \
  1107. $(APP)/ebin/$(APP).app \
  1108. $(APP)/ebin/xfl_lexer.beam \
  1109. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  1110. $t $(SLEEP)
  1111. $t touch $(APP)/src/errvals.hrl
  1112. $t $(SLEEP)
  1113. $t $(MAKE) -C $(APP) $v
  1114. $t find $(APP) -type f -newer $(APP)/src/errvals.hrl | sort | diff $(APP)/EXPECT -
  1115. $t rm $(APP)/EXPECT
  1116. $i "Check that the application was compiled correctly"
  1117. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1118. ok = application:start($(APP)), \
  1119. {ok, Mods = [boy, girl, xfl_lexer]} \
  1120. = application:get_key($(APP), modules), \
  1121. [{module, M} = code:load_file(M) || M <- Mods], \
  1122. halt()"
  1123. $i "Clean the application"
  1124. $t $(MAKE) -C $(APP) clean $v
  1125. $i "Check that source files still exist"
  1126. $t test -f $(APP)/Makefile
  1127. $t test -f $(APP)/erlang.mk
  1128. ifdef LEGACY
  1129. $t test -f $(APP)/src/$(APP).app.src
  1130. endif
  1131. $t test -f $(APP)/src/boy.erl
  1132. $t test -f $(APP)/src/girl.erl
  1133. $t test -f $(APP)/src/errvals.hrl
  1134. $t test -f $(APP)/src/muin_proc_dict.hrl
  1135. $t test -f $(APP)/src/muin_records.hrl
  1136. $t test -f $(APP)/src/typechecks.hrl
  1137. $t test -f $(APP)/src/xfl_lexer.xrl
  1138. $i "Check that all build artifacts are removed, including intermediates"
  1139. $t test ! -e $(APP)/$(APP).d
  1140. $t test ! -e $(APP)/ebin/
  1141. $t test ! -e $(APP)/src/xfl_lexer.erl
  1142. $i "Build the application again"
  1143. $t $(MAKE) -C $(APP) $v
  1144. $i "Check that all compiled files exist"
  1145. $t test -f $(APP)/$(APP).d
  1146. $t test -f $(APP)/ebin/$(APP).app
  1147. $t test -f $(APP)/ebin/boy.beam
  1148. $t test -f $(APP)/ebin/girl.beam
  1149. $t test -f $(APP)/ebin/xfl_lexer.beam
  1150. $t test -f $(APP)/src/xfl_lexer.erl
  1151. $i "Check that the application was compiled correctly"
  1152. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1153. ok = application:start($(APP)), \
  1154. {ok, Mods = [boy, girl, xfl_lexer]} \
  1155. = application:get_key($(APP), modules), \
  1156. [{module, M} = code:load_file(M) || M <- Mods], \
  1157. halt()"
  1158. core-app-yrl: build clean
  1159. $i "Bootstrap a new OTP library named $(APP)"
  1160. $t mkdir $(APP)/
  1161. $t cp ../erlang.mk $(APP)/
  1162. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1163. $i "Download .yrl files from Erlang/OTP"
  1164. $t curl -s -o $(APP)/src/xmerl_xpath_parse.yrl $(OTP_MASTER)/lib/xmerl/src/xmerl_xpath_parse.yrl
  1165. $t curl -s -o $(APP)/src/xref_parser.yrl $(OTP_MASTER)/lib/tools/src/xref_parser.yrl
  1166. $i "Generate unrelated .erl files"
  1167. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1168. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1169. $i "Build the application"
  1170. $t $(MAKE) -C $(APP) $v
  1171. $i "Check that all compiled files exist"
  1172. $t test -f $(APP)/$(APP).d
  1173. $t test -f $(APP)/ebin/$(APP).app
  1174. $t test -f $(APP)/ebin/boy.beam
  1175. $t test -f $(APP)/ebin/girl.beam
  1176. $t test -f $(APP)/ebin/xmerl_xpath_parse.beam
  1177. $t test -f $(APP)/ebin/xref_parser.beam
  1178. $t test -f $(APP)/src/xmerl_xpath_parse.erl
  1179. $t test -f $(APP)/src/xref_parser.erl
  1180. $i "Check that the application was compiled correctly"
  1181. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1182. ok = application:start($(APP)), \
  1183. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  1184. = application:get_key($(APP), modules), \
  1185. [{module, M} = code:load_file(M) || M <- Mods], \
  1186. halt()"
  1187. $i "Touch one .yrl file; check that only required files are rebuilt"
  1188. $t printf "%s\n" \
  1189. $(APP)/$(APP).d \
  1190. $(APP)/ebin/$(APP).app \
  1191. $(APP)/ebin/xref_parser.beam \
  1192. $(APP)/src/xref_parser.erl | sort > $(APP)/EXPECT
  1193. $t $(SLEEP)
  1194. $t touch $(APP)/src/xref_parser.yrl
  1195. $t $(SLEEP)
  1196. $t $(MAKE) -C $(APP) $v
  1197. $t find $(APP) -type f -newer $(APP)/src/xref_parser.yrl | sort | diff $(APP)/EXPECT -
  1198. $t rm $(APP)/EXPECT
  1199. $i "Check that the application was compiled correctly"
  1200. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1201. ok = application:start($(APP)), \
  1202. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  1203. = application:get_key($(APP), modules), \
  1204. [{module, M} = code:load_file(M) || M <- Mods], \
  1205. halt()"
  1206. $i "Clean the application"
  1207. $t $(MAKE) -C $(APP) clean $v
  1208. $i "Check that source files still exist"
  1209. $t test -f $(APP)/Makefile
  1210. $t test -f $(APP)/erlang.mk
  1211. ifdef LEGACY
  1212. $t test -f $(APP)/src/$(APP).app.src
  1213. endif
  1214. $t test -f $(APP)/src/boy.erl
  1215. $t test -f $(APP)/src/girl.erl
  1216. $t test -f $(APP)/src/xmerl_xpath_parse.yrl
  1217. $t test -f $(APP)/src/xref_parser.yrl
  1218. $i "Check that all build artifacts are removed, including intermediates"
  1219. $t test ! -e $(APP)/$(APP).d
  1220. $t test ! -e $(APP)/ebin/
  1221. $t test ! -e $(APP)/src/xmerl_xpath_parse.erl
  1222. $t test ! -e $(APP)/src/xref_parser.erl
  1223. $i "Build the application again"
  1224. $t $(MAKE) -C $(APP) $v
  1225. $i "Check that all compiled files exist"
  1226. $t test -f $(APP)/$(APP).d
  1227. $t test -f $(APP)/ebin/$(APP).app
  1228. $t test -f $(APP)/ebin/boy.beam
  1229. $t test -f $(APP)/ebin/girl.beam
  1230. $t test -f $(APP)/ebin/xmerl_xpath_parse.beam
  1231. $t test -f $(APP)/ebin/xref_parser.beam
  1232. $t test -f $(APP)/src/xmerl_xpath_parse.erl
  1233. $t test -f $(APP)/src/xref_parser.erl
  1234. $i "Check that the application was compiled correctly"
  1235. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1236. ok = application:start($(APP)), \
  1237. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  1238. = application:get_key($(APP), modules), \
  1239. [{module, M} = code:load_file(M) || M <- Mods], \
  1240. halt()"
  1241. core-app-yrl-header: build clean
  1242. $i "Bootstrap a new OTP library named $(APP)"
  1243. $t mkdir $(APP)/
  1244. $t cp ../erlang.mk $(APP)/
  1245. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1246. $i "Create a .yrl file"
  1247. $t echo "Nonterminals E T F." > $(APP)/src/y_parse.yrl
  1248. $t echo "Terminals '+' '*' '(' ')' number." >> $(APP)/src/y_parse.yrl
  1249. $t echo "Rootsymbol E." >> $(APP)/src/y_parse.yrl
  1250. $t echo "E -> E '+' T: {'\$$2', '\$$1', '\$$3'}." >> $(APP)/src/y_parse.yrl
  1251. $t echo "E -> T : '\$$1'." >> $(APP)/src/y_parse.yrl
  1252. $t echo "T -> T '*' F: {'\$$2', '\$$1', '\$$3'}." >> $(APP)/src/y_parse.yrl
  1253. $t echo "T -> F : '\$$1'." >> $(APP)/src/y_parse.yrl
  1254. $t echo "F -> '(' E ')' : '\$$2'." >> $(APP)/src/y_parse.yrl
  1255. $t echo "F -> number : '\$$1'. " >> $(APP)/src/y_parse.yrl
  1256. $i "Create the yrl header file"
  1257. $t mkdir $(APP)/include
  1258. $t echo "-export([forty_two/0])." > $(APP)/include/yecc_header.hrl
  1259. # A bunch of gobbldygook we don't actually care about, they just
  1260. # need to exist so we don't get errors.
  1261. $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
  1262. $t echo "yeccpars1(_,_,_,_,_) -> throw(not_implemented)." >> $(APP)/include/yecc_header.hrl
  1263. $t echo "yeccerror(_) -> throw(not_implemented)." >> $(APP)/include/yecc_header.hrl
  1264. # Required bits done, now part we'll actually test for.
  1265. $t echo "forty_two() -> 42." >> $(APP)/include/yecc_header.hrl
  1266. $i "Generate unrelated .erl files"
  1267. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1268. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1269. $i "Build the application"
  1270. $t YRL_ERLC_OPTS="-I include/yecc_header.hrl" $(MAKE) -C $(APP) $v
  1271. $i "Check that all compiled files exist"
  1272. $t test -f $(APP)/$(APP).d
  1273. $t test -f $(APP)/ebin/$(APP).app
  1274. $t test -f $(APP)/ebin/boy.beam
  1275. $t test -f $(APP)/ebin/girl.beam
  1276. $t test -f $(APP)/ebin/y_parse.beam
  1277. $t test -f $(APP)/src/y_parse.erl
  1278. $i "Check that the application was compiled correctly"
  1279. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1280. ok = application:start($(APP)), \
  1281. {ok, Mods = [boy, girl, y_parse]} \
  1282. = application:get_key($(APP), modules), \
  1283. [{module, M} = code:load_file(M) || M <- Mods], \
  1284. halt()"
  1285. $i "Check the built yecc module used the header"
  1286. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1287. {module, y_parse} = code:load_file(y_parse), \
  1288. 42 = y_parse:forty_two(), \
  1289. halt()"
  1290. $i "Check that the application was compiled correctly"
  1291. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1292. ok = application:start($(APP)), \
  1293. {ok, Mods = [boy, girl, y_parse]} \
  1294. = application:get_key($(APP), modules), \
  1295. [{module, M} = code:load_file(M) || M <- Mods], \
  1296. halt()"
  1297. core-app-yrl-include: build clean
  1298. $i "Bootstrap a new OTP library named $(APP)"
  1299. $t mkdir $(APP)/
  1300. $t cp ../erlang.mk $(APP)/
  1301. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1302. $i "Download a .yrl file with includes from Erlang/OTP"
  1303. $t curl -s -o $(APP)/src/core_parse.yrl $(OTP_MASTER)/lib/compiler/src/core_parse.yrl
  1304. $t curl -s -o $(APP)/src/core_parse.hrl $(OTP_MASTER)/lib/compiler/src/core_parse.hrl
  1305. $i "Generate unrelated .erl files"
  1306. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1307. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1308. $i "Build the application"
  1309. $t $(MAKE) -C $(APP) $v
  1310. $i "Check that all compiled files exist"
  1311. $t test -f $(APP)/$(APP).d
  1312. $t test -f $(APP)/ebin/$(APP).app
  1313. $t test -f $(APP)/ebin/boy.beam
  1314. $t test -f $(APP)/ebin/core_parse.beam
  1315. $t test -f $(APP)/ebin/girl.beam
  1316. $t test -f $(APP)/src/core_parse.erl
  1317. $i "Check that the application was compiled correctly"
  1318. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1319. ok = application:start($(APP)), \
  1320. {ok, Mods = [boy, core_parse, girl]} \
  1321. = application:get_key($(APP), modules), \
  1322. [{module, M} = code:load_file(M) || M <- Mods], \
  1323. halt()"
  1324. $i "Touch the .yrl file; check that only required files are rebuilt"
  1325. $t printf "%s\n" \
  1326. $(APP)/$(APP).d \
  1327. $(APP)/ebin/$(APP).app \
  1328. $(APP)/ebin/core_parse.beam \
  1329. $(APP)/src/core_parse.erl | sort > $(APP)/EXPECT
  1330. $t $(SLEEP)
  1331. $t touch $(APP)/src/core_parse.yrl
  1332. $t $(SLEEP)
  1333. $t $(MAKE) -C $(APP) $v
  1334. $t find $(APP) -type f -newer $(APP)/src/core_parse.yrl | sort | diff $(APP)/EXPECT -
  1335. $t rm $(APP)/EXPECT
  1336. $i "Check that the application was compiled correctly"
  1337. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1338. ok = application:start($(APP)), \
  1339. {ok, Mods = [boy, core_parse, girl]} \
  1340. = application:get_key($(APP), modules), \
  1341. [{module, M} = code:load_file(M) || M <- Mods], \
  1342. halt()"
  1343. $i "Touch the .hrl file included; check that only required files are rebuilt"
  1344. $t printf "%s\n" \
  1345. $(APP)/$(APP).d \
  1346. $(APP)/ebin/$(APP).app \
  1347. $(APP)/ebin/core_parse.beam \
  1348. $(APP)/src/core_parse.erl | sort > $(APP)/EXPECT
  1349. $t $(SLEEP)
  1350. $t touch $(APP)/src/core_parse.hrl
  1351. $t $(SLEEP)
  1352. $t $(MAKE) -C $(APP) $v
  1353. $t find $(APP) -type f -newer $(APP)/src/core_parse.hrl | sort | diff $(APP)/EXPECT -
  1354. $t rm $(APP)/EXPECT
  1355. $i "Check that the application was compiled correctly"
  1356. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1357. ok = application:start($(APP)), \
  1358. {ok, Mods = [boy, core_parse, girl]} \
  1359. = application:get_key($(APP), modules), \
  1360. [{module, M} = code:load_file(M) || M <- Mods], \
  1361. halt()"
  1362. $i "Clean the application"
  1363. $t $(MAKE) -C $(APP) clean $v
  1364. $i "Check that source files still exist"
  1365. $t test -f $(APP)/Makefile
  1366. $t test -f $(APP)/erlang.mk
  1367. ifdef LEGACY
  1368. $t test -f $(APP)/src/$(APP).app.src
  1369. endif
  1370. $t test -f $(APP)/src/boy.erl
  1371. $t test -f $(APP)/src/core_parse.hrl
  1372. $t test -f $(APP)/src/core_parse.yrl
  1373. $t test -f $(APP)/src/girl.erl
  1374. $i "Check that all build artifacts are removed, including intermediates"
  1375. $t test ! -e $(APP)/$(APP).d
  1376. $t test ! -e $(APP)/ebin/
  1377. $t test ! -e $(APP)/src/core_parse.erl
  1378. $i "Build the application again"
  1379. $t $(MAKE) -C $(APP) $v
  1380. $i "Check that all compiled files exist"
  1381. $t test -f $(APP)/$(APP).d
  1382. $t test -f $(APP)/ebin/$(APP).app
  1383. $t test -f $(APP)/ebin/boy.beam
  1384. $t test -f $(APP)/ebin/core_parse.beam
  1385. $t test -f $(APP)/ebin/girl.beam
  1386. $t test -f $(APP)/src/core_parse.erl
  1387. $i "Check that the application was compiled correctly"
  1388. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1389. ok = application:start($(APP)), \
  1390. {ok, Mods = [boy, core_parse, girl]} \
  1391. = application:get_key($(APP), modules), \
  1392. [{module, M} = code:load_file(M) || M <- Mods], \
  1393. halt()"