core_app.mk 57 KB

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