core_app.mk 91 KB

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