core_app.mk 88 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695
  1. # Core: Building applications.
  2. CORE_APP_TARGETS = $(call list_targets,core-app)
  3. .PHONY: core-app $(CORE_APP_TARGETS)
  4. core-app: $(CORE_APP_TARGETS)
  5. ifdef LEGACY
  6. core-app-appsrc-change: init
  7. $i "Bootstrap a new OTP application named $(APP)"
  8. $t mkdir $(APP)/
  9. $t cp ../erlang.mk $(APP)/
  10. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  11. $i "Build the application"
  12. $t $(MAKE) -C $(APP) $v
  13. $i "Touch the .app.src file; check that only the .app file gets rebuilt"
  14. $t printf "%s\n" $(APP)/ebin/$(APP).app > $(APP)/EXPECT
  15. $t $(SLEEP)
  16. $t touch $(APP)/src/$(APP).app.src
  17. $t $(SLEEP)
  18. $t $(MAKE) -C $(APP) $v
  19. $t find $(APP) -type f -newer $(APP)/src/$(APP).app.src | sort | diff $(APP)/EXPECT -
  20. $t rm $(APP)/EXPECT
  21. endif
  22. core-app-asn1: init
  23. $i "Bootstrap a new OTP library named $(APP)"
  24. $t mkdir $(APP)/
  25. $t cp ../erlang.mk $(APP)/
  26. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  27. $i "Download .asn1 files from Erlang/OTP"
  28. $t mkdir $(APP)/asn1/
  29. $t curl -s -o $(APP)/asn1/CAP.asn1 $(OTP_MASTER)/lib/asn1/test/asn1_SUITE_data/CAP.asn1
  30. $t curl -s -o $(APP)/asn1/Def.asn1 $(OTP_MASTER)/lib/asn1/test/asn1_SUITE_data/Def.asn1
  31. $i "Generate .erl files dependent from headers generated by .asn1 files"
  32. $t printf "%s\n" "-module(use_cap)." "-include(\"CAP.hrl\")." > $(APP)/src/use_cap.erl
  33. $t printf "%s\n" "-module(use_def)." "-include(\"Def.hrl\")." > $(APP)/src/use_def.erl
  34. $i "Generate an unrelated .hrl file"
  35. $t mkdir $(APP)/include/
  36. $t touch $(APP)/include/unrelated.hrl
  37. $i "Build the application"
  38. $t $(MAKE) -C $(APP) $v
  39. $i "Check that all compiled files exist"
  40. $t test -f $(APP)/$(APP).d
  41. $t test -f $(APP)/ebin/$(APP).app
  42. $t test -f $(APP)/ebin/CAP.beam
  43. $t test -f $(APP)/ebin/Def.beam
  44. $t test -f $(APP)/ebin/use_cap.beam
  45. $t test -f $(APP)/ebin/use_def.beam
  46. $t test -f $(APP)/include/CAP.asn1db
  47. $t test -f $(APP)/include/CAP.hrl
  48. $t test -f $(APP)/include/Def.asn1db
  49. $t test -f $(APP)/include/Def.hrl
  50. $t test -f $(APP)/src/CAP.erl
  51. $t test -f $(APP)/src/Def.erl
  52. $i "Check that the application was compiled correctly"
  53. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  54. ok = application:start($(APP)), \
  55. {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
  56. = application:get_key($(APP), modules), \
  57. [{module, M} = code:load_file(M) || M <- Mods], \
  58. halt()"
  59. $i "Touch one .asn1 file; check that only required files are rebuilt"
  60. # The use_cap.erl gets touched because of its dependency to CAP.hrl.
  61. $t printf "%s\n" \
  62. $(APP)/$(APP).d \
  63. $(APP)/ebin/$(APP).app \
  64. $(APP)/ebin/CAP.beam \
  65. $(APP)/ebin/use_cap.beam \
  66. $(APP)/include/CAP.asn1db \
  67. $(APP)/include/CAP.hrl \
  68. $(APP)/src/CAP.erl \
  69. $(APP)/src/use_cap.erl | sort > $(APP)/EXPECT
  70. $t $(SLEEP)
  71. $t touch $(APP)/asn1/CAP.asn1
  72. $t $(SLEEP)
  73. $t $(MAKE) -C $(APP) $v
  74. $t find $(APP) -type f -newer $(APP)/asn1/CAP.asn1 | sort | diff $(APP)/EXPECT -
  75. $t rm $(APP)/EXPECT
  76. $i "Check that the application was compiled correctly"
  77. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  78. ok = application:start($(APP)), \
  79. {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
  80. = application:get_key($(APP), modules), \
  81. [{module, M} = code:load_file(M) || M <- Mods], \
  82. halt()"
  83. $i "Clean the application"
  84. $t $(MAKE) -C $(APP) clean $v
  85. $i "Check that source files still exist"
  86. $t test -f $(APP)/Makefile
  87. $t test -f $(APP)/erlang.mk
  88. $t test -f $(APP)/asn1/CAP.asn1
  89. $t test -f $(APP)/asn1/Def.asn1
  90. $t test -f $(APP)/include/unrelated.hrl
  91. ifdef LEGACY
  92. $t test -f $(APP)/src/$(APP).app.src
  93. endif
  94. $t test -f $(APP)/src/use_cap.erl
  95. $t test -f $(APP)/src/use_def.erl
  96. $i "Check that all build artifacts are removed, including intermediates"
  97. $t test ! -e $(APP)/$(APP).d
  98. $t test ! -e $(APP)/ebin/
  99. $t test ! -e $(APP)/include/CAP.asn1db
  100. $t test ! -e $(APP)/include/CAP.hrl
  101. $t test ! -e $(APP)/include/Def.asn1db
  102. $t test ! -e $(APP)/include/Def.hrl
  103. $t test ! -e $(APP)/src/CAP.erl
  104. $t test ! -e $(APP)/src/Def.erl
  105. $i "Build the application again"
  106. $t $(MAKE) -C $(APP) $v
  107. $i "Check that all compiled files exist"
  108. $t test -f $(APP)/$(APP).d
  109. $t test -f $(APP)/ebin/$(APP).app
  110. $t test -f $(APP)/ebin/CAP.beam
  111. $t test -f $(APP)/ebin/Def.beam
  112. $t test -f $(APP)/ebin/use_cap.beam
  113. $t test -f $(APP)/ebin/use_def.beam
  114. $t test -f $(APP)/include/CAP.asn1db
  115. $t test -f $(APP)/include/CAP.hrl
  116. $t test -f $(APP)/include/Def.asn1db
  117. $t test -f $(APP)/include/Def.hrl
  118. $t test -f $(APP)/src/CAP.erl
  119. $t test -f $(APP)/src/Def.erl
  120. $i "Check that the application was compiled correctly"
  121. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  122. ok = application:start($(APP)), \
  123. {ok, Mods = ['CAP', 'Def', use_cap, use_def]} \
  124. = application:get_key($(APP), modules), \
  125. [{module, M} = code:load_file(M) || M <- Mods], \
  126. halt()"
  127. $i "Clean the application"
  128. $t $(MAKE) -C $(APP) clean $v
  129. $i "Build the application with ERLC_ASN1_OPTS set"
  130. $t echo "ERLC_ASN1_OPTS += +'{record_name_prefix,\"FOO-\"}'" >> $(APP)/Makefile
  131. $t $(MAKE) -C $(APP) $v
  132. $i "Check that the application was built with ERLC_ASN1_OPTS set"
  133. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  134. Attrs = 'Def':module_info(attributes), \
  135. Asn1Info = proplists:get_value(asn1_info, Attrs), \
  136. Opts = proplists:get_value(options, Asn1Info), \
  137. true = lists:member({record_name_prefix, \"FOO-\"}, Opts), \
  138. halt()"
  139. core-app-asn1-maps: init
  140. $i "Bootstrap a new OTP library named $(APP)"
  141. $t mkdir $(APP)/
  142. $t cp ../erlang.mk $(APP)/
  143. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  144. $i "Set ERLC_ASN1_OPTS = +maps in the Makefile"
  145. $t perl -ni.bak -e 'print;if ($$.==1) {print "ERLC_ASN1_OPTS = +maps\n"}' $(APP)/Makefile
  146. $i "Download .asn1 files from Erlang/OTP"
  147. $t mkdir $(APP)/asn1/
  148. $t curl -s -o $(APP)/asn1/CAP.asn1 $(OTP_MASTER)/lib/asn1/test/asn1_SUITE_data/CAP.asn1
  149. $t curl -s -o $(APP)/asn1/Def.asn1 $(OTP_MASTER)/lib/asn1/test/asn1_SUITE_data/Def.asn1
  150. $i "Build the application"
  151. $t $(MAKE) -C $(APP) $v
  152. $i "Check that all compiled files exist"
  153. $t test -f $(APP)/$(APP).d
  154. $t test -f $(APP)/ebin/$(APP).app
  155. $t test -f $(APP)/ebin/CAP.beam
  156. $t test -f $(APP)/ebin/Def.beam
  157. $t test -f $(APP)/include/CAP.asn1db
  158. $t ! test -e $(APP)/include/CAP.hrl
  159. $t test -f $(APP)/include/Def.asn1db
  160. $t ! test -e $(APP)/include/Def.hrl
  161. $t test -f $(APP)/src/CAP.erl
  162. $t test -f $(APP)/src/Def.erl
  163. $i "Check that the application was compiled correctly"
  164. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  165. ok = application:start($(APP)), \
  166. {ok, Mods = ['CAP', 'Def']} \
  167. = application:get_key($(APP), modules), \
  168. [{module, M} = code:load_file(M) || M <- Mods], \
  169. halt()"
  170. core-app-auto-git-id: init
  171. $i "Bootstrap a new OTP library named $(APP)"
  172. $t mkdir $(APP)/
  173. $t cp ../erlang.mk $(APP)/
  174. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  175. $i "Make it a git repository"
  176. $t cd $(APP) && \
  177. git init -q && \
  178. git config user.email "testsuite@erlang.mk" && \
  179. git config user.name "test suite" && \
  180. git add . && \
  181. git commit -q --no-gpg-sign -m "Tests"
  182. $i "Build the application"
  183. $t $(MAKE) -C $(APP) $v
  184. ifdef LEGACY
  185. # Legacy replaces {id, "git"} always regardless of built as a dependency.
  186. $i "Check that the generated .app file has an id key"
  187. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  188. ok = application:start($(APP)), \
  189. {ok, ID} = application:get_key($(APP), id), \
  190. true = ID =/= [], \
  191. halt()"
  192. else
  193. # If there is no .app.src though, only fill in id when built as a dependency.
  194. $i "Check that the generated .app file has no id key"
  195. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  196. ok = application:start($(APP)), \
  197. {ok, []} = application:get_key($(APP), id), \
  198. halt()"
  199. endif
  200. $i "Clean the application"
  201. $t $(MAKE) -C $(APP) clean $v
  202. $i "Build the application with IS_DEP=1"
  203. $t $(MAKE) -C $(APP) IS_DEP=1 $v
  204. $i "Check that the generated .app file has an id key"
  205. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  206. ok = application:start($(APP)), \
  207. {ok, ID} = application:get_key($(APP), id), \
  208. true = ID =/= [], \
  209. halt()"
  210. ifndef LEGACY
  211. core-app-env: init
  212. $i "Bootstrap a new OTP library named $(APP)"
  213. $t mkdir $(APP)/
  214. $t cp ../erlang.mk $(APP)/
  215. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  216. $i "Define PROJECT_ENV"
  217. $t echo "PROJECT_ENV = [{test_key, test_value}]" >> $(APP)/Makefile
  218. $i "Build the application"
  219. $t $(MAKE) -C $(APP) $v
  220. $i "Check that the application was compiled correctly"
  221. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  222. ok = application:load($(APP)), \
  223. {ok, test_value} = application:get_env($(APP), test_key), \
  224. halt()"
  225. $i "Define PROJECT_ENV with escape in string, special char"
  226. $t echo "PROJECT_ENV = [{test_atom, '\\\$$\$$test'}, {test_key, \"\\\"test_\\tvalue\\\"\"}]" >> $(APP)/Makefile
  227. $i "Build the application"
  228. $t $(MAKE) -C $(APP) $v
  229. $i "Check that the application was compiled correctly"
  230. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  231. ok = application:load($(APP)), \
  232. {ok, \"\\\"test_\\tvalue\\\"\"} = application:get_env($(APP), test_key), \
  233. {ok, '\\\$$test'} = application:get_env($(APP), test_atom), \
  234. halt()"
  235. core-app-env-invalid: init
  236. $i "Bootstrap a new OTP library named $(APP)"
  237. $t mkdir $(APP)/
  238. $t cp ../erlang.mk $(APP)/
  239. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  240. $i "Define an invalid PROJECT_ENV"
  241. $t echo "PROJECT_ENV = [{test_key, test_value" >> $(APP)/Makefile
  242. $i "Build the application"
  243. $t ! $(MAKE) -C $(APP) $v
  244. endif
  245. core-app-erlc-exclude: init
  246. $i "Bootstrap a new OTP library named $(APP)"
  247. $t mkdir $(APP)/
  248. $t cp ../erlang.mk $(APP)/
  249. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  250. $i "Generate .erl files"
  251. $t echo "-module(boy)." > $(APP)/src/boy.erl
  252. $t echo "-module(girl)." > $(APP)/src/girl.erl
  253. $i "Exclude boy.erl from the compilation"
  254. $t echo "ERLC_EXCLUDE = boy" >> $(APP)/Makefile
  255. $i "Build the application"
  256. $t $(MAKE) -C $(APP) $v
  257. $i "Check that boy.erl was not compiled"
  258. $t test ! -e $(APP)/ebin/boy.beam
  259. $i "Check that the application was compiled correctly (without boy.erl)"
  260. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  261. ok = application:start($(APP)), \
  262. {ok, Mods = [girl]} \
  263. = application:get_key($(APP), modules), \
  264. [{module, M} = code:load_file(M) || M <- Mods], \
  265. halt()"
  266. core-app-erlc-opts: init
  267. $i "Bootstrap a new OTP library named $(APP)"
  268. $t mkdir $(APP)/
  269. $t cp ../erlang.mk $(APP)/
  270. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  271. $i "Define an empty ERLC_OPTS (without debug_info)"
  272. $t echo "ERLC_OPTS =" >> $(APP)/Makefile
  273. $i "Generate .erl files"
  274. $t echo "-module(boy)." > $(APP)/src/boy.erl
  275. $t echo "-module(girl)." > $(APP)/src/girl.erl
  276. $i "Build the application"
  277. $t $(MAKE) -C $(APP) $v
  278. $i "Check that the application was compiled correctly (without debug_info)"
  279. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  280. ok = application:start($(APP)), \
  281. {ok, Mods = [boy, girl]} \
  282. = application:get_key($(APP), modules), \
  283. [{module, M} = code:load_file(M) || M <- Mods], \
  284. false = proplists:is_defined(debug_info, proplists:get_value(options, boy:module_info(compile))), \
  285. false = proplists:is_defined(debug_info, proplists:get_value(options, girl:module_info(compile))), \
  286. halt()"
  287. core-app-erlc-opts-filter: init
  288. $i "Bootstrap a new OTP library named $(APP)"
  289. $t mkdir $(APP)/
  290. $t cp ../erlang.mk $(APP)/
  291. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  292. $i "Define ERLC_OPTS filtering out debug_info"
  293. $t echo "ERLC_OPTS := \$$(filter-out +debug_info,\$$(ERLC_OPTS))" >> $(APP)/Makefile
  294. $i "Generate .erl files"
  295. $t echo "-module(boy)." > $(APP)/src/boy.erl
  296. $t echo "-module(girl)." > $(APP)/src/girl.erl
  297. $i "Build the application"
  298. $t $(MAKE) -C $(APP) $v
  299. $i "Check that the application was compiled correctly (without debug_info)"
  300. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  301. ok = application:start($(APP)), \
  302. {ok, Mods = [boy, girl]} \
  303. = application:get_key($(APP), modules), \
  304. [{module, M} = code:load_file(M) || M <- Mods], \
  305. false = proplists:is_defined(debug_info, proplists:get_value(options, boy:module_info(compile))), \
  306. false = proplists:is_defined(debug_info, proplists:get_value(options, girl:module_info(compile))), \
  307. halt()"
  308. core-app-error: init
  309. $i "Bootstrap a new OTP library named $(APP)"
  310. $t mkdir $(APP)/
  311. $t cp ../erlang.mk $(APP)/
  312. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  313. $i "Generate a bad .erl files"
  314. $t touch $(APP)/src/breaking.erl
  315. $i "Generate unrelated .erl files"
  316. $t echo "-module(boy)." > $(APP)/src/boy.erl
  317. $t echo "-module(girl)." > $(APP)/src/girl.erl
  318. $i "Check that trying to build returns non-zero"
  319. $t ! $(MAKE) -C $(APP) $v
  320. ifndef LEGACY
  321. core-app-extra-keys: init
  322. $i "Bootstrap a new OTP library named $(APP)"
  323. $t mkdir $(APP)/
  324. $t cp ../erlang.mk $(APP)/
  325. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  326. $i "Define PROJECT_APP_EXTRA_KEYS"
  327. $t printf "define PROJECT_APP_EXTRA_KEYS\n\t{maxT, 10000},\n\t{non_standard_key, test_value}\nendef\n" >> $(APP)/Makefile
  328. $i "Build the application"
  329. $t $(MAKE) -C $(APP) $v
  330. $i "Check that the application was compiled correctly"
  331. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  332. ok = application:load($(APP)), \
  333. {ok, 10000} = application:get_key($(APP), maxT), \
  334. AppFile = filename:join(code:lib_dir($(APP), ebin), atom_to_list($(APP)) ++ \".app\"), \
  335. {ok, [App]} = file:consult(AppFile), \
  336. {application, $(APP), Props} = App, \
  337. test_value = proplists:get_value(non_standard_key, Props),\
  338. halt()"
  339. $i "Define PROJECT_APP_EXTRA_KEYS with escape in string, special char"
  340. $t echo "PROJECT_APP_EXTRA_KEYS = {non_standard_atom, '\\\$$\$$my_app'}, {non_standard_string, \"\\\"test_\\tvalue\\\"\"}" >> $(APP)/Makefile
  341. $i "Build the application"
  342. $t $(MAKE) -C $(APP) $v
  343. $i "Check that the application was compiled correctly"
  344. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  345. ok = application:load($(APP)), \
  346. AppFile = filename:join(code:lib_dir($(APP), ebin), atom_to_list($(APP)) ++ \".app\"), \
  347. {ok, [App]} = file:consult(AppFile), \
  348. {application, $(APP), Props} = App, \
  349. '\\\$$my_app' = proplists:get_value(non_standard_atom, Props),\
  350. \"\\\"test_\\tvalue\\\"\" = proplists:get_value(non_standard_string, Props),\
  351. halt()"
  352. endif
  353. core-app-generate-erl: init
  354. $i "Bootstrap a new OTP library named $(APP)"
  355. $t mkdir $(APP)/
  356. $t cp ../erlang.mk $(APP)/
  357. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  358. $i "Create a fake script file to be used as dependency"
  359. $t touch $(APP)/script.sh
  360. $i "Append rules to the Makefile to generate a .erl module"
  361. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  362. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@" >> $(APP)/Makefile
  363. $i "Generate unrelated .erl files"
  364. $t echo "-module(boy)." > $(APP)/src/boy.erl
  365. $t echo "-module(girl)." > $(APP)/src/girl.erl
  366. $i "Build the application"
  367. $t $(MAKE) -C $(APP) $v
  368. $i "Check that all compiled files exist"
  369. $t test -f $(APP)/$(APP).d
  370. $t test -f $(APP)/ebin/$(APP).app
  371. $t test -f $(APP)/ebin/boy.beam
  372. $t test -f $(APP)/ebin/generated.beam
  373. $t test -f $(APP)/ebin/girl.beam
  374. $t test -f $(APP)/src/generated.erl
  375. $i "Check that the application was compiled correctly"
  376. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  377. ok = application:start($(APP)), \
  378. {ok, Mods = [boy, generated, girl]} \
  379. = application:get_key($(APP), modules), \
  380. [{module, M} = code:load_file(M) || M <- Mods], \
  381. halt()"
  382. $i "Touch the script file; check that only required files are rebuilt"
  383. $t printf "%s\n" \
  384. $(APP)/$(APP).d \
  385. $(APP)/ebin/$(APP).app \
  386. $(APP)/ebin/generated.beam \
  387. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  388. $t $(SLEEP)
  389. $t touch $(APP)/script.sh
  390. $t $(SLEEP)
  391. $t $(MAKE) -C $(APP) $v
  392. $t find $(APP) -type f -newer $(APP)/script.sh | sort | diff $(APP)/EXPECT -
  393. $t rm $(APP)/EXPECT
  394. $i "Check that the application was compiled correctly"
  395. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  396. ok = application:start($(APP)), \
  397. {ok, Mods = [boy, generated, girl]} \
  398. = application:get_key($(APP), modules), \
  399. [{module, M} = code:load_file(M) || M <- Mods], \
  400. halt()"
  401. $i "Clean the application"
  402. $t $(MAKE) -C $(APP) clean $v
  403. $i "Check that source files still exist"
  404. $t test -f $(APP)/Makefile
  405. $t test -f $(APP)/erlang.mk
  406. $t test -f $(APP)/script.sh
  407. ifdef LEGACY
  408. $t test -f $(APP)/src/$(APP).app.src
  409. endif
  410. $t test -f $(APP)/src/boy.erl
  411. $t test -f $(APP)/src/girl.erl
  412. $i "Check that the generated .erl file still exists"
  413. $t test -f $(APP)/src/generated.erl
  414. $i "Check that all build artifacts are removed"
  415. $t test ! -e $(APP)/$(APP).d
  416. $t test ! -e $(APP)/ebin/
  417. $i "Add a rule to remove the generated .erl file on clean"
  418. $t echo "clean:: ; rm src/generated.erl" >> $(APP)/Makefile
  419. $i "Clean the application again"
  420. $t $(MAKE) -C $(APP) clean $v
  421. $i "Check that the generated .erl file was removed"
  422. $t test ! -e $(APP)/src/generated.erl
  423. $i "Build the application again"
  424. $t $(MAKE) -C $(APP) $v
  425. $i "Check that all compiled files exist"
  426. $t test -f $(APP)/$(APP).d
  427. $t test -f $(APP)/ebin/$(APP).app
  428. $t test -f $(APP)/ebin/boy.beam
  429. $t test -f $(APP)/ebin/generated.beam
  430. $t test -f $(APP)/ebin/girl.beam
  431. $t test -f $(APP)/src/generated.erl
  432. $i "Check that the application was compiled correctly"
  433. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  434. ok = application:start($(APP)), \
  435. {ok, Mods = [boy, generated, girl]} \
  436. = application:get_key($(APP), modules), \
  437. [{module, M} = code:load_file(M) || M <- Mods], \
  438. halt()"
  439. core-app-generate-erl-include: init
  440. $i "Bootstrap a new OTP library named $(APP)"
  441. $t mkdir $(APP)/
  442. $t cp ../erlang.mk $(APP)/
  443. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  444. $i "Create a fake script file to be used as dependency"
  445. $t touch $(APP)/script.sh
  446. $i "Append rules to the Makefile to generate a .erl module"
  447. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  448. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@; echo \"-include(\\\"included.hrl\\\").\" >> \$$@" >> $(APP)/Makefile
  449. $i "Generate the .hrl file"
  450. $t mkdir $(APP)/include/
  451. $t touch $(APP)/include/included.hrl
  452. $i "Generate unrelated .erl files"
  453. $t echo "-module(boy)." > $(APP)/src/boy.erl
  454. $t echo "-module(girl)." > $(APP)/src/girl.erl
  455. $i "Build the application"
  456. $t $(MAKE) -C $(APP) $v
  457. $i "Check that all compiled files exist"
  458. $t test -f $(APP)/$(APP).d
  459. $t test -f $(APP)/ebin/$(APP).app
  460. $t test -f $(APP)/ebin/boy.beam
  461. $t test -f $(APP)/ebin/generated.beam
  462. $t test -f $(APP)/ebin/girl.beam
  463. $t test -f $(APP)/src/generated.erl
  464. $i "Check that the application was compiled correctly"
  465. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  466. ok = application:start($(APP)), \
  467. {ok, Mods = [boy, generated, girl]} \
  468. = application:get_key($(APP), modules), \
  469. [{module, M} = code:load_file(M) || M <- Mods], \
  470. halt()"
  471. $i "Touch the .hrl file; check that only required files are rebuilt"
  472. $t printf "%s\n" \
  473. $(APP)/$(APP).d \
  474. $(APP)/ebin/$(APP).app \
  475. $(APP)/ebin/generated.beam \
  476. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  477. $t $(SLEEP)
  478. $t touch $(APP)/include/included.hrl
  479. $t $(SLEEP)
  480. $t $(MAKE) -C $(APP) $v
  481. $t find $(APP) -type f -newer $(APP)/include/included.hrl | sort | diff $(APP)/EXPECT -
  482. $t rm $(APP)/EXPECT
  483. $i "Check that the application was compiled correctly"
  484. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  485. ok = application:start($(APP)), \
  486. {ok, Mods = [boy, generated, girl]} \
  487. = application:get_key($(APP), modules), \
  488. [{module, M} = code:load_file(M) || M <- Mods], \
  489. halt()"
  490. core-app-generate-erl-prepend: init
  491. $i "Bootstrap a new OTP library named $(APP)"
  492. $t mkdir $(APP)/
  493. $t cp ../erlang.mk $(APP)/
  494. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  495. $i "Create a fake script file to be used as dependency"
  496. $t touch $(APP)/script.sh
  497. $i "Generate a Makefile and prepend rules that generate a .erl module"
  498. $t echo "PROJECT = $(APP)" > $(APP)/Makefile
  499. $t echo ".DEFAULT_GOAL = all" >> $(APP)/Makefile
  500. $t echo "\$$(PROJECT).d:: src/generated.erl" >> $(APP)/Makefile
  501. $t echo "src/generated.erl:: script.sh; echo \"-module(generated).\" > \$$@" >> $(APP)/Makefile
  502. $t echo "include erlang.mk" >> $(APP)/Makefile
  503. $i "Generate unrelated .erl files"
  504. $t echo "-module(boy)." > $(APP)/src/boy.erl
  505. $t echo "-module(girl)." > $(APP)/src/girl.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/boy.beam
  512. $t test -f $(APP)/ebin/generated.beam
  513. $t test -f $(APP)/ebin/girl.beam
  514. $t test -f $(APP)/src/generated.erl
  515. $i "Check that the application was compiled correctly"
  516. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  517. ok = application:start($(APP)), \
  518. {ok, Mods = [boy, generated, girl]} \
  519. = application:get_key($(APP), modules), \
  520. [{module, M} = code:load_file(M) || M <- Mods], \
  521. halt()"
  522. $i "Touch the script file; check that only required files are rebuilt"
  523. $t printf "%s\n" \
  524. $(APP)/$(APP).d \
  525. $(APP)/ebin/$(APP).app \
  526. $(APP)/ebin/generated.beam \
  527. $(APP)/src/generated.erl | sort > $(APP)/EXPECT
  528. $t $(SLEEP)
  529. $t touch $(APP)/script.sh
  530. $t $(SLEEP)
  531. $t $(MAKE) -C $(APP) $v
  532. $t find $(APP) -type f -newer $(APP)/script.sh | sort | diff $(APP)/EXPECT -
  533. $t rm $(APP)/EXPECT
  534. $i "Check that the application was compiled correctly"
  535. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  536. ok = application:start($(APP)), \
  537. {ok, Mods = [boy, generated, girl]} \
  538. = application:get_key($(APP), modules), \
  539. [{module, M} = code:load_file(M) || M <- Mods], \
  540. halt()"
  541. $i "Clean the application"
  542. $t $(MAKE) -C $(APP) clean $v
  543. $i "Check that source files still exist"
  544. $t test -f $(APP)/Makefile
  545. $t test -f $(APP)/erlang.mk
  546. $t test -f $(APP)/script.sh
  547. ifdef LEGACY
  548. $t test -f $(APP)/src/$(APP).app.src
  549. endif
  550. $t test -f $(APP)/src/boy.erl
  551. $t test -f $(APP)/src/girl.erl
  552. $i "Check that the generated .erl file still exists"
  553. $t test -f $(APP)/src/generated.erl
  554. $i "Check that all build artifacts are removed"
  555. $t test ! -e $(APP)/$(APP).d
  556. $t test ! -e $(APP)/ebin/
  557. $i "Add a rule to remove the generated .erl file on clean"
  558. $t echo "clean:: ; rm src/generated.erl" >> $(APP)/Makefile
  559. $i "Clean the application again"
  560. $t $(MAKE) -C $(APP) clean $v
  561. $i "Check that the generated .erl file was removed"
  562. $t test ! -e $(APP)/src/generated.erl
  563. $i "Build the application again"
  564. $t $(MAKE) -C $(APP) $v
  565. $i "Check that all compiled files exist"
  566. $t test -f $(APP)/$(APP).d
  567. $t test -f $(APP)/ebin/$(APP).app
  568. $t test -f $(APP)/ebin/boy.beam
  569. $t test -f $(APP)/ebin/generated.beam
  570. $t test -f $(APP)/ebin/girl.beam
  571. $t test -f $(APP)/src/generated.erl
  572. $i "Check that the application was compiled correctly"
  573. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  574. ok = application:start($(APP)), \
  575. {ok, Mods = [boy, generated, girl]} \
  576. = application:get_key($(APP), modules), \
  577. [{module, M} = code:load_file(M) || M <- Mods], \
  578. halt()"
  579. core-app-hrl: init
  580. $i "Bootstrap a new OTP library named $(APP)"
  581. $t mkdir $(APP)/
  582. $t cp ../erlang.mk $(APP)/
  583. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  584. $i "Generate .hrl files"
  585. $t mkdir $(APP)/include/
  586. $t touch $(APP)/include/blue.hrl $(APP)/include/red.hrl
  587. $i "Generate .erl files dependent from headers"
  588. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  589. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  590. $i "Build the application"
  591. $t $(MAKE) -C $(APP) $v
  592. $i "Check that all compiled files exist"
  593. $t test -f $(APP)/$(APP).d
  594. $t test -f $(APP)/ebin/$(APP).app
  595. $t test -f $(APP)/ebin/use_blue.beam
  596. $t test -f $(APP)/ebin/use_red.beam
  597. $i "Check that the application was compiled correctly"
  598. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  599. ok = application:start($(APP)), \
  600. {ok, Mods = [use_blue, use_red]} \
  601. = application:get_key($(APP), modules), \
  602. [{module, M} = code:load_file(M) || M <- Mods], \
  603. halt()"
  604. $i "Touch one .hrl file; check that only required files are rebuilt"
  605. # The use_red.erl gets touched because of its dependency to red.hrl.
  606. $t printf "%s\n" \
  607. $(APP)/$(APP).d \
  608. $(APP)/ebin/$(APP).app \
  609. $(APP)/ebin/use_red.beam \
  610. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  611. $t $(SLEEP)
  612. $t touch $(APP)/include/red.hrl
  613. $t $(SLEEP)
  614. $t $(MAKE) -C $(APP) $v
  615. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  616. $t rm $(APP)/EXPECT
  617. $i "Check that the application was compiled correctly"
  618. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  619. ok = application:start($(APP)), \
  620. {ok, Mods = [use_blue, use_red]} \
  621. = application:get_key($(APP), modules), \
  622. [{module, M} = code:load_file(M) || M <- Mods], \
  623. halt()"
  624. $i "Clean the application"
  625. $t $(MAKE) -C $(APP) clean $v
  626. $i "Check that source files still exist"
  627. $t test -f $(APP)/Makefile
  628. $t test -f $(APP)/erlang.mk
  629. $t test -f $(APP)/include/blue.hrl
  630. $t test -f $(APP)/include/red.hrl
  631. ifdef LEGACY
  632. $t test -f $(APP)/src/$(APP).app.src
  633. endif
  634. $t test -f $(APP)/src/use_blue.erl
  635. $t test -f $(APP)/src/use_red.erl
  636. $i "Check that all build artifacts are removed"
  637. $t test ! -e $(APP)/$(APP).d
  638. $t test ! -e $(APP)/ebin/
  639. $i "Build the application again"
  640. $t $(MAKE) -C $(APP) $v
  641. $i "Check that all compiled files exist"
  642. $t test -f $(APP)/$(APP).d
  643. $t test -f $(APP)/ebin/$(APP).app
  644. $t test -f $(APP)/ebin/use_blue.beam
  645. $t test -f $(APP)/ebin/use_red.beam
  646. $i "Check that the application was compiled correctly"
  647. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  648. ok = application:start($(APP)), \
  649. {ok, Mods = [use_blue, use_red]} \
  650. = application:get_key($(APP), modules), \
  651. [{module, M} = code:load_file(M) || M <- Mods], \
  652. halt()"
  653. core-app-hrl-recursive: init
  654. $i "Bootstrap a new OTP library named $(APP)"
  655. $t mkdir $(APP)/
  656. $t cp ../erlang.mk $(APP)/
  657. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  658. $i "Generate .hrl files"
  659. $t mkdir $(APP)/include/
  660. $t touch $(APP)/include/blue.hrl $(APP)/include/pill.hrl
  661. $t echo "-include(\"pill.hrl\")." > $(APP)/include/red.hrl
  662. $i "Generate .erl files dependent from headers"
  663. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  664. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  665. $i "Build the application"
  666. $t $(MAKE) -C $(APP) $v
  667. $i "Check that all compiled files exist"
  668. $t test -f $(APP)/$(APP).d
  669. $t test -f $(APP)/ebin/$(APP).app
  670. $t test -f $(APP)/ebin/use_blue.beam
  671. $t test -f $(APP)/ebin/use_red.beam
  672. $i "Check that the application was compiled correctly"
  673. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  674. ok = application:start($(APP)), \
  675. {ok, Mods = [use_blue, use_red]} \
  676. = application:get_key($(APP), modules), \
  677. [{module, M} = code:load_file(M) || M <- Mods], \
  678. halt()"
  679. $i "Touch the deepest .hrl file; check that only required files are rebuilt"
  680. # The use_red.erl gets touched because of its dependency to red.hrl and pill.hrl.
  681. $t printf "%s\n" \
  682. $(APP)/$(APP).d \
  683. $(APP)/ebin/$(APP).app \
  684. $(APP)/ebin/use_red.beam \
  685. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  686. $t $(SLEEP)
  687. $t touch $(APP)/include/pill.hrl
  688. $t $(SLEEP)
  689. $t $(MAKE) -C $(APP) $v
  690. $t find $(APP) -type f -newer $(APP)/include/pill.hrl | sort | diff $(APP)/EXPECT -
  691. $t rm $(APP)/EXPECT
  692. $i "Check that the application was compiled correctly"
  693. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  694. ok = application:start($(APP)), \
  695. {ok, Mods = [use_blue, use_red]} \
  696. = application:get_key($(APP), modules), \
  697. [{module, M} = code:load_file(M) || M <- Mods], \
  698. halt()"
  699. $i "Clean the application"
  700. $t $(MAKE) -C $(APP) clean $v
  701. $i "Check that source files still exist"
  702. $t test -f $(APP)/Makefile
  703. $t test -f $(APP)/erlang.mk
  704. $t test -f $(APP)/include/blue.hrl
  705. $t test -f $(APP)/include/pill.hrl
  706. $t test -f $(APP)/include/red.hrl
  707. ifdef LEGACY
  708. $t test -f $(APP)/src/$(APP).app.src
  709. endif
  710. $t test -f $(APP)/src/use_blue.erl
  711. $t test -f $(APP)/src/use_red.erl
  712. $i "Check that all build artifacts are removed"
  713. $t test ! -e $(APP)/$(APP).d
  714. $t test ! -e $(APP)/ebin/
  715. $i "Build the application again"
  716. $t $(MAKE) -C $(APP) $v
  717. $i "Check that all compiled files exist"
  718. $t test -f $(APP)/$(APP).d
  719. $t test -f $(APP)/ebin/$(APP).app
  720. $t test -f $(APP)/ebin/use_blue.beam
  721. $t test -f $(APP)/ebin/use_red.beam
  722. $i "Check that the application was compiled correctly"
  723. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  724. ok = application:start($(APP)), \
  725. {ok, Mods = [use_blue, use_red]} \
  726. = application:get_key($(APP), modules), \
  727. [{module, M} = code:load_file(M) || M <- Mods], \
  728. halt()"
  729. core-app-makefile-change: init
  730. $i "Bootstrap a new OTP application named $(APP)"
  731. $t mkdir $(APP)/
  732. $t cp ../erlang.mk $(APP)/
  733. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  734. $i "Build the application"
  735. $t $(MAKE) -C $(APP) $v
  736. $i "Touch the Makefile; check that all files get rebuilt"
  737. $t printf "%s\n" \
  738. $(APP)/$(APP).d \
  739. $(APP)/ebin/$(APP).app \
  740. $(APP)/ebin/$(APP)_app.beam \
  741. $(APP)/ebin/$(APP)_sup.beam \
  742. $(APP)/src/$(APP)_app.erl \
  743. $(APP)/src/$(APP)_sup.erl | sort > $(APP)/EXPECT
  744. $t $(SLEEP)
  745. $t touch $(APP)/Makefile
  746. $t $(SLEEP)
  747. $t $(MAKE) -C $(APP) $v
  748. $t find $(APP) -type f -newer $(APP)/Makefile -not -path "$(APP)/.erlang.mk/*" | sort | diff $(APP)/EXPECT -
  749. $t rm $(APP)/EXPECT
  750. core-app-mib: init
  751. $i "Bootstrap a new OTP library named $(APP)"
  752. $t mkdir $(APP)/
  753. $t cp ../erlang.mk $(APP)/
  754. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  755. $i "Download .mib files from Erlang/OTP"
  756. $t mkdir $(APP)/mibs/
  757. $t curl -s -o $(APP)/mibs/EX1-MIB.mib $(OTP_MASTER)/lib/snmp/examples/ex1/EX1-MIB.mib
  758. $t curl -s -o $(APP)/mibs/OTP-REG.mib $(OTP_MASTER)/lib/snmp/mibs/OTP-REG.mib
  759. $i "Generate .erl files dependent from headers generated by .mib files"
  760. $t printf "%s\n" "-module(use_v1)." "-include(\"EX1-MIB.hrl\")." > $(APP)/src/use_v1.erl
  761. $t printf "%s\n" "-module(use_v2)." "-include(\"OTP-REG.hrl\")." > $(APP)/src/use_v2.erl
  762. $i "Generate an unrelated .hrl file"
  763. $t mkdir $(APP)/include/
  764. $t touch $(APP)/include/unrelated.hrl
  765. $i "Build the application"
  766. $t $(MAKE) -C $(APP) $v
  767. $i "Check that all compiled files exist"
  768. $t test -f $(APP)/$(APP).d
  769. $t test -f $(APP)/ebin/$(APP).app
  770. $t test -f $(APP)/ebin/use_v1.beam
  771. $t test -f $(APP)/ebin/use_v2.beam
  772. $t test -f $(APP)/include/EX1-MIB.hrl
  773. $t test -f $(APP)/include/OTP-REG.hrl
  774. $t test -f $(APP)/priv/mibs/EX1-MIB.bin
  775. $t test -f $(APP)/priv/mibs/OTP-REG.bin
  776. $i "Check that the application was compiled correctly"
  777. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  778. ok = application:start($(APP)), \
  779. {ok, Mods = [use_v1, use_v2]} \
  780. = application:get_key($(APP), modules), \
  781. [{module, M} = code:load_file(M) || M <- Mods], \
  782. halt()"
  783. $i "Touch one .mib file; check that only required files are rebuilt"
  784. # The use_v1.erl gets touched because of its dependency to EX1-MIB.hrl.
  785. $t printf "%s\n" \
  786. $(APP)/$(APP).d \
  787. $(APP)/ebin/$(APP).app \
  788. $(APP)/ebin/use_v1.beam \
  789. $(APP)/include/EX1-MIB.hrl \
  790. $(APP)/priv/mibs/EX1-MIB.bin \
  791. $(APP)/src/use_v1.erl | sort > $(APP)/EXPECT
  792. $t $(SLEEP)
  793. $t touch $(APP)/mibs/EX1-MIB.mib
  794. $t $(SLEEP)
  795. $t $(MAKE) -C $(APP) $v
  796. $t find $(APP) -type f -newer $(APP)/mibs/EX1-MIB.mib | sort | diff $(APP)/EXPECT -
  797. $t rm $(APP)/EXPECT
  798. $i "Check that the application was compiled correctly"
  799. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  800. ok = application:start($(APP)), \
  801. {ok, Mods = [use_v1, use_v2]} \
  802. = application:get_key($(APP), modules), \
  803. [{module, M} = code:load_file(M) || M <- Mods], \
  804. halt()"
  805. $i "Clean the application"
  806. $t $(MAKE) -C $(APP) clean $v
  807. $i "Check that source files still exist"
  808. $t test -f $(APP)/Makefile
  809. $t test -f $(APP)/erlang.mk
  810. $t test -f $(APP)/include/unrelated.hrl
  811. $t test -f $(APP)/mibs/EX1-MIB.mib
  812. $t test -f $(APP)/mibs/OTP-REG.mib
  813. ifdef LEGACY
  814. $t test -f $(APP)/src/$(APP).app.src
  815. endif
  816. $t test -f $(APP)/src/use_v1.erl
  817. $t test -f $(APP)/src/use_v2.erl
  818. $i "Check that all build artifacts are removed, including intermediates"
  819. $t test ! -e $(APP)/$(APP).d
  820. $t test ! -e $(APP)/ebin/
  821. $t test ! -e $(APP)/include/EX1-MIB.hrl
  822. $t test ! -e $(APP)/include/OTP-REG.hrl
  823. $t test ! -e $(APP)/priv/mibs/
  824. $i "Build the application again"
  825. $t $(MAKE) -C $(APP) $v
  826. $i "Check that all compiled files exist"
  827. $t test -f $(APP)/$(APP).d
  828. $t test -f $(APP)/ebin/$(APP).app
  829. $t test -f $(APP)/ebin/use_v1.beam
  830. $t test -f $(APP)/ebin/use_v2.beam
  831. $t test -f $(APP)/include/EX1-MIB.hrl
  832. $t test -f $(APP)/include/OTP-REG.hrl
  833. $t test -f $(APP)/priv/mibs/EX1-MIB.bin
  834. $t test -f $(APP)/priv/mibs/OTP-REG.bin
  835. $i "Check that the application was compiled correctly"
  836. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  837. ok = application:start($(APP)), \
  838. {ok, Mods = [use_v1, use_v2]} \
  839. = application:get_key($(APP), modules), \
  840. [{module, M} = code:load_file(M) || M <- Mods], \
  841. halt()"
  842. ifndef LEGACY
  843. core-app-name-special-char: init
  844. $i "Bootstrap a new OTP library named $(APP)"
  845. $t mkdir $(APP)/
  846. $t cp ../erlang.mk $(APP)/
  847. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  848. $i "Set PROJECT_DESCRIPTION = test % in the Makefile"
  849. $t echo "PROJECT_DESCRIPTION = test %" >> $(APP)/Makefile
  850. $i "Build the application"
  851. $t $(MAKE) -C $(APP) $v
  852. $i "Check that the application was compiled correctly"
  853. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  854. ok = application:load($(APP)), \
  855. {ok,\"test %\"} = application:get_key($(APP), description), \
  856. halt()"
  857. endif
  858. core-app-no-app: init
  859. $i "Bootstrap a project without an OTP library"
  860. $t mkdir $(APP)/
  861. $t cp ../erlang.mk $(APP)/
  862. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  863. $t rm -rf $(APP)/src
  864. $i "Build the project"
  865. $t $(MAKE) -C $(APP) $v
  866. core-app-no-makedep: init
  867. $i "Bootstrap a new OTP library named $(APP)"
  868. $t mkdir $(APP)/
  869. $t cp ../erlang.mk $(APP)/
  870. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  871. $i "Set NO_MAKEDEP ?= 1 in the Makefile"
  872. $t perl -ni.bak -e 'print;if ($$.==1) {print "NO_MAKEDEP ?= 1\n"}' $(APP)/Makefile
  873. $i "Generate .hrl files"
  874. $t mkdir $(APP)/include/
  875. $t touch $(APP)/include/blue.hrl $(APP)/include/red.hrl
  876. $i "Generate .erl files dependent from headers"
  877. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  878. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  879. $i "Build the application"
  880. $t $(MAKE) -C $(APP) $v
  881. $i "Check that all compiled files exist"
  882. $t test -f $(APP)/$(APP).d
  883. $t test -f $(APP)/ebin/$(APP).app
  884. $t test -f $(APP)/ebin/use_blue.beam
  885. $t test -f $(APP)/ebin/use_red.beam
  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 "Touch one .hrl file; check that only required files are rebuilt"
  894. # The use_red.erl gets touched because of its dependency to red.hrl.
  895. $t printf "%s\n" \
  896. $(APP)/ebin/$(APP).app \
  897. $(APP)/ebin/use_red.beam \
  898. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  899. $t $(SLEEP)
  900. $t touch $(APP)/include/red.hrl
  901. $t $(SLEEP)
  902. $t $(MAKE) -C $(APP) $v
  903. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  904. $t rm $(APP)/EXPECT
  905. $i "Check that the application was compiled correctly"
  906. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  907. ok = application:start($(APP)), \
  908. {ok, Mods = [use_blue, use_red]} \
  909. = application:get_key($(APP), modules), \
  910. [{module, M} = code:load_file(M) || M <- Mods], \
  911. halt()"
  912. $i "Touch one .hrl file; disable NO_MAKEDEP and check that only required files are rebuilt"
  913. # The use_red.erl gets touched because of its dependency to red.hrl.
  914. $t printf "%s\n" \
  915. $(APP)/$(APP).d \
  916. $(APP)/ebin/$(APP).app \
  917. $(APP)/ebin/use_red.beam \
  918. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  919. $t $(SLEEP)
  920. $t touch $(APP)/include/red.hrl
  921. $t $(SLEEP)
  922. $t NO_MAKEDEP= $(MAKE) -C $(APP) $v
  923. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  924. $t rm $(APP)/EXPECT
  925. $i "Check that the application was compiled correctly"
  926. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  927. ok = application:start($(APP)), \
  928. {ok, Mods = [use_blue, use_red]} \
  929. = application:get_key($(APP), modules), \
  930. [{module, M} = code:load_file(M) || M <- Mods], \
  931. halt()"
  932. $i "Clean the application"
  933. $t $(MAKE) -C $(APP) clean $v
  934. $i "Check that source files still exist"
  935. $t test -f $(APP)/Makefile
  936. $t test -f $(APP)/erlang.mk
  937. $t test -f $(APP)/include/blue.hrl
  938. $t test -f $(APP)/include/red.hrl
  939. ifdef LEGACY
  940. $t test -f $(APP)/src/$(APP).app.src
  941. endif
  942. $t test -f $(APP)/src/use_blue.erl
  943. $t test -f $(APP)/src/use_red.erl
  944. $i "Check that all build artifacts are removed"
  945. $t test ! -e $(APP)/$(APP).d
  946. $t test ! -e $(APP)/ebin/
  947. $i "Build the application again"
  948. $t $(MAKE) -C $(APP) $v
  949. $i "Check that all compiled files exist"
  950. $t test -f $(APP)/$(APP).d
  951. $t test -f $(APP)/ebin/$(APP).app
  952. $t test -f $(APP)/ebin/use_blue.beam
  953. $t test -f $(APP)/ebin/use_red.beam
  954. $i "Check that the application was compiled correctly"
  955. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  956. ok = application:start($(APP)), \
  957. {ok, Mods = [use_blue, use_red]} \
  958. = application:get_key($(APP), modules), \
  959. [{module, M} = code:load_file(M) || M <- Mods], \
  960. halt()"
  961. core-app-project-mod: init
  962. $i "Bootstrap a new OTP library named $(APP)"
  963. $t mkdir $(APP)/
  964. $t cp ../erlang.mk $(APP)/
  965. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  966. $i "Generate an application module"
  967. $t printf "%s\n" \
  968. "-module(app_mod)." \
  969. "-export([start/2, stop/1])." \
  970. "start(_StartType, _StartArgs) -> {ok, self()}." \
  971. "stop(_State) -> ok." > $(APP)/src/app_mod.erl
  972. $i "Build the application with PROJECT_MOD"
  973. $t $(MAKE) -C $(APP) PROJECT_MOD=app_mod $v
  974. $i "Check that the application starts correctly"
  975. $t $(ERL) -pa $(APP)/ebin/ -eval "ok = application:start($(APP)), halt()"
  976. core-app-pt: init
  977. $i "Bootstrap a new OTP library named $(APP)"
  978. $t mkdir $(APP)/
  979. $t cp ../erlang.mk $(APP)/
  980. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  981. $i "Generate a parse_transform module"
  982. $t printf "%s\n" \
  983. "-module(my_pt)." \
  984. "-export([parse_transform/2])." \
  985. "parse_transform(Forms, _) ->" \
  986. " io:format(\"# Running my_pt parse_transform.~n\")," \
  987. " Forms." > $(APP)/src/my_pt.erl
  988. $i "Generate a .erl file that uses the my_pt parse_transform"
  989. $t printf "%s\n" \
  990. "-module(my_user)." \
  991. "-compile({parse_transform, my_pt})." > $(APP)/src/my_user.erl
  992. $i "Build the application; confirm the parse_transform is used"
  993. $t $(MAKE) -C $(APP) | grep "Running my_pt parse_transform."
  994. $i "Check that the application was compiled correctly"
  995. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  996. ok = application:start($(APP)), \
  997. {ok, Mods = [my_pt, my_user]} = application:get_key($(APP), modules), \
  998. [{module, M} = code:load_file(M) || M <- Mods], \
  999. halt()"
  1000. core-app-pt-erlc-opts: init
  1001. $i "Bootstrap a new OTP library named $(APP)"
  1002. $t mkdir $(APP)/
  1003. $t cp ../erlang.mk $(APP)/
  1004. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1005. $i "Bootstrap a new OTP library in $(APP)/deps/my_pt_dep"
  1006. $t mkdir -p $(APP)/deps/my_pt_dep/
  1007. $t cp ../erlang.mk $(APP)/deps/my_pt_dep/
  1008. $t $(MAKE) -C $(APP)/deps/my_pt_dep/ -f erlang.mk bootstrap-lib $v
  1009. $i "Generate a parse_transform module in my_pt_dep"
  1010. $t printf "%s\n" \
  1011. "-module(my_pt)." \
  1012. "-export([parse_transform/2])." \
  1013. "parse_transform(Forms, _) ->" \
  1014. " io:format(\"# Running my_pt parse_transform.~n\")," \
  1015. " Forms." > $(APP)/deps/my_pt_dep/src/my_pt.erl
  1016. $i "Add my_pt_dep to the list of dependencies"
  1017. $t perl -ni.bak -e 'print;if ($$.==1) {print "BUILD_DEPS = my_pt_dep\n"}' $(APP)/Makefile
  1018. $i "Generate .erl files"
  1019. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1020. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1021. $i "Add the my_pt parse_transform to ERLC_OPTS"
  1022. $t echo "ERLC_OPTS += +'{parse_transform, my_pt}'" >> $(APP)/Makefile
  1023. $i "Build the application; confirm the parse_transform is used"
  1024. $t $(MAKE) -C $(APP) | grep "Running my_pt parse_transform."
  1025. $i "Check that the application was compiled correctly"
  1026. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1027. ok = application:start($(APP)), \
  1028. {ok, Mods = [boy, girl]} = application:get_key($(APP), modules), \
  1029. [{module, M} = code:load_file(M) || M <- Mods], \
  1030. halt()"
  1031. core-app-xrl: init
  1032. $i "Bootstrap a new OTP library named $(APP)"
  1033. $t mkdir $(APP)/
  1034. $t cp ../erlang.mk $(APP)/
  1035. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1036. $i "Download .xrl files from Robert"
  1037. $t curl -s -o $(APP)/src/erlang_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/erlang_scan.xrl
  1038. $t curl -s -o $(APP)/src/lfe_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/lfe_scan.xrl
  1039. $i "Generate unrelated .erl files"
  1040. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1041. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1042. $i "Disable warnings; our test .xrl files aren't perfect"
  1043. $t echo "ERLC_OPTS=+debug_info" >> $(APP)/Makefile
  1044. $i "Build the application"
  1045. $t $(MAKE) -C $(APP) $v
  1046. $i "Check that all compiled files exist"
  1047. $t test -f $(APP)/$(APP).d
  1048. $t test -f $(APP)/ebin/$(APP).app
  1049. $t test -f $(APP)/ebin/boy.beam
  1050. $t test -f $(APP)/ebin/erlang_scan.beam
  1051. $t test -f $(APP)/ebin/girl.beam
  1052. $t test -f $(APP)/ebin/lfe_scan.beam
  1053. $t test -f $(APP)/src/erlang_scan.erl
  1054. $t test -f $(APP)/src/lfe_scan.erl
  1055. $i "Check that the application was compiled correctly"
  1056. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1057. ok = application:start($(APP)), \
  1058. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  1059. = application:get_key($(APP), modules), \
  1060. [{module, M} = code:load_file(M) || M <- Mods], \
  1061. halt()"
  1062. $i "Touch one .xrl file; check that only required files are rebuilt"
  1063. $t printf "%s\n" \
  1064. $(APP)/$(APP).d \
  1065. $(APP)/ebin/$(APP).app \
  1066. $(APP)/ebin/erlang_scan.beam \
  1067. $(APP)/src/erlang_scan.erl | sort > $(APP)/EXPECT
  1068. $t $(SLEEP)
  1069. $t touch $(APP)/src/erlang_scan.xrl
  1070. $t $(SLEEP)
  1071. $t $(MAKE) -C $(APP) $v
  1072. $t find $(APP) -type f -newer $(APP)/src/erlang_scan.xrl | sort | diff $(APP)/EXPECT -
  1073. $t rm $(APP)/EXPECT
  1074. $i "Check that the application was compiled correctly"
  1075. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1076. ok = application:start($(APP)), \
  1077. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  1078. = application:get_key($(APP), modules), \
  1079. [{module, M} = code:load_file(M) || M <- Mods], \
  1080. halt()"
  1081. $i "Clean the application"
  1082. $t $(MAKE) -C $(APP) clean $v
  1083. $i "Check that source files still exist"
  1084. $t test -f $(APP)/Makefile
  1085. $t test -f $(APP)/erlang.mk
  1086. ifdef LEGACY
  1087. $t test -f $(APP)/src/$(APP).app.src
  1088. endif
  1089. $t test -f $(APP)/src/boy.erl
  1090. $t test -f $(APP)/src/erlang_scan.xrl
  1091. $t test -f $(APP)/src/girl.erl
  1092. $t test -f $(APP)/src/lfe_scan.xrl
  1093. $i "Check that all build artifacts are removed, including intermediates"
  1094. $t test ! -e $(APP)/$(APP).d
  1095. $t test ! -e $(APP)/ebin/
  1096. $t test ! -e $(APP)/src/erlang_scan.erl
  1097. $t test ! -e $(APP)/src/lfe_scan.erl
  1098. $i "Build the application again"
  1099. $t $(MAKE) -C $(APP) $v
  1100. $i "Check that all compiled files exist"
  1101. $t test -f $(APP)/$(APP).d
  1102. $t test -f $(APP)/ebin/$(APP).app
  1103. $t test -f $(APP)/ebin/boy.beam
  1104. $t test -f $(APP)/ebin/erlang_scan.beam
  1105. $t test -f $(APP)/ebin/girl.beam
  1106. $t test -f $(APP)/ebin/lfe_scan.beam
  1107. $t test -f $(APP)/src/erlang_scan.erl
  1108. $t test -f $(APP)/src/lfe_scan.erl
  1109. $i "Check that the application was compiled correctly"
  1110. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1111. ok = application:start($(APP)), \
  1112. {ok, Mods = [boy, erlang_scan, girl, lfe_scan]} \
  1113. = application:get_key($(APP), modules), \
  1114. [{module, M} = code:load_file(M) || M <- Mods], \
  1115. halt()"
  1116. core-app-xrl-help: init
  1117. $i "Bootstrap a new OTP library named $(APP)"
  1118. $t mkdir $(APP)/
  1119. $t cp ../erlang.mk $(APP)/
  1120. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1121. $i "Download an .xrl file from Robert"
  1122. $t curl -s -o $(APP)/src/erlang_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/erlang_scan.xrl
  1123. $i "Disable warnings; our test .xrl files aren't perfect"
  1124. $t echo "ERLC_OPTS=+debug_info" >> $(APP)/Makefile
  1125. $i "Run 'make help'"
  1126. $t $(MAKE) -C $(APP) help $v
  1127. $i "Check that no files were compiled"
  1128. $t test ! -e $(APP)/$(APP).d
  1129. $t test ! -e $(APP)/ebin/$(APP).app
  1130. $t test ! -e $(APP)/ebin/erlang_scan.beam
  1131. $t test ! -e $(APP)/src/erlang_scan.erl
  1132. core-app-xrl-include: init
  1133. $i "Bootstrap a new OTP library named $(APP)"
  1134. $t mkdir $(APP)/
  1135. $t cp ../erlang.mk $(APP)/
  1136. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1137. $i "Download a .xrl file with numerous includes from Gordon"
  1138. $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
  1139. $t curl -s -o $(APP)/src/errvals.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/errvals.hrl
  1140. $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
  1141. $t curl -s -o $(APP)/src/muin_records.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/muin_records.hrl
  1142. $t curl -s -o $(APP)/src/typechecks.hrl https://raw.githubusercontent.com/hypernumbers/hypernumbers/master/lib/hypernumbers-1.0/include/typechecks.hrl
  1143. $i "Generate unrelated .erl files"
  1144. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1145. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1146. $i "Disable warnings; our test .xrl files aren't perfect"
  1147. $t echo "ERLC_OPTS=+debug_info" >> $(APP)/Makefile
  1148. $i "Build the application"
  1149. $t $(MAKE) -C $(APP) $v
  1150. $i "Check that all compiled files exist"
  1151. $t test -f $(APP)/$(APP).d
  1152. $t test -f $(APP)/ebin/$(APP).app
  1153. $t test -f $(APP)/ebin/boy.beam
  1154. $t test -f $(APP)/ebin/girl.beam
  1155. $t test -f $(APP)/ebin/xfl_lexer.beam
  1156. $t test -f $(APP)/src/xfl_lexer.erl
  1157. $i "Check that the application was compiled correctly"
  1158. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1159. ok = application:start($(APP)), \
  1160. {ok, Mods = [boy, girl, xfl_lexer]} \
  1161. = application:get_key($(APP), modules), \
  1162. [{module, M} = code:load_file(M) || M <- Mods], \
  1163. halt()"
  1164. $i "Touch the .xrl file; check that only required files are rebuilt"
  1165. $t printf "%s\n" \
  1166. $(APP)/$(APP).d \
  1167. $(APP)/ebin/$(APP).app \
  1168. $(APP)/ebin/xfl_lexer.beam \
  1169. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  1170. $t $(SLEEP)
  1171. $t touch $(APP)/src/xfl_lexer.xrl
  1172. $t $(SLEEP)
  1173. $t $(MAKE) -C $(APP) $v
  1174. $t find $(APP) -type f -newer $(APP)/src/xfl_lexer.xrl | sort | diff $(APP)/EXPECT -
  1175. $t rm $(APP)/EXPECT
  1176. $i "Check that the application was compiled correctly"
  1177. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1178. ok = application:start($(APP)), \
  1179. {ok, Mods = [boy, girl, xfl_lexer]} \
  1180. = application:get_key($(APP), modules), \
  1181. [{module, M} = code:load_file(M) || M <- Mods], \
  1182. halt()"
  1183. $i "Touch a .hrl file included directly; check that only required files are rebuilt"
  1184. $t printf "%s\n" \
  1185. $(APP)/$(APP).d \
  1186. $(APP)/ebin/$(APP).app \
  1187. $(APP)/ebin/xfl_lexer.beam \
  1188. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  1189. $t $(SLEEP)
  1190. $t touch $(APP)/src/typechecks.hrl
  1191. $t $(SLEEP)
  1192. $t $(MAKE) -C $(APP) $v
  1193. $t find $(APP) -type f -newer $(APP)/src/typechecks.hrl | sort | diff $(APP)/EXPECT -
  1194. $t rm $(APP)/EXPECT
  1195. $i "Check that the application was compiled correctly"
  1196. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1197. ok = application:start($(APP)), \
  1198. {ok, Mods = [boy, girl, xfl_lexer]} \
  1199. = application:get_key($(APP), modules), \
  1200. [{module, M} = code:load_file(M) || M <- Mods], \
  1201. halt()"
  1202. $i "Touch a .hrl file included indirectly; check that only required files are rebuilt"
  1203. $t printf "%s\n" \
  1204. $(APP)/$(APP).d \
  1205. $(APP)/ebin/$(APP).app \
  1206. $(APP)/ebin/xfl_lexer.beam \
  1207. $(APP)/src/xfl_lexer.erl | sort > $(APP)/EXPECT
  1208. $t $(SLEEP)
  1209. $t touch $(APP)/src/errvals.hrl
  1210. $t $(SLEEP)
  1211. $t $(MAKE) -C $(APP) $v
  1212. $t find $(APP) -type f -newer $(APP)/src/errvals.hrl | sort | diff $(APP)/EXPECT -
  1213. $t rm $(APP)/EXPECT
  1214. $i "Check that the application was compiled correctly"
  1215. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1216. ok = application:start($(APP)), \
  1217. {ok, Mods = [boy, girl, xfl_lexer]} \
  1218. = application:get_key($(APP), modules), \
  1219. [{module, M} = code:load_file(M) || M <- Mods], \
  1220. halt()"
  1221. $i "Clean the application"
  1222. $t $(MAKE) -C $(APP) clean $v
  1223. $i "Check that source files still exist"
  1224. $t test -f $(APP)/Makefile
  1225. $t test -f $(APP)/erlang.mk
  1226. ifdef LEGACY
  1227. $t test -f $(APP)/src/$(APP).app.src
  1228. endif
  1229. $t test -f $(APP)/src/boy.erl
  1230. $t test -f $(APP)/src/girl.erl
  1231. $t test -f $(APP)/src/errvals.hrl
  1232. $t test -f $(APP)/src/muin_proc_dict.hrl
  1233. $t test -f $(APP)/src/muin_records.hrl
  1234. $t test -f $(APP)/src/typechecks.hrl
  1235. $t test -f $(APP)/src/xfl_lexer.xrl
  1236. $i "Check that all build artifacts are removed, including intermediates"
  1237. $t test ! -e $(APP)/$(APP).d
  1238. $t test ! -e $(APP)/ebin/
  1239. $t test ! -e $(APP)/src/xfl_lexer.erl
  1240. $i "Build the application again"
  1241. $t $(MAKE) -C $(APP) $v
  1242. $i "Check that all compiled files exist"
  1243. $t test -f $(APP)/$(APP).d
  1244. $t test -f $(APP)/ebin/$(APP).app
  1245. $t test -f $(APP)/ebin/boy.beam
  1246. $t test -f $(APP)/ebin/girl.beam
  1247. $t test -f $(APP)/ebin/xfl_lexer.beam
  1248. $t test -f $(APP)/src/xfl_lexer.erl
  1249. $i "Check that the application was compiled correctly"
  1250. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1251. ok = application:start($(APP)), \
  1252. {ok, Mods = [boy, girl, xfl_lexer]} \
  1253. = application:get_key($(APP), modules), \
  1254. [{module, M} = code:load_file(M) || M <- Mods], \
  1255. halt()"
  1256. core-app-yrl: init
  1257. $i "Bootstrap a new OTP library named $(APP)"
  1258. $t mkdir $(APP)/
  1259. $t cp ../erlang.mk $(APP)/
  1260. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1261. $i "Download .yrl files from Erlang/OTP"
  1262. $t curl -s -o $(APP)/src/xmerl_xpath_parse.yrl $(OTP_MASTER)/lib/xmerl/src/xmerl_xpath_parse.yrl
  1263. $t curl -s -o $(APP)/src/xref_parser.yrl $(OTP_MASTER)/lib/tools/src/xref_parser.yrl
  1264. $i "Generate unrelated .erl files"
  1265. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1266. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1267. $i "Build the application"
  1268. $t $(MAKE) -C $(APP) $v
  1269. $i "Check that all compiled files exist"
  1270. $t test -f $(APP)/$(APP).d
  1271. $t test -f $(APP)/ebin/$(APP).app
  1272. $t test -f $(APP)/ebin/boy.beam
  1273. $t test -f $(APP)/ebin/girl.beam
  1274. $t test -f $(APP)/ebin/xmerl_xpath_parse.beam
  1275. $t test -f $(APP)/ebin/xref_parser.beam
  1276. $t test -f $(APP)/src/xmerl_xpath_parse.erl
  1277. $t test -f $(APP)/src/xref_parser.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, xmerl_xpath_parse, xref_parser]} \
  1282. = application:get_key($(APP), modules), \
  1283. [{module, M} = code:load_file(M) || M <- Mods], \
  1284. halt()"
  1285. $i "Touch one .yrl file; check that only required files are rebuilt"
  1286. $t printf "%s\n" \
  1287. $(APP)/$(APP).d \
  1288. $(APP)/ebin/$(APP).app \
  1289. $(APP)/ebin/xref_parser.beam \
  1290. $(APP)/src/xref_parser.erl | sort > $(APP)/EXPECT
  1291. $t $(SLEEP)
  1292. $t touch $(APP)/src/xref_parser.yrl
  1293. $t $(SLEEP)
  1294. $t $(MAKE) -C $(APP) $v
  1295. $t find $(APP) -type f -newer $(APP)/src/xref_parser.yrl | sort | diff $(APP)/EXPECT -
  1296. $t rm $(APP)/EXPECT
  1297. $i "Check that the application was compiled correctly"
  1298. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1299. ok = application:start($(APP)), \
  1300. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  1301. = application:get_key($(APP), modules), \
  1302. [{module, M} = code:load_file(M) || M <- Mods], \
  1303. halt()"
  1304. $i "Clean the application"
  1305. $t $(MAKE) -C $(APP) clean $v
  1306. $i "Check that source files still exist"
  1307. $t test -f $(APP)/Makefile
  1308. $t test -f $(APP)/erlang.mk
  1309. ifdef LEGACY
  1310. $t test -f $(APP)/src/$(APP).app.src
  1311. endif
  1312. $t test -f $(APP)/src/boy.erl
  1313. $t test -f $(APP)/src/girl.erl
  1314. $t test -f $(APP)/src/xmerl_xpath_parse.yrl
  1315. $t test -f $(APP)/src/xref_parser.yrl
  1316. $i "Check that all build artifacts are removed, including intermediates"
  1317. $t test ! -e $(APP)/$(APP).d
  1318. $t test ! -e $(APP)/ebin/
  1319. $t test ! -e $(APP)/src/xmerl_xpath_parse.erl
  1320. $t test ! -e $(APP)/src/xref_parser.erl
  1321. $i "Build the application again"
  1322. $t $(MAKE) -C $(APP) $v
  1323. $i "Check that all compiled files exist"
  1324. $t test -f $(APP)/$(APP).d
  1325. $t test -f $(APP)/ebin/$(APP).app
  1326. $t test -f $(APP)/ebin/boy.beam
  1327. $t test -f $(APP)/ebin/girl.beam
  1328. $t test -f $(APP)/ebin/xmerl_xpath_parse.beam
  1329. $t test -f $(APP)/ebin/xref_parser.beam
  1330. $t test -f $(APP)/src/xmerl_xpath_parse.erl
  1331. $t test -f $(APP)/src/xref_parser.erl
  1332. $i "Check that the application was compiled correctly"
  1333. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1334. ok = application:start($(APP)), \
  1335. {ok, Mods = [boy, girl, xmerl_xpath_parse, xref_parser]} \
  1336. = application:get_key($(APP), modules), \
  1337. [{module, M} = code:load_file(M) || M <- Mods], \
  1338. halt()"
  1339. core-app-yrl-header: init
  1340. $i "Bootstrap a new OTP library named $(APP)"
  1341. $t mkdir $(APP)/
  1342. $t cp ../erlang.mk $(APP)/
  1343. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1344. $i "Create a .yrl file"
  1345. $t echo "Nonterminals E T F." > $(APP)/src/y_parse.yrl
  1346. $t echo "Terminals '+' '*' '(' ')' number." >> $(APP)/src/y_parse.yrl
  1347. $t echo "Rootsymbol E." >> $(APP)/src/y_parse.yrl
  1348. $t echo "E -> E '+' T: {'\$$2', '\$$1', '\$$3'}." >> $(APP)/src/y_parse.yrl
  1349. $t echo "E -> T : '\$$1'." >> $(APP)/src/y_parse.yrl
  1350. $t echo "T -> T '*' F: {'\$$2', '\$$1', '\$$3'}." >> $(APP)/src/y_parse.yrl
  1351. $t echo "T -> F : '\$$1'." >> $(APP)/src/y_parse.yrl
  1352. $t echo "F -> '(' E ')' : '\$$2'." >> $(APP)/src/y_parse.yrl
  1353. $t echo "F -> number : '\$$1'. " >> $(APP)/src/y_parse.yrl
  1354. $i "Create the yrl header file"
  1355. $t mkdir $(APP)/include
  1356. $t echo "-export([forty_two/0])." > $(APP)/include/yecc_header.hrl
  1357. # A bunch of gobbldygook we don't actually care about, they just
  1358. # need to exist so we don't get errors.
  1359. $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
  1360. $t echo "yeccpars1(_,_,_,_,_) -> throw(not_implemented)." >> $(APP)/include/yecc_header.hrl
  1361. $t echo "yeccerror(_) -> throw(not_implemented)." >> $(APP)/include/yecc_header.hrl
  1362. # Required bits done, now part we'll actually test for.
  1363. $t echo "forty_two() -> 42." >> $(APP)/include/yecc_header.hrl
  1364. $i "Generate unrelated .erl files"
  1365. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1366. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1367. $i "Build the application"
  1368. $t YRL_ERLC_OPTS="-I include/yecc_header.hrl" $(MAKE) -C $(APP) $v
  1369. $i "Check that all compiled files exist"
  1370. $t test -f $(APP)/$(APP).d
  1371. $t test -f $(APP)/ebin/$(APP).app
  1372. $t test -f $(APP)/ebin/boy.beam
  1373. $t test -f $(APP)/ebin/girl.beam
  1374. $t test -f $(APP)/ebin/y_parse.beam
  1375. $t test -f $(APP)/src/y_parse.erl
  1376. $i "Check that the application was compiled correctly"
  1377. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1378. ok = application:start($(APP)), \
  1379. {ok, Mods = [boy, girl, y_parse]} \
  1380. = application:get_key($(APP), modules), \
  1381. [{module, M} = code:load_file(M) || M <- Mods], \
  1382. halt()"
  1383. $i "Check the built yecc module used the header"
  1384. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1385. {module, y_parse} = code:load_file(y_parse), \
  1386. 42 = y_parse:forty_two(), \
  1387. halt()"
  1388. $i "Check that the application was compiled correctly"
  1389. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1390. ok = application:start($(APP)), \
  1391. {ok, Mods = [boy, girl, y_parse]} \
  1392. = application:get_key($(APP), modules), \
  1393. [{module, M} = code:load_file(M) || M <- Mods], \
  1394. halt()"
  1395. core-app-yrl-include: init
  1396. $i "Bootstrap a new OTP library named $(APP)"
  1397. $t mkdir $(APP)/
  1398. $t cp ../erlang.mk $(APP)/
  1399. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1400. $i "Download a .yrl file with includes from Erlang/OTP"
  1401. $t curl -s -o $(APP)/src/core_parse.yrl $(OTP_MASTER)/lib/compiler/src/core_parse.yrl
  1402. $t curl -s -o $(APP)/src/core_parse.hrl $(OTP_MASTER)/lib/compiler/src/core_parse.hrl
  1403. $i "Generate unrelated .erl files"
  1404. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1405. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1406. $i "Build the application"
  1407. $t $(MAKE) -C $(APP) $v
  1408. $i "Check that all compiled files exist"
  1409. $t test -f $(APP)/$(APP).d
  1410. $t test -f $(APP)/ebin/$(APP).app
  1411. $t test -f $(APP)/ebin/boy.beam
  1412. $t test -f $(APP)/ebin/core_parse.beam
  1413. $t test -f $(APP)/ebin/girl.beam
  1414. $t test -f $(APP)/src/core_parse.erl
  1415. $i "Check that the application was compiled correctly"
  1416. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1417. ok = application:start($(APP)), \
  1418. {ok, Mods = [boy, core_parse, girl]} \
  1419. = application:get_key($(APP), modules), \
  1420. [{module, M} = code:load_file(M) || M <- Mods], \
  1421. halt()"
  1422. $i "Touch the .yrl file; check that only required files are rebuilt"
  1423. $t printf "%s\n" \
  1424. $(APP)/$(APP).d \
  1425. $(APP)/ebin/$(APP).app \
  1426. $(APP)/ebin/core_parse.beam \
  1427. $(APP)/src/core_parse.erl | sort > $(APP)/EXPECT
  1428. $t $(SLEEP)
  1429. $t touch $(APP)/src/core_parse.yrl
  1430. $t $(SLEEP)
  1431. $t $(MAKE) -C $(APP) $v
  1432. $t find $(APP) -type f -newer $(APP)/src/core_parse.yrl | sort | diff $(APP)/EXPECT -
  1433. $t rm $(APP)/EXPECT
  1434. $i "Check that the application was compiled correctly"
  1435. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1436. ok = application:start($(APP)), \
  1437. {ok, Mods = [boy, core_parse, girl]} \
  1438. = application:get_key($(APP), modules), \
  1439. [{module, M} = code:load_file(M) || M <- Mods], \
  1440. halt()"
  1441. $i "Touch the .hrl file included; check that only required files are rebuilt"
  1442. $t printf "%s\n" \
  1443. $(APP)/$(APP).d \
  1444. $(APP)/ebin/$(APP).app \
  1445. $(APP)/ebin/core_parse.beam \
  1446. $(APP)/src/core_parse.erl | sort > $(APP)/EXPECT
  1447. $t $(SLEEP)
  1448. $t touch $(APP)/src/core_parse.hrl
  1449. $t $(SLEEP)
  1450. $t $(MAKE) -C $(APP) $v
  1451. $t find $(APP) -type f -newer $(APP)/src/core_parse.hrl | sort | diff $(APP)/EXPECT -
  1452. $t rm $(APP)/EXPECT
  1453. $i "Check that the application was compiled correctly"
  1454. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1455. ok = application:start($(APP)), \
  1456. {ok, Mods = [boy, core_parse, girl]} \
  1457. = application:get_key($(APP), modules), \
  1458. [{module, M} = code:load_file(M) || M <- Mods], \
  1459. halt()"
  1460. $i "Clean the application"
  1461. $t $(MAKE) -C $(APP) clean $v
  1462. $i "Check that source files still exist"
  1463. $t test -f $(APP)/Makefile
  1464. $t test -f $(APP)/erlang.mk
  1465. ifdef LEGACY
  1466. $t test -f $(APP)/src/$(APP).app.src
  1467. endif
  1468. $t test -f $(APP)/src/boy.erl
  1469. $t test -f $(APP)/src/core_parse.hrl
  1470. $t test -f $(APP)/src/core_parse.yrl
  1471. $t test -f $(APP)/src/girl.erl
  1472. $i "Check that all build artifacts are removed, including intermediates"
  1473. $t test ! -e $(APP)/$(APP).d
  1474. $t test ! -e $(APP)/ebin/
  1475. $t test ! -e $(APP)/src/core_parse.erl
  1476. $i "Build the application again"
  1477. $t $(MAKE) -C $(APP) $v
  1478. $i "Check that all compiled files exist"
  1479. $t test -f $(APP)/$(APP).d
  1480. $t test -f $(APP)/ebin/$(APP).app
  1481. $t test -f $(APP)/ebin/boy.beam
  1482. $t test -f $(APP)/ebin/core_parse.beam
  1483. $t test -f $(APP)/ebin/girl.beam
  1484. $t test -f $(APP)/src/core_parse.erl
  1485. $i "Check that the application was compiled correctly"
  1486. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1487. ok = application:start($(APP)), \
  1488. {ok, Mods = [boy, core_parse, girl]} \
  1489. = application:get_key($(APP), modules), \
  1490. [{module, M} = code:load_file(M) || M <- Mods], \
  1491. halt()"
  1492. core-app-yrl-test-build-then-normal-build: init
  1493. $i "Bootstrap a new OTP library named $(APP)"
  1494. $t mkdir $(APP)/
  1495. $t cp ../erlang.mk $(APP)/
  1496. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1497. $i "Create the parser .yrl file"
  1498. $t printf "%s\n" \
  1499. "Nonterminals top." \
  1500. "Terminals plus num." \
  1501. "Rootsymbol top." \
  1502. "top -> num plus num : {'$1', '$3'}." > $(APP)/src/$(APP)_parser.yrl
  1503. $i "Create the test suite"
  1504. $t mkdir $(APP)/test
  1505. $t printf "%s\n" \
  1506. "-module(test_SUITE)." \
  1507. "-export([all/0, test/1])." \
  1508. "all() -> [test]." \
  1509. "test(_) -> 0=0." > $(APP)/test/test_SUITE.erl
  1510. $i "Build the application in test mode"
  1511. $t $(MAKE) -C $(APP) ct $v
  1512. $i "Build the application in normal mode"
  1513. $t $(MAKE) -C $(APP) $v
  1514. core-app-hrl-include-lib: init
  1515. $i "Bootstrap a new OTP library named $(APP)"
  1516. $t mkdir $(APP)/
  1517. $t cp ../erlang.mk $(APP)/
  1518. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1519. $i "Generate .hrl files"
  1520. $t mkdir $(APP)/include/
  1521. $t touch $(APP)/include/blue.hrl $(APP)/include/red.hrl
  1522. $i "Generate .erl files dependent from headers"
  1523. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  1524. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  1525. $i "Build the application"
  1526. $t $(MAKE) -C $(APP) $v
  1527. $i "Check that all compiled files exist"
  1528. $t test -f $(APP)/$(APP).d
  1529. $t test -f $(APP)/ebin/$(APP).app
  1530. $t test -f $(APP)/ebin/use_blue.beam
  1531. $t test -f $(APP)/ebin/use_red.beam
  1532. $i "Check that the application was compiled correctly"
  1533. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1534. ok = application:start($(APP)), \
  1535. {ok, Mods = [use_blue, use_red]} \
  1536. = application:get_key($(APP), modules), \
  1537. [{module, M} = code:load_file(M) || M <- Mods], \
  1538. halt()"
  1539. $i "Touch one .hrl file; check that only required files are rebuilt"
  1540. # The use_red.erl gets touched because of its dependency to red.hrl.
  1541. $t printf "%s\n" \
  1542. $(APP)/$(APP).d \
  1543. $(APP)/ebin/$(APP).app \
  1544. $(APP)/ebin/use_red.beam \
  1545. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  1546. $t $(SLEEP)
  1547. $t touch $(APP)/include/red.hrl
  1548. $t $(SLEEP)
  1549. $t $(MAKE) -C $(APP) $v
  1550. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  1551. $t rm $(APP)/EXPECT
  1552. $i "Check that the application was compiled correctly"
  1553. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1554. ok = application:start($(APP)), \
  1555. {ok, Mods = [use_blue, use_red]} \
  1556. = application:get_key($(APP), modules), \
  1557. [{module, M} = code:load_file(M) || M <- Mods], \
  1558. halt()"
  1559. $i "Clean the application"
  1560. $t $(MAKE) -C $(APP) clean $v
  1561. $i "Check that source files still exist"
  1562. $t test -f $(APP)/Makefile
  1563. $t test -f $(APP)/erlang.mk
  1564. $t test -f $(APP)/include/blue.hrl
  1565. $t test -f $(APP)/include/red.hrl
  1566. ifdef LEGACY
  1567. $t test -f $(APP)/src/$(APP).app.src
  1568. endif
  1569. $t test -f $(APP)/src/use_blue.erl
  1570. $t test -f $(APP)/src/use_red.erl
  1571. $i "Check that all build artifacts are removed"
  1572. $t test ! -e $(APP)/$(APP).d
  1573. $t test ! -e $(APP)/ebin/
  1574. $i "Build the application again"
  1575. $t $(MAKE) -C $(APP) $v
  1576. $i "Check that all compiled files exist"
  1577. $t test -f $(APP)/$(APP).d
  1578. $t test -f $(APP)/ebin/$(APP).app
  1579. $t test -f $(APP)/ebin/use_blue.beam
  1580. $t test -f $(APP)/ebin/use_red.beam
  1581. $i "Check that the application was compiled correctly"
  1582. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1583. ok = application:start($(APP)), \
  1584. {ok, Mods = [use_blue, use_red]} \
  1585. = application:get_key($(APP), modules), \
  1586. [{module, M} = code:load_file(M) || M <- Mods], \
  1587. halt()"
  1588. core-app-hrl-include-lib-recursive: init
  1589. $i "Bootstrap a new OTP library named $(APP)"
  1590. $t mkdir $(APP)/
  1591. $t cp ../erlang.mk $(APP)/
  1592. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1593. $i "Generate .hrl files"
  1594. $t mkdir $(APP)/include/
  1595. $t touch $(APP)/include/blue.hrl $(APP)/include/pill.hrl
  1596. $t echo "-include_lib(\"pill.hrl\")." > $(APP)/include/red.hrl
  1597. $i "Generate .erl files dependent from headers"
  1598. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  1599. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  1600. $i "Build the application"
  1601. $t $(MAKE) -C $(APP) $v
  1602. $i "Check that all compiled files exist"
  1603. $t test -f $(APP)/$(APP).d
  1604. $t test -f $(APP)/ebin/$(APP).app
  1605. $t test -f $(APP)/ebin/use_blue.beam
  1606. $t test -f $(APP)/ebin/use_red.beam
  1607. $i "Check that the application was compiled correctly"
  1608. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1609. ok = application:start($(APP)), \
  1610. {ok, Mods = [use_blue, use_red]} \
  1611. = application:get_key($(APP), modules), \
  1612. [{module, M} = code:load_file(M) || M <- Mods], \
  1613. halt()"
  1614. $i "Touch the deepest .hrl file; check that only required files are rebuilt"
  1615. # The use_red.erl gets touched because of its dependency to red.hrl and pill.hrl.
  1616. $t printf "%s\n" \
  1617. $(APP)/$(APP).d \
  1618. $(APP)/ebin/$(APP).app \
  1619. $(APP)/ebin/use_red.beam \
  1620. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  1621. $t $(SLEEP)
  1622. $t touch $(APP)/include/pill.hrl
  1623. $t $(SLEEP)
  1624. $t $(MAKE) -C $(APP) $v
  1625. $t find $(APP) -type f -newer $(APP)/include/pill.hrl | sort | diff $(APP)/EXPECT -
  1626. $t rm $(APP)/EXPECT
  1627. $i "Check that the application was compiled correctly"
  1628. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1629. ok = application:start($(APP)), \
  1630. {ok, Mods = [use_blue, use_red]} \
  1631. = application:get_key($(APP), modules), \
  1632. [{module, M} = code:load_file(M) || M <- Mods], \
  1633. halt()"
  1634. $i "Clean the application"
  1635. $t $(MAKE) -C $(APP) clean $v
  1636. $i "Check that source files still exist"
  1637. $t test -f $(APP)/Makefile
  1638. $t test -f $(APP)/erlang.mk
  1639. $t test -f $(APP)/include/blue.hrl
  1640. $t test -f $(APP)/include/pill.hrl
  1641. $t test -f $(APP)/include/red.hrl
  1642. ifdef LEGACY
  1643. $t test -f $(APP)/src/$(APP).app.src
  1644. endif
  1645. $t test -f $(APP)/src/use_blue.erl
  1646. $t test -f $(APP)/src/use_red.erl
  1647. $i "Check that all build artifacts are removed"
  1648. $t test ! -e $(APP)/$(APP).d
  1649. $t test ! -e $(APP)/ebin/
  1650. $i "Build the application again"
  1651. $t $(MAKE) -C $(APP) $v
  1652. $i "Check that all compiled files exist"
  1653. $t test -f $(APP)/$(APP).d
  1654. $t test -f $(APP)/ebin/$(APP).app
  1655. $t test -f $(APP)/ebin/use_blue.beam
  1656. $t test -f $(APP)/ebin/use_red.beam
  1657. $i "Check that the application was compiled correctly"
  1658. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1659. ok = application:start($(APP)), \
  1660. {ok, Mods = [use_blue, use_red]} \
  1661. = application:get_key($(APP), modules), \
  1662. [{module, M} = code:load_file(M) || M <- Mods], \
  1663. halt()"
  1664. core-app-hrl-multiapps-include-lib: init
  1665. $i "Create a multi application repository with no root application"
  1666. $t mkdir $(APP)/
  1667. $t cp ../erlang.mk $(APP)/
  1668. $t echo "include erlang.mk" > $(APP)/Makefile
  1669. $i "Create a new application named my_app"
  1670. $t $(MAKE) -C $(APP) new-lib in=my_app $v
  1671. $i "Create a new library named my_lib"
  1672. $t $(MAKE) -C $(APP) new-lib in=my_lib $v
  1673. $i "Add my_lib as LOCAL_DEPS of my_app"
  1674. $t echo "LOCAL_DEPS = my_lib" >> $(APP)/apps/my_app/Makefile
  1675. $i "Generate .hrl files"
  1676. $t mkdir $(APP)/apps/my_lib/include/
  1677. $t touch $(APP)/apps/my_lib/include/blue.hrl $(APP)/apps/my_lib/include/red.hrl
  1678. $i "Generate .erl files dependent from headers"
  1679. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"my_lib/include/blue.hrl\")." > $(APP)/apps/my_app/src/use_blue.erl
  1680. $t printf "%s\n" "-module(use_red)." "-include_lib(\"my_lib/include/red.hrl\")." > $(APP)/apps/my_app/src/use_red.erl
  1681. $i "Build the application"
  1682. $t $(MAKE) -C $(APP) $v
  1683. $i "Check that all compiled files exist"
  1684. $t test -f $(APP)/apps/my_app/my_app.d
  1685. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  1686. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  1687. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  1688. $i "Check that the application was compiled correctly"
  1689. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1690. {ok, _Apps } = application:ensure_all_started(my_app), \
  1691. {ok, Mods = [use_blue, use_red]} \
  1692. = application:get_key(my_app, modules), \
  1693. [{module, M} = code:load_file(M) || M <- Mods], \
  1694. halt()"
  1695. $i "Touch one .hrl file; check that only required files are rebuilt"
  1696. # The use_red.erl gets touched because of its dependency to red.hrl.
  1697. $t printf "%s\n" \
  1698. $(APP)/apps/my_app/my_app.d \
  1699. $(APP)/apps/my_app/ebin/my_app.app \
  1700. $(APP)/apps/my_app/ebin/use_red.beam \
  1701. $(APP)/apps/my_app/src/use_red.erl | sort > $(APP)/EXPECT
  1702. $t $(SLEEP)
  1703. $t touch $(APP)/apps/my_lib/include/red.hrl
  1704. $t $(SLEEP)
  1705. $t $(MAKE) -C $(APP) $v
  1706. $t find $(APP)/apps/my_app -type f -newer $(APP)/apps/my_lib/include/red.hrl | sort | diff $(APP)/EXPECT -
  1707. $t rm $(APP)/EXPECT
  1708. $i "Check that the application was compiled correctly"
  1709. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1710. {ok, _Apps } = application:ensure_all_started(my_app), \
  1711. {ok, Mods = [use_blue, use_red]} \
  1712. = application:get_key(my_app, modules), \
  1713. [{module, M} = code:load_file(M) || M <- Mods], \
  1714. halt()"
  1715. $i "Clean the application"
  1716. $t $(MAKE) -C $(APP) clean $v
  1717. $i "Check that source files still exist"
  1718. $t test -f $(APP)/Makefile
  1719. $t test -f $(APP)/erlang.mk
  1720. $t test -f $(APP)/apps/my_lib/Makefile
  1721. $t test -f $(APP)/apps/my_lib/include/blue.hrl
  1722. $t test -f $(APP)/apps/my_lib/include/red.hrl
  1723. $t test -f $(APP)/apps/my_app/Makefile
  1724. $t test -f $(APP)/apps/my_app/src/use_blue.erl
  1725. $t test -f $(APP)/apps/my_app/src/use_red.erl
  1726. ifdef LEGACY
  1727. $t test -f $(APP)/apps/my_lib/src/my_lib.app.src
  1728. $t test -f $(APP)/apps/my_app/src/my_app.app.src
  1729. endif
  1730. $i "Check that all build artifacts are removed"
  1731. $t test ! -e $(APP)/apps/my_lib/my_app.d
  1732. $t test ! -e $(APP)/apps/my_lib/ebin/
  1733. $t test ! -e $(APP)/apps/my_app/my_app.d
  1734. $t test ! -e $(APP)/apps/my_app/ebin/
  1735. $i "Build the application again"
  1736. $t $(MAKE) -C $(APP) $v
  1737. $i "Check that all compiled files exist"
  1738. $t test -f $(APP)/apps/my_app/my_app.d
  1739. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  1740. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  1741. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  1742. $i "Check that the application was compiled correctly"
  1743. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1744. {ok, _Apps } = application:ensure_all_started(my_app), \
  1745. {ok, Mods = [use_blue, use_red]} \
  1746. = application:get_key(my_app, modules), \
  1747. [{module, M} = code:load_file(M) || M <- Mods], \
  1748. halt()"
  1749. core-app-hrl-multiapps-include-lib-recursive: init
  1750. $i "Create a multi application repository with no root application"
  1751. $t mkdir $(APP)/
  1752. $t cp ../erlang.mk $(APP)/
  1753. $t echo "include erlang.mk" > $(APP)/Makefile
  1754. $i "Create a new application named my_app"
  1755. $t $(MAKE) -C $(APP) new-lib in=my_app $v
  1756. $i "Create a new library named my_lib"
  1757. $t $(MAKE) -C $(APP) new-lib in=my_lib $v
  1758. $i "Add my_lib as LOCAL_DEPS of my_app"
  1759. $t echo "LOCAL_DEPS = my_lib" >> $(APP)/apps/my_app/Makefile
  1760. $i "Generate .hrl files"
  1761. $t mkdir $(APP)/apps/my_lib/include/
  1762. $t touch $(APP)/apps/my_lib/include/blue.hrl $(APP)/apps/my_lib/include/red.hrl $(APP)/apps/my_lib/include/pill.hrl
  1763. $t echo "-include(\"pill.hrl\")." > $(APP)/apps/my_lib/include/red.hrl
  1764. $i "Generate .erl files dependent from headers"
  1765. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"my_lib/include/blue.hrl\")." > $(APP)/apps/my_app/src/use_blue.erl
  1766. $t printf "%s\n" "-module(use_red)." "-include_lib(\"my_lib/include/red.hrl\")." > $(APP)/apps/my_app/src/use_red.erl
  1767. $i "Build the application"
  1768. $t $(MAKE) -C $(APP) $v
  1769. $i "Check that all compiled files exist"
  1770. $t test -f $(APP)/apps/my_app/my_app.d
  1771. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  1772. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  1773. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  1774. $i "Check that the application was compiled correctly"
  1775. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1776. {ok, _Apps } = application:ensure_all_started(my_app), \
  1777. {ok, Mods = [use_blue, use_red]} \
  1778. = application:get_key(my_app, modules), \
  1779. [{module, M} = code:load_file(M) || M <- Mods], \
  1780. halt()"
  1781. $i "Touch one .hrl file; check that only required files are rebuilt"
  1782. # The use_red.erl gets touched because of its dependency to red.hrl.
  1783. $t printf "%s\n" \
  1784. $(APP)/apps/my_app/my_app.d \
  1785. $(APP)/apps/my_app/ebin/my_app.app \
  1786. $(APP)/apps/my_app/ebin/use_red.beam \
  1787. $(APP)/apps/my_app/src/use_red.erl | sort > $(APP)/EXPECT
  1788. $t $(SLEEP)
  1789. $t touch $(APP)/apps/my_lib/include/pill.hrl
  1790. $t $(SLEEP)
  1791. $t $(MAKE) -C $(APP) $v
  1792. $t find $(APP)/apps/my_app -type f -newer $(APP)/apps/my_lib/include/pill.hrl | sort | diff $(APP)/EXPECT -
  1793. $t rm $(APP)/EXPECT
  1794. $i "Check that the application was compiled correctly"
  1795. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1796. {ok, _Apps } = application:ensure_all_started(my_app), \
  1797. {ok, Mods = [use_blue, use_red]} \
  1798. = application:get_key(my_app, modules), \
  1799. [{module, M} = code:load_file(M) || M <- Mods], \
  1800. halt()"
  1801. $i "Clean the application"
  1802. $t $(MAKE) -C $(APP) clean $v
  1803. $i "Check that source files still exist"
  1804. $t test -f $(APP)/Makefile
  1805. $t test -f $(APP)/erlang.mk
  1806. $t test -f $(APP)/apps/my_lib/Makefile
  1807. $t test -f $(APP)/apps/my_lib/include/blue.hrl
  1808. $t test -f $(APP)/apps/my_lib/include/red.hrl
  1809. $t test -f $(APP)/apps/my_lib/include/pill.hrl
  1810. $t test -f $(APP)/apps/my_app/Makefile
  1811. $t test -f $(APP)/apps/my_app/src/use_blue.erl
  1812. $t test -f $(APP)/apps/my_app/src/use_red.erl
  1813. ifdef LEGACY
  1814. $t test -f $(APP)/apps/my_lib/src/my_lib.app.src
  1815. $t test -f $(APP)/apps/my_app/src/my_app.app.src
  1816. endif
  1817. $i "Check that all build artifacts are removed"
  1818. $t test ! -e $(APP)/apps/my_lib/my_app.d
  1819. $t test ! -e $(APP)/apps/my_lib/ebin/
  1820. $t test ! -e $(APP)/apps/my_app/my_app.d
  1821. $t test ! -e $(APP)/apps/my_app/ebin/
  1822. $i "Build the application again"
  1823. $t $(MAKE) -C $(APP) $v
  1824. $i "Check that all compiled files exist"
  1825. $t test -f $(APP)/apps/my_app/my_app.d
  1826. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  1827. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  1828. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  1829. $i "Check that the application was compiled correctly"
  1830. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1831. {ok, _Apps } = application:ensure_all_started(my_app), \
  1832. {ok, Mods = [use_blue, use_red]} \
  1833. = application:get_key(my_app, modules), \
  1834. [{module, M} = code:load_file(M) || M <- Mods], \
  1835. halt()"
  1836. core-app-hrl-include-lib-src: init
  1837. $i "Bootstrap a new OTP library named $(APP)"
  1838. $t mkdir $(APP)/
  1839. $t cp ../erlang.mk $(APP)/
  1840. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1841. $t touch $(APP)/src/blue.hrl $(APP)/src/red.hrl
  1842. $i "Generate .erl files dependent from headers"
  1843. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  1844. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  1845. $i "Build the application"
  1846. $t $(MAKE) -C $(APP) $v
  1847. $i "Check that all compiled files exist"
  1848. $t test -f $(APP)/$(APP).d
  1849. $t test -f $(APP)/ebin/$(APP).app
  1850. $t test -f $(APP)/ebin/use_blue.beam
  1851. $t test -f $(APP)/ebin/use_red.beam
  1852. $i "Check that the application was compiled correctly"
  1853. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1854. ok = application:start($(APP)), \
  1855. {ok, Mods = [use_blue, use_red]} \
  1856. = application:get_key($(APP), modules), \
  1857. [{module, M} = code:load_file(M) || M <- Mods], \
  1858. halt()"
  1859. $i "Touch one .hrl file; check that only required files are rebuilt"
  1860. # The use_red.erl gets touched because of its dependency to red.hrl.
  1861. $t printf "%s\n" \
  1862. $(APP)/$(APP).d \
  1863. $(APP)/ebin/$(APP).app \
  1864. $(APP)/ebin/use_red.beam \
  1865. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  1866. $t $(SLEEP)
  1867. $t touch $(APP)/src/red.hrl
  1868. $t $(SLEEP)
  1869. $t $(MAKE) -C $(APP) $v
  1870. $t find $(APP) -type f -newer $(APP)/src/red.hrl | sort | diff $(APP)/EXPECT -
  1871. $t rm $(APP)/EXPECT
  1872. $i "Check that the application was compiled correctly"
  1873. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1874. ok = application:start($(APP)), \
  1875. {ok, Mods = [use_blue, use_red]} \
  1876. = application:get_key($(APP), modules), \
  1877. [{module, M} = code:load_file(M) || M <- Mods], \
  1878. halt()"
  1879. $i "Clean the application"
  1880. $t $(MAKE) -C $(APP) clean $v
  1881. $i "Check that source files still exist"
  1882. $t test -f $(APP)/Makefile
  1883. $t test -f $(APP)/erlang.mk
  1884. $t test -f $(APP)/src/blue.hrl
  1885. $t test -f $(APP)/src/red.hrl
  1886. ifdef LEGACY
  1887. $t test -f $(APP)/src/$(APP).app.src
  1888. endif
  1889. $t test -f $(APP)/src/use_blue.erl
  1890. $t test -f $(APP)/src/use_red.erl
  1891. $i "Check that all build artifacts are removed"
  1892. $t test ! -e $(APP)/$(APP).d
  1893. $t test ! -e $(APP)/ebin/
  1894. $i "Build the application again"
  1895. $t $(MAKE) -C $(APP) $v
  1896. $i "Check that all compiled files exist"
  1897. $t test -f $(APP)/$(APP).d
  1898. $t test -f $(APP)/ebin/$(APP).app
  1899. $t test -f $(APP)/ebin/use_blue.beam
  1900. $t test -f $(APP)/ebin/use_red.beam
  1901. $i "Check that the application was compiled correctly"
  1902. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1903. ok = application:start($(APP)), \
  1904. {ok, Mods = [use_blue, use_red]} \
  1905. = application:get_key($(APP), modules), \
  1906. [{module, M} = code:load_file(M) || M <- Mods], \
  1907. halt()"
  1908. core-app-hrl-include-lib-src-recursive: init
  1909. $i "Bootstrap a new OTP library named $(APP)"
  1910. $t mkdir $(APP)/
  1911. $t cp ../erlang.mk $(APP)/
  1912. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1913. $i "Generate .hrl files"
  1914. $t touch $(APP)/src/blue.hrl $(APP)/src/pill.hrl
  1915. $t echo "-include_lib(\"pill.hrl\")." > $(APP)/src/red.hrl
  1916. $i "Generate .erl files dependent from headers"
  1917. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  1918. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  1919. $i "Build the application"
  1920. $t $(MAKE) -C $(APP) $v
  1921. $i "Check that all compiled files exist"
  1922. $t test -f $(APP)/$(APP).d
  1923. $t test -f $(APP)/ebin/$(APP).app
  1924. $t test -f $(APP)/ebin/use_blue.beam
  1925. $t test -f $(APP)/ebin/use_red.beam
  1926. $i "Check that the application was compiled correctly"
  1927. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1928. ok = application:start($(APP)), \
  1929. {ok, Mods = [use_blue, use_red]} \
  1930. = application:get_key($(APP), modules), \
  1931. [{module, M} = code:load_file(M) || M <- Mods], \
  1932. halt()"
  1933. $i "Touch the deepest .hrl file; check that only required files are rebuilt"
  1934. # The use_red.erl gets touched because of its dependency to red.hrl and pill.hrl.
  1935. $t printf "%s\n" \
  1936. $(APP)/$(APP).d \
  1937. $(APP)/ebin/$(APP).app \
  1938. $(APP)/ebin/use_red.beam \
  1939. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  1940. $t $(SLEEP)
  1941. $t touch $(APP)/src/pill.hrl
  1942. $t $(SLEEP)
  1943. $t $(MAKE) -C $(APP) $v
  1944. $t find $(APP) -type f -newer $(APP)/src/pill.hrl | sort | diff $(APP)/EXPECT -
  1945. $t rm $(APP)/EXPECT
  1946. $i "Check that the application was compiled correctly"
  1947. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1948. ok = application:start($(APP)), \
  1949. {ok, Mods = [use_blue, use_red]} \
  1950. = application:get_key($(APP), modules), \
  1951. [{module, M} = code:load_file(M) || M <- Mods], \
  1952. halt()"
  1953. $i "Clean the application"
  1954. $t $(MAKE) -C $(APP) clean $v
  1955. $i "Check that source files still exist"
  1956. $t test -f $(APP)/Makefile
  1957. $t test -f $(APP)/erlang.mk
  1958. $t test -f $(APP)/src/blue.hrl
  1959. $t test -f $(APP)/src/pill.hrl
  1960. $t test -f $(APP)/src/red.hrl
  1961. ifdef LEGACY
  1962. $t test -f $(APP)/src/$(APP).app.src
  1963. endif
  1964. $t test -f $(APP)/src/use_blue.erl
  1965. $t test -f $(APP)/src/use_red.erl
  1966. $i "Check that all build artifacts are removed"
  1967. $t test ! -e $(APP)/$(APP).d
  1968. $t test ! -e $(APP)/ebin/
  1969. $i "Build the application again"
  1970. $t $(MAKE) -C $(APP) $v
  1971. $i "Check that all compiled files exist"
  1972. $t test -f $(APP)/$(APP).d
  1973. $t test -f $(APP)/ebin/$(APP).app
  1974. $t test -f $(APP)/ebin/use_blue.beam
  1975. $t test -f $(APP)/ebin/use_red.beam
  1976. $i "Check that the application was compiled correctly"
  1977. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1978. ok = application:start($(APP)), \
  1979. {ok, Mods = [use_blue, use_red]} \
  1980. = application:get_key($(APP), modules), \
  1981. [{module, M} = code:load_file(M) || M <- Mods], \
  1982. halt()"
  1983. core-app-hrl-deps: init
  1984. $i "Create a multi application repository with no root application"
  1985. $t mkdir $(APP)/
  1986. $t cp ../erlang.mk $(APP)/
  1987. $t echo "include erlang.mk" > $(APP)/Makefile
  1988. $i "Create a new application named my_app"
  1989. $t $(MAKE) -C $(APP) new-lib in=my_app $v
  1990. $t echo "DEPS = cowlib" > $(APP)/apps/my_app/Makefile
  1991. $t echo "dep_cowlib_commit = master" >> $(APP)/apps/my_app/Makefile
  1992. $t echo "include ../../erlang.mk" >> $(APP)/apps/my_app/Makefile
  1993. $t printf "%s\n" "-module(boy)." "-include_lib(\"cowlib/include/cow_inline.hrl\")." > $(APP)/apps/my_app/src/boy.erl
  1994. $t printf "%s\n" "-module(girl)." > $(APP)/apps/my_app/src/girl.erl
  1995. $i "Build the application"
  1996. $t $(MAKE) -C $(APP) $v
  1997. $i "Check that all compiled files exist"
  1998. $t test -f $(APP)/apps/my_app/my_app.d
  1999. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  2000. $t test -f $(APP)/apps/my_app/ebin/boy.beam
  2001. $t test -f $(APP)/apps/my_app/ebin/girl.beam
  2002. $t test -f $(APP)/deps/cowlib/ebin/cowlib.app
  2003. ifndef LEGACY
  2004. $i "Check that the application was compiled correctly"
  2005. $t $(ERL) -pa $(APP)/apps/*/ebin/ -eval " \
  2006. ok = application:load(my_app), \
  2007. {ok, MyAppDeps} = application:get_key(my_app, applications), \
  2008. true = lists:member(cowlib, MyAppDeps), \
  2009. halt()"
  2010. endif
  2011. $i "Touch cowlib .hrl file; check that only required files are rebuilt"
  2012. $t printf "%s\n" \
  2013. $(APP)/apps/my_app/my_app.d \
  2014. $(APP)/apps/my_app/ebin/my_app.app \
  2015. $(APP)/apps/my_app/ebin/boy.beam \
  2016. $(APP)/apps/my_app/src/boy.erl | sort > $(APP)/EXPECT
  2017. $t $(SLEEP)
  2018. $t touch $(APP)/deps/cowlib/include/cow_inline.hrl
  2019. $t $(SLEEP)
  2020. $t $(MAKE) -C $(APP) $v
  2021. $t find $(APP)/apps/my_app -type f -newer $(APP)/deps/cowlib/include/cow_inline.hrl | sort | diff $(APP)/EXPECT -
  2022. $t rm $(APP)/EXPECT
  2023. $i "Clean Cowlib"
  2024. $t $(MAKE) -C $(APP)/deps/cowlib clean $v
  2025. $i "Check that Cowlib compiled files were removed"
  2026. $t test ! -e $(APP)/deps/cowlib/ebin/cowlib.app
  2027. $i "Build the application again"
  2028. $t $(MAKE) -C $(APP) $v
  2029. $i "Check that Cowlib compiled files exist"
  2030. $t test -f $(APP)/deps/cowlib/ebin/cowlib.app
  2031. $i "Clean the application"
  2032. $t $(MAKE) -C $(APP) clean $v
  2033. $i "Check that Cowlib is still here"
  2034. $t test -d $(APP)/deps/cowlib
  2035. $i "Check that all relevant files were removed"
  2036. $t test ! -e $(APP)/apps/my_app/my_app.d
  2037. $t test ! -e $(APP)/apps/my_app/ebin/my_app.app
  2038. $t test ! -e $(APP)/apps/my_app/ebin/boy.beam
  2039. $t test ! -e $(APP)/apps/my_app/ebin/girl.beam
  2040. $i "Distclean the application"
  2041. $t $(MAKE) -C $(APP) distclean $v
  2042. $i "Check that all relevant files were removed"
  2043. $t test ! -e $(APP)/deps
  2044. $i "Build the application"
  2045. $t $(MAKE) -C $(APP) $v
  2046. $i "Check that all compiled files exist"
  2047. $t test -f $(APP)/apps/my_app/my_app.d
  2048. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  2049. $t test -f $(APP)/apps/my_app/ebin/boy.beam
  2050. $t test -f $(APP)/apps/my_app/ebin/girl.beam
  2051. $t test -d $(APP)/deps/cowlib
  2052. ifndef LEGACY
  2053. $i "Check that the application was compiled correctly"
  2054. $t $(ERL) -pa $(APP)/apps/*/ebin/ -eval " \
  2055. ok = application:load(my_app), \
  2056. {ok, MyAppDeps} = application:get_key(my_app, applications), \
  2057. true = lists:member(cowlib, MyAppDeps), \
  2058. halt()"
  2059. endif
  2060. core-app-hrl-include-loop: init
  2061. $i "Bootstrap a new OTP library named $(APP)"
  2062. $t mkdir $(APP)/
  2063. $t cp ../erlang.mk $(APP)/
  2064. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  2065. $i "Generate .hrl files with header loop"
  2066. $t mkdir $(APP)/include/
  2067. $t printf "%s\n" "-include(\"blue.hrl\")." > $(APP)/include/red.hrl
  2068. $t printf "%s\n" "-include(\"red.hrl\")." > $(APP)/include/blue.hrl
  2069. $i "Generate .erl files dependent from headers"
  2070. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  2071. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  2072. $i "Build the application. Compilation should fail"
  2073. $t ! $(MAKE) -C $(APP) $v
  2074. $i "Check .d file"
  2075. $t grep -q "src/use_blue.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2076. $t grep -q "src/use_red.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2077. core-app-hrl-include_lib-loop: init
  2078. $i "Bootstrap a new OTP library named $(APP)"
  2079. $t mkdir $(APP)/
  2080. $t cp ../erlang.mk $(APP)/
  2081. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  2082. $i "Generate .hrl files with heaeder loop"
  2083. $t mkdir $(APP)/include/
  2084. $t printf "%s\n" "-include_lib(\"blue.hrl\")." > $(APP)/include/red.hrl
  2085. $t printf "%s\n" "-include_lib(\"red.hrl\")." > $(APP)/include/blue.hrl
  2086. $i "Generate .erl files dependent from headers"
  2087. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  2088. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  2089. $i "Build the application. Compilation should fail"
  2090. $t ! $(MAKE) -C $(APP) $v
  2091. $i "Check .d file"
  2092. $t grep -q "src/use_blue.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2093. $t grep -q "src/use_red.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2094. core-app-hrl-include-loop-define-protected: init
  2095. $i "Bootstrap a new OTP library named $(APP)"
  2096. $t mkdir $(APP)/
  2097. $t cp ../erlang.mk $(APP)/
  2098. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  2099. $i "Generate .hrl files with hrl loop protection "
  2100. $t mkdir $(APP)/include/
  2101. $t printf "%s\n" "-ifndef(BLUE_HRL_LOADED)." "-define(BLUE_HRL_LOADED,true)." "-include(\"red.hrl\")." "-endif." > $(APP)/include/blue.hrl
  2102. $t printf "%s\n" "-ifndef(RED_HRL_LOADED)." "-define(RED_HRL_LOADED,true)." "-include(\"blue.hrl\")." "-endif." > $(APP)/include/red.hrl
  2103. $i "Generate .erl files dependent from headers"
  2104. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  2105. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  2106. $i "Build the application. Compilation should fail"
  2107. $t ! $(MAKE) -C $(APP) $v ; ret=$$?
  2108. $i "Check .d file"
  2109. $t grep -q "src/use_blue.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2110. $t grep -q "src/use_red.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2111. core-app-hrl-include_lib-loop-define-protected: init
  2112. $i "Bootstrap a new OTP library named $(APP)"
  2113. $t mkdir $(APP)/
  2114. $t cp ../erlang.mk $(APP)/
  2115. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  2116. $i "Generate .hrl files with hrl loop protection "
  2117. $t mkdir $(APP)/include/
  2118. $t printf "%s\n" "-ifndef(BLUE_HRL_LOADED)." "-define(BLUE_HRL_LOADED,true)." "-include_lib(\"red.hrl\")." "-endif." > $(APP)/include/blue.hrl
  2119. $t printf "%s\n" "-ifndef(RED_HRL_LOADED)." "-define(RED_HRL_LOADED,true)." "-include_lib(\"blue.hrl\")." "-endif." > $(APP)/include/red.hrl
  2120. $i "Generate .erl files dependent from headers"
  2121. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  2122. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  2123. $i "Build the application"
  2124. $t $(MAKE) -C $(APP) $v ; ret=$$?
  2125. $i "Check .d file"
  2126. $t grep -q "src/use_blue.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2127. $t grep -q "src/use_red.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2128. core-app-hrl-multiapps-include-loop-define-protected: init
  2129. $i "Create a multi application repository with no root application"
  2130. $t mkdir $(APP)/
  2131. $t cp ../erlang.mk $(APP)/
  2132. $t echo "include erlang.mk" > $(APP)/Makefile
  2133. $i "Create a new application named my_app"
  2134. $t $(MAKE) -C $(APP) new-lib in=my_app $v
  2135. $i "Create a new library named my_lib"
  2136. $t $(MAKE) -C $(APP) new-lib in=my_lib $v
  2137. $i "Add my_lib as LOCAL_DEPS of my_app"
  2138. $t echo "LOCAL_DEPS = my_lib" >> $(APP)/apps/my_app/Makefile
  2139. $i "Generate .hrl files"
  2140. $t mkdir $(APP)/apps/my_lib/include/
  2141. $t printf "%s\n" "-ifndef(BLUE_HRL_LOADED)." "-define(BLUE_HRL_LOADED,true)." "-include_lib(\"red.hrl\")." "-endif." > $(APP)/apps/my_lib/include/blue.hrl
  2142. $t printf "%s\n" "-ifndef(RED_HRL_LOADED)." "-define(RED_HRL_LOADED,true)." "-include_lib(\"blue.hrl\")." "-endif." > $(APP)/apps/my_lib/include/red.hrl
  2143. $i "Generate .erl files dependent from headers"
  2144. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"my_lib/include/blue.hrl\")." > $(APP)/apps/my_app/src/use_blue.erl
  2145. $t printf "%s\n" "-module(use_red)." "-include_lib(\"my_lib/include/red.hrl\")." > $(APP)/apps/my_app/src/use_red.erl
  2146. $i "Build the application"
  2147. $t $(MAKE) -C $(APP) $v
  2148. $i "Check that all compiled files exist"
  2149. $t test -f $(APP)/apps/my_app/my_app.d
  2150. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  2151. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  2152. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  2153. $i "Check that the application was compiled correctly"
  2154. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  2155. {ok, _Apps } = application:ensure_all_started(my_app), \
  2156. {ok, Mods = [use_blue, use_red]} \
  2157. = application:get_key(my_app, modules), \
  2158. [{module, M} = code:load_file(M) || M <- Mods], \
  2159. halt()"
  2160. $i "Touch one .hrl file; check that only required files are rebuilt"
  2161. # The use_red.erl gets touched because of its dependency to red.hrl.
  2162. $t printf "%s\n" \
  2163. $(APP)/apps/my_app/my_app.d \
  2164. $(APP)/apps/my_app/ebin/my_app.app \
  2165. $(APP)/apps/my_app/ebin/use_red.beam \
  2166. $(APP)/apps/my_app/src/use_red.erl \
  2167. $(APP)/apps/my_app/src/use_blue.erl \
  2168. $(APP)/apps/my_app/ebin/use_blue.beam | sort > $(APP)/EXPECT
  2169. $t $(SLEEP)
  2170. $t touch $(APP)/apps/my_lib/include/red.hrl
  2171. $t $(SLEEP)
  2172. $t $(MAKE) -C $(APP) $v
  2173. $t find $(APP)/apps/my_app -type f -newer $(APP)/apps/my_lib/include/red.hrl | sort | diff $(APP)/EXPECT -
  2174. $t rm $(APP)/EXPECT
  2175. $i "Check that the application was compiled correctly"
  2176. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  2177. {ok, _Apps } = application:ensure_all_started(my_app), \
  2178. {ok, Mods = [use_blue, use_red]} \
  2179. = application:get_key(my_app, modules), \
  2180. [{module, M} = code:load_file(M) || M <- Mods], \
  2181. halt()"
  2182. $i "Clean the application"
  2183. $t $(MAKE) -C $(APP) clean $v
  2184. $i "Check that source files still exist"
  2185. $t test -f $(APP)/Makefile
  2186. $t test -f $(APP)/erlang.mk
  2187. $t test -f $(APP)/apps/my_lib/Makefile
  2188. $t test -f $(APP)/apps/my_lib/include/blue.hrl
  2189. $t test -f $(APP)/apps/my_lib/include/red.hrl
  2190. $t test -f $(APP)/apps/my_app/Makefile
  2191. $t test -f $(APP)/apps/my_app/src/use_blue.erl
  2192. $t test -f $(APP)/apps/my_app/src/use_red.erl
  2193. ifdef LEGACY
  2194. $t test -f $(APP)/apps/my_lib/src/my_lib.app.src
  2195. $t test -f $(APP)/apps/my_app/src/my_app.app.src
  2196. endif
  2197. $i "Check that all build artifacts are removed"
  2198. $t test ! -e $(APP)/apps/my_lib/my_app.d
  2199. $t test ! -e $(APP)/apps/my_lib/ebin/
  2200. $t test ! -e $(APP)/apps/my_app/my_app.d
  2201. $t test ! -e $(APP)/apps/my_app/ebin/
  2202. $i "Build the application again"
  2203. $t $(MAKE) -C $(APP) $v
  2204. $i "Check that all compiled files exist"
  2205. $t test -f $(APP)/apps/my_app/my_app.d
  2206. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  2207. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  2208. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  2209. $i "Check that the application was compiled correctly"
  2210. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  2211. {ok, _Apps } = application:ensure_all_started(my_app), \
  2212. {ok, Mods = [use_blue, use_red]} \
  2213. = application:get_key(my_app, modules), \
  2214. [{module, M} = code:load_file(M) || M <- Mods], \
  2215. halt()"