core_app.mk 90 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793
  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 "yeccpars1(_,_,_,_,_) -> throw(not_implemented)." >> $(APP)/include/yecc_header.hrl
  1396. $t echo "yeccerror(_) -> throw(not_implemented)." >> $(APP)/include/yecc_header.hrl
  1397. # Required bits done, now part we'll actually test for.
  1398. $t echo "forty_two() -> 42." >> $(APP)/include/yecc_header.hrl
  1399. $i "Generate unrelated .erl files"
  1400. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1401. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1402. $i "Build the application"
  1403. $t YRL_ERLC_OPTS="-I include/yecc_header.hrl" $(MAKE) -C $(APP) $v
  1404. $i "Check that all compiled files exist"
  1405. $t test -f $(APP)/$(APP).d
  1406. $t test -f $(APP)/ebin/$(APP).app
  1407. $t test -f $(APP)/ebin/boy.beam
  1408. $t test -f $(APP)/ebin/girl.beam
  1409. $t test -f $(APP)/ebin/y_parse.beam
  1410. $t test -f $(APP)/src/y_parse.erl
  1411. $i "Check that the application was compiled correctly"
  1412. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1413. ok = application:start($(APP)), \
  1414. {ok, Mods = [boy, girl, y_parse]} \
  1415. = application:get_key($(APP), modules), \
  1416. [{module, M} = code:load_file(M) || M <- Mods], \
  1417. halt()"
  1418. $i "Check the built yecc module used the header"
  1419. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1420. {module, y_parse} = code:load_file(y_parse), \
  1421. 42 = y_parse:forty_two(), \
  1422. halt()"
  1423. $i "Check that the application was compiled correctly"
  1424. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1425. ok = application:start($(APP)), \
  1426. {ok, Mods = [boy, girl, y_parse]} \
  1427. = application:get_key($(APP), modules), \
  1428. [{module, M} = code:load_file(M) || M <- Mods], \
  1429. halt()"
  1430. core-app-yrl-include: init
  1431. $i "Bootstrap a new OTP library named $(APP)"
  1432. $t mkdir $(APP)/
  1433. $t cp ../erlang.mk $(APP)/
  1434. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1435. $i "Download a .yrl file with includes from Erlang/OTP"
  1436. $t curl -s -o $(APP)/src/core_parse.yrl $(OTP_MASTER)/lib/compiler/src/core_parse.yrl
  1437. $t curl -s -o $(APP)/src/core_parse.hrl $(OTP_MASTER)/lib/compiler/src/core_parse.hrl
  1438. $i "Generate unrelated .erl files"
  1439. $t echo "-module(boy)." > $(APP)/src/boy.erl
  1440. $t echo "-module(girl)." > $(APP)/src/girl.erl
  1441. $i "Build the application"
  1442. $t $(MAKE) -C $(APP) $v
  1443. $i "Check that all compiled files exist"
  1444. $t test -f $(APP)/$(APP).d
  1445. $t test -f $(APP)/ebin/$(APP).app
  1446. $t test -f $(APP)/ebin/boy.beam
  1447. $t test -f $(APP)/ebin/core_parse.beam
  1448. $t test -f $(APP)/ebin/girl.beam
  1449. $t test -f $(APP)/src/core_parse.erl
  1450. $i "Check that the application was compiled correctly"
  1451. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1452. ok = application:start($(APP)), \
  1453. {ok, Mods = [boy, core_parse, girl]} \
  1454. = application:get_key($(APP), modules), \
  1455. [{module, M} = code:load_file(M) || M <- Mods], \
  1456. halt()"
  1457. $i "Touch the .yrl file; check that only required files are rebuilt"
  1458. $t printf "%s\n" \
  1459. $(APP)/$(APP).d \
  1460. $(APP)/ebin/$(APP).app \
  1461. $(APP)/ebin/core_parse.beam \
  1462. $(APP)/src/core_parse.erl | sort > $(APP)/EXPECT
  1463. $t $(SLEEP)
  1464. $t touch $(APP)/src/core_parse.yrl
  1465. $t $(SLEEP)
  1466. $t $(MAKE) -C $(APP) $v
  1467. $t find $(APP) -type f -newer $(APP)/src/core_parse.yrl | sort | diff $(APP)/EXPECT -
  1468. $t rm $(APP)/EXPECT
  1469. $i "Check that the application was compiled correctly"
  1470. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1471. ok = application:start($(APP)), \
  1472. {ok, Mods = [boy, core_parse, girl]} \
  1473. = application:get_key($(APP), modules), \
  1474. [{module, M} = code:load_file(M) || M <- Mods], \
  1475. halt()"
  1476. $i "Touch the .hrl file included; check that only required files are rebuilt"
  1477. $t printf "%s\n" \
  1478. $(APP)/$(APP).d \
  1479. $(APP)/ebin/$(APP).app \
  1480. $(APP)/ebin/core_parse.beam \
  1481. $(APP)/src/core_parse.erl | sort > $(APP)/EXPECT
  1482. $t $(SLEEP)
  1483. $t touch $(APP)/src/core_parse.hrl
  1484. $t $(SLEEP)
  1485. $t $(MAKE) -C $(APP) $v
  1486. $t find $(APP) -type f -newer $(APP)/src/core_parse.hrl | sort | diff $(APP)/EXPECT -
  1487. $t rm $(APP)/EXPECT
  1488. $i "Check that the application was compiled correctly"
  1489. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1490. ok = application:start($(APP)), \
  1491. {ok, Mods = [boy, core_parse, girl]} \
  1492. = application:get_key($(APP), modules), \
  1493. [{module, M} = code:load_file(M) || M <- Mods], \
  1494. halt()"
  1495. $i "Clean the application"
  1496. $t $(MAKE) -C $(APP) clean $v
  1497. $i "Check that source files still exist"
  1498. $t test -f $(APP)/Makefile
  1499. $t test -f $(APP)/erlang.mk
  1500. ifdef LEGACY
  1501. $t test -f $(APP)/src/$(APP).app.src
  1502. endif
  1503. $t test -f $(APP)/src/boy.erl
  1504. $t test -f $(APP)/src/core_parse.hrl
  1505. $t test -f $(APP)/src/core_parse.yrl
  1506. $t test -f $(APP)/src/girl.erl
  1507. $i "Check that all build artifacts are removed, including intermediates"
  1508. $t test ! -e $(APP)/$(APP).d
  1509. $t test ! -e $(APP)/ebin/
  1510. $t test ! -e $(APP)/src/core_parse.erl
  1511. $i "Build the application again"
  1512. $t $(MAKE) -C $(APP) $v
  1513. $i "Check that all compiled files exist"
  1514. $t test -f $(APP)/$(APP).d
  1515. $t test -f $(APP)/ebin/$(APP).app
  1516. $t test -f $(APP)/ebin/boy.beam
  1517. $t test -f $(APP)/ebin/core_parse.beam
  1518. $t test -f $(APP)/ebin/girl.beam
  1519. $t test -f $(APP)/src/core_parse.erl
  1520. $i "Check that the application was compiled correctly"
  1521. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1522. ok = application:start($(APP)), \
  1523. {ok, Mods = [boy, core_parse, girl]} \
  1524. = application:get_key($(APP), modules), \
  1525. [{module, M} = code:load_file(M) || M <- Mods], \
  1526. halt()"
  1527. core-app-yrl-test-build-then-normal-build: init
  1528. $i "Bootstrap a new OTP library named $(APP)"
  1529. $t mkdir $(APP)/
  1530. $t cp ../erlang.mk $(APP)/
  1531. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1532. $i "Create the parser .yrl file"
  1533. $t printf "%s\n" \
  1534. "Nonterminals top." \
  1535. "Terminals plus num." \
  1536. "Rootsymbol top." \
  1537. "top -> num plus num : {'$1', '$3'}." > $(APP)/src/$(APP)_parser.yrl
  1538. $i "Create the test suite"
  1539. $t mkdir $(APP)/test
  1540. $t printf "%s\n" \
  1541. "-module(test_SUITE)." \
  1542. "-export([all/0, test/1])." \
  1543. "all() -> [test]." \
  1544. "test(_) -> 0=0." > $(APP)/test/test_SUITE.erl
  1545. $i "Build the application in test mode"
  1546. $t $(MAKE) -C $(APP) ct $v
  1547. $i "Build the application in normal mode"
  1548. $t $(MAKE) -C $(APP) $v
  1549. core-app-hrl-include-lib: init
  1550. $i "Bootstrap a new OTP library named $(APP)"
  1551. $t mkdir $(APP)/
  1552. $t cp ../erlang.mk $(APP)/
  1553. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1554. $i "Generate .hrl files"
  1555. $t mkdir $(APP)/include/
  1556. $t touch $(APP)/include/blue.hrl $(APP)/include/red.hrl
  1557. $i "Generate .erl files dependent from headers"
  1558. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  1559. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  1560. $i "Build the application"
  1561. $t $(MAKE) -C $(APP) $v
  1562. $i "Check that all compiled files exist"
  1563. $t test -f $(APP)/$(APP).d
  1564. $t test -f $(APP)/ebin/$(APP).app
  1565. $t test -f $(APP)/ebin/use_blue.beam
  1566. $t test -f $(APP)/ebin/use_red.beam
  1567. $i "Check that the application was compiled correctly"
  1568. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1569. ok = application:start($(APP)), \
  1570. {ok, Mods = [use_blue, use_red]} \
  1571. = application:get_key($(APP), modules), \
  1572. [{module, M} = code:load_file(M) || M <- Mods], \
  1573. halt()"
  1574. $i "Touch one .hrl file; check that only required files are rebuilt"
  1575. # The use_red.erl gets touched because of its dependency to red.hrl.
  1576. $t printf "%s\n" \
  1577. $(APP)/$(APP).d \
  1578. $(APP)/ebin/$(APP).app \
  1579. $(APP)/ebin/use_red.beam \
  1580. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  1581. $t $(SLEEP)
  1582. $t touch $(APP)/include/red.hrl
  1583. $t $(SLEEP)
  1584. $t $(MAKE) -C $(APP) $v
  1585. $t find $(APP) -type f -newer $(APP)/include/red.hrl | sort | diff $(APP)/EXPECT -
  1586. $t rm $(APP)/EXPECT
  1587. $i "Check that the application was compiled correctly"
  1588. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1589. ok = application:start($(APP)), \
  1590. {ok, Mods = [use_blue, use_red]} \
  1591. = application:get_key($(APP), modules), \
  1592. [{module, M} = code:load_file(M) || M <- Mods], \
  1593. halt()"
  1594. $i "Clean the application"
  1595. $t $(MAKE) -C $(APP) clean $v
  1596. $i "Check that source files still exist"
  1597. $t test -f $(APP)/Makefile
  1598. $t test -f $(APP)/erlang.mk
  1599. $t test -f $(APP)/include/blue.hrl
  1600. $t test -f $(APP)/include/red.hrl
  1601. ifdef LEGACY
  1602. $t test -f $(APP)/src/$(APP).app.src
  1603. endif
  1604. $t test -f $(APP)/src/use_blue.erl
  1605. $t test -f $(APP)/src/use_red.erl
  1606. $i "Check that all build artifacts are removed"
  1607. $t test ! -e $(APP)/$(APP).d
  1608. $t test ! -e $(APP)/ebin/
  1609. $i "Build the application again"
  1610. $t $(MAKE) -C $(APP) $v
  1611. $i "Check that all compiled files exist"
  1612. $t test -f $(APP)/$(APP).d
  1613. $t test -f $(APP)/ebin/$(APP).app
  1614. $t test -f $(APP)/ebin/use_blue.beam
  1615. $t test -f $(APP)/ebin/use_red.beam
  1616. $i "Check that the application was compiled correctly"
  1617. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1618. ok = application:start($(APP)), \
  1619. {ok, Mods = [use_blue, use_red]} \
  1620. = application:get_key($(APP), modules), \
  1621. [{module, M} = code:load_file(M) || M <- Mods], \
  1622. halt()"
  1623. core-app-hrl-include-lib-recursive: init
  1624. $i "Bootstrap a new OTP library named $(APP)"
  1625. $t mkdir $(APP)/
  1626. $t cp ../erlang.mk $(APP)/
  1627. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1628. $i "Generate .hrl files"
  1629. $t mkdir $(APP)/include/
  1630. $t touch $(APP)/include/blue.hrl $(APP)/include/pill.hrl
  1631. $t echo "-include_lib(\"pill.hrl\")." > $(APP)/include/red.hrl
  1632. $i "Generate .erl files dependent from headers"
  1633. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  1634. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  1635. $i "Build the application"
  1636. $t $(MAKE) -C $(APP) $v
  1637. $i "Check that all compiled files exist"
  1638. $t test -f $(APP)/$(APP).d
  1639. $t test -f $(APP)/ebin/$(APP).app
  1640. $t test -f $(APP)/ebin/use_blue.beam
  1641. $t test -f $(APP)/ebin/use_red.beam
  1642. $i "Check that the application was compiled correctly"
  1643. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1644. ok = application:start($(APP)), \
  1645. {ok, Mods = [use_blue, use_red]} \
  1646. = application:get_key($(APP), modules), \
  1647. [{module, M} = code:load_file(M) || M <- Mods], \
  1648. halt()"
  1649. $i "Touch the deepest .hrl file; check that only required files are rebuilt"
  1650. # The use_red.erl gets touched because of its dependency to red.hrl and pill.hrl.
  1651. $t printf "%s\n" \
  1652. $(APP)/$(APP).d \
  1653. $(APP)/ebin/$(APP).app \
  1654. $(APP)/ebin/use_red.beam \
  1655. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  1656. $t $(SLEEP)
  1657. $t touch $(APP)/include/pill.hrl
  1658. $t $(SLEEP)
  1659. $t $(MAKE) -C $(APP) $v
  1660. $t find $(APP) -type f -newer $(APP)/include/pill.hrl | sort | diff $(APP)/EXPECT -
  1661. $t rm $(APP)/EXPECT
  1662. $i "Check that the application was compiled correctly"
  1663. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1664. ok = application:start($(APP)), \
  1665. {ok, Mods = [use_blue, use_red]} \
  1666. = application:get_key($(APP), modules), \
  1667. [{module, M} = code:load_file(M) || M <- Mods], \
  1668. halt()"
  1669. $i "Clean the application"
  1670. $t $(MAKE) -C $(APP) clean $v
  1671. $i "Check that source files still exist"
  1672. $t test -f $(APP)/Makefile
  1673. $t test -f $(APP)/erlang.mk
  1674. $t test -f $(APP)/include/blue.hrl
  1675. $t test -f $(APP)/include/pill.hrl
  1676. $t test -f $(APP)/include/red.hrl
  1677. ifdef LEGACY
  1678. $t test -f $(APP)/src/$(APP).app.src
  1679. endif
  1680. $t test -f $(APP)/src/use_blue.erl
  1681. $t test -f $(APP)/src/use_red.erl
  1682. $i "Check that all build artifacts are removed"
  1683. $t test ! -e $(APP)/$(APP).d
  1684. $t test ! -e $(APP)/ebin/
  1685. $i "Build the application again"
  1686. $t $(MAKE) -C $(APP) $v
  1687. $i "Check that all compiled files exist"
  1688. $t test -f $(APP)/$(APP).d
  1689. $t test -f $(APP)/ebin/$(APP).app
  1690. $t test -f $(APP)/ebin/use_blue.beam
  1691. $t test -f $(APP)/ebin/use_red.beam
  1692. $i "Check that the application was compiled correctly"
  1693. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1694. ok = application:start($(APP)), \
  1695. {ok, Mods = [use_blue, use_red]} \
  1696. = application:get_key($(APP), modules), \
  1697. [{module, M} = code:load_file(M) || M <- Mods], \
  1698. halt()"
  1699. core-app-hrl-multiapps-include-lib: init
  1700. $i "Create a multi application repository with no root application"
  1701. $t mkdir $(APP)/
  1702. $t cp ../erlang.mk $(APP)/
  1703. $t echo "include erlang.mk" > $(APP)/Makefile
  1704. $i "Create a new application named my_app"
  1705. $t $(MAKE) -C $(APP) new-lib in=my_app $v
  1706. $i "Create a new library named my_lib"
  1707. $t $(MAKE) -C $(APP) new-lib in=my_lib $v
  1708. $i "Add my_lib as LOCAL_DEPS of my_app"
  1709. $t echo "LOCAL_DEPS = my_lib" >> $(APP)/apps/my_app/Makefile
  1710. $i "Generate .hrl files"
  1711. $t mkdir $(APP)/apps/my_lib/include/
  1712. $t touch $(APP)/apps/my_lib/include/blue.hrl $(APP)/apps/my_lib/include/red.hrl
  1713. $i "Generate .erl files dependent from headers"
  1714. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"my_lib/include/blue.hrl\")." > $(APP)/apps/my_app/src/use_blue.erl
  1715. $t printf "%s\n" "-module(use_red)." "-include_lib(\"my_lib/include/red.hrl\")." > $(APP)/apps/my_app/src/use_red.erl
  1716. $i "Build the application"
  1717. $t $(MAKE) -C $(APP) $v
  1718. $i "Check that all compiled files exist"
  1719. $t test -f $(APP)/apps/my_app/my_app.d
  1720. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  1721. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  1722. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  1723. $i "Check that the application was compiled correctly"
  1724. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1725. {ok, _Apps } = application:ensure_all_started(my_app), \
  1726. {ok, Mods = [use_blue, use_red]} \
  1727. = application:get_key(my_app, modules), \
  1728. [{module, M} = code:load_file(M) || M <- Mods], \
  1729. halt()"
  1730. $i "Touch one .hrl file; check that only required files are rebuilt"
  1731. # The use_red.erl gets touched because of its dependency to red.hrl.
  1732. $t printf "%s\n" \
  1733. $(APP)/apps/my_app/my_app.d \
  1734. $(APP)/apps/my_app/ebin/my_app.app \
  1735. $(APP)/apps/my_app/ebin/use_red.beam \
  1736. $(APP)/apps/my_app/src/use_red.erl | sort > $(APP)/EXPECT
  1737. $t $(SLEEP)
  1738. $t touch $(APP)/apps/my_lib/include/red.hrl
  1739. $t $(SLEEP)
  1740. $t $(MAKE) -C $(APP) $v
  1741. $t find $(APP)/apps/my_app -type f -newer $(APP)/apps/my_lib/include/red.hrl | sort | diff $(APP)/EXPECT -
  1742. $t rm $(APP)/EXPECT
  1743. $i "Check that the application was compiled correctly"
  1744. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1745. {ok, _Apps } = application:ensure_all_started(my_app), \
  1746. {ok, Mods = [use_blue, use_red]} \
  1747. = application:get_key(my_app, modules), \
  1748. [{module, M} = code:load_file(M) || M <- Mods], \
  1749. halt()"
  1750. $i "Clean the application"
  1751. $t $(MAKE) -C $(APP) clean $v
  1752. $i "Check that source files still exist"
  1753. $t test -f $(APP)/Makefile
  1754. $t test -f $(APP)/erlang.mk
  1755. $t test -f $(APP)/apps/my_lib/Makefile
  1756. $t test -f $(APP)/apps/my_lib/include/blue.hrl
  1757. $t test -f $(APP)/apps/my_lib/include/red.hrl
  1758. $t test -f $(APP)/apps/my_app/Makefile
  1759. $t test -f $(APP)/apps/my_app/src/use_blue.erl
  1760. $t test -f $(APP)/apps/my_app/src/use_red.erl
  1761. ifdef LEGACY
  1762. $t test -f $(APP)/apps/my_lib/src/my_lib.app.src
  1763. $t test -f $(APP)/apps/my_app/src/my_app.app.src
  1764. endif
  1765. $i "Check that all build artifacts are removed"
  1766. $t test ! -e $(APP)/apps/my_lib/my_app.d
  1767. $t test ! -e $(APP)/apps/my_lib/ebin/
  1768. $t test ! -e $(APP)/apps/my_app/my_app.d
  1769. $t test ! -e $(APP)/apps/my_app/ebin/
  1770. $i "Build the application again"
  1771. $t $(MAKE) -C $(APP) $v
  1772. $i "Check that all compiled files exist"
  1773. $t test -f $(APP)/apps/my_app/my_app.d
  1774. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  1775. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  1776. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  1777. $i "Check that the application was compiled correctly"
  1778. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1779. {ok, _Apps } = application:ensure_all_started(my_app), \
  1780. {ok, Mods = [use_blue, use_red]} \
  1781. = application:get_key(my_app, modules), \
  1782. [{module, M} = code:load_file(M) || M <- Mods], \
  1783. halt()"
  1784. core-app-hrl-multiapps-include-lib-recursive: init
  1785. $i "Create a multi application repository with no root application"
  1786. $t mkdir $(APP)/
  1787. $t cp ../erlang.mk $(APP)/
  1788. $t echo "include erlang.mk" > $(APP)/Makefile
  1789. $i "Create a new application named my_app"
  1790. $t $(MAKE) -C $(APP) new-lib in=my_app $v
  1791. $i "Create a new library named my_lib"
  1792. $t $(MAKE) -C $(APP) new-lib in=my_lib $v
  1793. $i "Add my_lib as LOCAL_DEPS of my_app"
  1794. $t echo "LOCAL_DEPS = my_lib" >> $(APP)/apps/my_app/Makefile
  1795. $i "Generate .hrl files"
  1796. $t mkdir $(APP)/apps/my_lib/include/
  1797. $t touch $(APP)/apps/my_lib/include/blue.hrl $(APP)/apps/my_lib/include/red.hrl $(APP)/apps/my_lib/include/pill.hrl
  1798. $t echo "-include(\"pill.hrl\")." > $(APP)/apps/my_lib/include/red.hrl
  1799. $i "Generate .erl files dependent from headers"
  1800. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"my_lib/include/blue.hrl\")." > $(APP)/apps/my_app/src/use_blue.erl
  1801. $t printf "%s\n" "-module(use_red)." "-include_lib(\"my_lib/include/red.hrl\")." > $(APP)/apps/my_app/src/use_red.erl
  1802. $i "Build the application"
  1803. $t $(MAKE) -C $(APP) $v
  1804. $i "Check that all compiled files exist"
  1805. $t test -f $(APP)/apps/my_app/my_app.d
  1806. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  1807. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  1808. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  1809. $i "Check that the application was compiled correctly"
  1810. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1811. {ok, _Apps } = application:ensure_all_started(my_app), \
  1812. {ok, Mods = [use_blue, use_red]} \
  1813. = application:get_key(my_app, modules), \
  1814. [{module, M} = code:load_file(M) || M <- Mods], \
  1815. halt()"
  1816. $i "Touch one .hrl file; check that only required files are rebuilt"
  1817. # The use_red.erl gets touched because of its dependency to red.hrl.
  1818. $t printf "%s\n" \
  1819. $(APP)/apps/my_app/my_app.d \
  1820. $(APP)/apps/my_app/ebin/my_app.app \
  1821. $(APP)/apps/my_app/ebin/use_red.beam \
  1822. $(APP)/apps/my_app/src/use_red.erl | sort > $(APP)/EXPECT
  1823. $t $(SLEEP)
  1824. $t touch $(APP)/apps/my_lib/include/pill.hrl
  1825. $t $(SLEEP)
  1826. $t $(MAKE) -C $(APP) $v
  1827. $t find $(APP)/apps/my_app -type f -newer $(APP)/apps/my_lib/include/pill.hrl | sort | diff $(APP)/EXPECT -
  1828. $t rm $(APP)/EXPECT
  1829. $i "Check that the application was compiled correctly"
  1830. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1831. {ok, _Apps } = application:ensure_all_started(my_app), \
  1832. {ok, Mods = [use_blue, use_red]} \
  1833. = application:get_key(my_app, modules), \
  1834. [{module, M} = code:load_file(M) || M <- Mods], \
  1835. halt()"
  1836. $i "Clean the application"
  1837. $t $(MAKE) -C $(APP) clean $v
  1838. $i "Check that source files still exist"
  1839. $t test -f $(APP)/Makefile
  1840. $t test -f $(APP)/erlang.mk
  1841. $t test -f $(APP)/apps/my_lib/Makefile
  1842. $t test -f $(APP)/apps/my_lib/include/blue.hrl
  1843. $t test -f $(APP)/apps/my_lib/include/red.hrl
  1844. $t test -f $(APP)/apps/my_lib/include/pill.hrl
  1845. $t test -f $(APP)/apps/my_app/Makefile
  1846. $t test -f $(APP)/apps/my_app/src/use_blue.erl
  1847. $t test -f $(APP)/apps/my_app/src/use_red.erl
  1848. ifdef LEGACY
  1849. $t test -f $(APP)/apps/my_lib/src/my_lib.app.src
  1850. $t test -f $(APP)/apps/my_app/src/my_app.app.src
  1851. endif
  1852. $i "Check that all build artifacts are removed"
  1853. $t test ! -e $(APP)/apps/my_lib/my_app.d
  1854. $t test ! -e $(APP)/apps/my_lib/ebin/
  1855. $t test ! -e $(APP)/apps/my_app/my_app.d
  1856. $t test ! -e $(APP)/apps/my_app/ebin/
  1857. $i "Build the application again"
  1858. $t $(MAKE) -C $(APP) $v
  1859. $i "Check that all compiled files exist"
  1860. $t test -f $(APP)/apps/my_app/my_app.d
  1861. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  1862. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  1863. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  1864. $i "Check that the application was compiled correctly"
  1865. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  1866. {ok, _Apps } = application:ensure_all_started(my_app), \
  1867. {ok, Mods = [use_blue, use_red]} \
  1868. = application:get_key(my_app, modules), \
  1869. [{module, M} = code:load_file(M) || M <- Mods], \
  1870. halt()"
  1871. core-app-hrl-include-lib-src: init
  1872. $i "Bootstrap a new OTP library named $(APP)"
  1873. $t mkdir $(APP)/
  1874. $t cp ../erlang.mk $(APP)/
  1875. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1876. $t touch $(APP)/src/blue.hrl $(APP)/src/red.hrl
  1877. $i "Generate .erl files dependent from headers"
  1878. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  1879. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  1880. $i "Build the application"
  1881. $t $(MAKE) -C $(APP) $v
  1882. $i "Check that all compiled files exist"
  1883. $t test -f $(APP)/$(APP).d
  1884. $t test -f $(APP)/ebin/$(APP).app
  1885. $t test -f $(APP)/ebin/use_blue.beam
  1886. $t test -f $(APP)/ebin/use_red.beam
  1887. $i "Check that the application was compiled correctly"
  1888. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1889. ok = application:start($(APP)), \
  1890. {ok, Mods = [use_blue, use_red]} \
  1891. = application:get_key($(APP), modules), \
  1892. [{module, M} = code:load_file(M) || M <- Mods], \
  1893. halt()"
  1894. $i "Touch one .hrl file; check that only required files are rebuilt"
  1895. # The use_red.erl gets touched because of its dependency to red.hrl.
  1896. $t printf "%s\n" \
  1897. $(APP)/$(APP).d \
  1898. $(APP)/ebin/$(APP).app \
  1899. $(APP)/ebin/use_red.beam \
  1900. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  1901. $t $(SLEEP)
  1902. $t touch $(APP)/src/red.hrl
  1903. $t $(SLEEP)
  1904. $t $(MAKE) -C $(APP) $v
  1905. $t find $(APP) -type f -newer $(APP)/src/red.hrl | sort | diff $(APP)/EXPECT -
  1906. $t rm $(APP)/EXPECT
  1907. $i "Check that the application was compiled correctly"
  1908. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1909. ok = application:start($(APP)), \
  1910. {ok, Mods = [use_blue, use_red]} \
  1911. = application:get_key($(APP), modules), \
  1912. [{module, M} = code:load_file(M) || M <- Mods], \
  1913. halt()"
  1914. $i "Clean the application"
  1915. $t $(MAKE) -C $(APP) clean $v
  1916. $i "Check that source files still exist"
  1917. $t test -f $(APP)/Makefile
  1918. $t test -f $(APP)/erlang.mk
  1919. $t test -f $(APP)/src/blue.hrl
  1920. $t test -f $(APP)/src/red.hrl
  1921. ifdef LEGACY
  1922. $t test -f $(APP)/src/$(APP).app.src
  1923. endif
  1924. $t test -f $(APP)/src/use_blue.erl
  1925. $t test -f $(APP)/src/use_red.erl
  1926. $i "Check that all build artifacts are removed"
  1927. $t test ! -e $(APP)/$(APP).d
  1928. $t test ! -e $(APP)/ebin/
  1929. $i "Build the application again"
  1930. $t $(MAKE) -C $(APP) $v
  1931. $i "Check that all compiled files exist"
  1932. $t test -f $(APP)/$(APP).d
  1933. $t test -f $(APP)/ebin/$(APP).app
  1934. $t test -f $(APP)/ebin/use_blue.beam
  1935. $t test -f $(APP)/ebin/use_red.beam
  1936. $i "Check that the application was compiled correctly"
  1937. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1938. ok = application:start($(APP)), \
  1939. {ok, Mods = [use_blue, use_red]} \
  1940. = application:get_key($(APP), modules), \
  1941. [{module, M} = code:load_file(M) || M <- Mods], \
  1942. halt()"
  1943. core-app-hrl-include-lib-src-recursive: init
  1944. $i "Bootstrap a new OTP library named $(APP)"
  1945. $t mkdir $(APP)/
  1946. $t cp ../erlang.mk $(APP)/
  1947. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  1948. $i "Generate .hrl files"
  1949. $t touch $(APP)/src/blue.hrl $(APP)/src/pill.hrl
  1950. $t echo "-include_lib(\"pill.hrl\")." > $(APP)/src/red.hrl
  1951. $i "Generate .erl files dependent from headers"
  1952. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  1953. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  1954. $i "Build the application"
  1955. $t $(MAKE) -C $(APP) $v
  1956. $i "Check that all compiled files exist"
  1957. $t test -f $(APP)/$(APP).d
  1958. $t test -f $(APP)/ebin/$(APP).app
  1959. $t test -f $(APP)/ebin/use_blue.beam
  1960. $t test -f $(APP)/ebin/use_red.beam
  1961. $i "Check that the application was compiled correctly"
  1962. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1963. ok = application:start($(APP)), \
  1964. {ok, Mods = [use_blue, use_red]} \
  1965. = application:get_key($(APP), modules), \
  1966. [{module, M} = code:load_file(M) || M <- Mods], \
  1967. halt()"
  1968. $i "Touch the deepest .hrl file; check that only required files are rebuilt"
  1969. # The use_red.erl gets touched because of its dependency to red.hrl and pill.hrl.
  1970. $t printf "%s\n" \
  1971. $(APP)/$(APP).d \
  1972. $(APP)/ebin/$(APP).app \
  1973. $(APP)/ebin/use_red.beam \
  1974. $(APP)/src/use_red.erl | sort > $(APP)/EXPECT
  1975. $t $(SLEEP)
  1976. $t touch $(APP)/src/pill.hrl
  1977. $t $(SLEEP)
  1978. $t $(MAKE) -C $(APP) $v
  1979. $t find $(APP) -type f -newer $(APP)/src/pill.hrl | sort | diff $(APP)/EXPECT -
  1980. $t rm $(APP)/EXPECT
  1981. $i "Check that the application was compiled correctly"
  1982. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  1983. ok = application:start($(APP)), \
  1984. {ok, Mods = [use_blue, use_red]} \
  1985. = application:get_key($(APP), modules), \
  1986. [{module, M} = code:load_file(M) || M <- Mods], \
  1987. halt()"
  1988. $i "Clean the application"
  1989. $t $(MAKE) -C $(APP) clean $v
  1990. $i "Check that source files still exist"
  1991. $t test -f $(APP)/Makefile
  1992. $t test -f $(APP)/erlang.mk
  1993. $t test -f $(APP)/src/blue.hrl
  1994. $t test -f $(APP)/src/pill.hrl
  1995. $t test -f $(APP)/src/red.hrl
  1996. ifdef LEGACY
  1997. $t test -f $(APP)/src/$(APP).app.src
  1998. endif
  1999. $t test -f $(APP)/src/use_blue.erl
  2000. $t test -f $(APP)/src/use_red.erl
  2001. $i "Check that all build artifacts are removed"
  2002. $t test ! -e $(APP)/$(APP).d
  2003. $t test ! -e $(APP)/ebin/
  2004. $i "Build the application again"
  2005. $t $(MAKE) -C $(APP) $v
  2006. $i "Check that all compiled files exist"
  2007. $t test -f $(APP)/$(APP).d
  2008. $t test -f $(APP)/ebin/$(APP).app
  2009. $t test -f $(APP)/ebin/use_blue.beam
  2010. $t test -f $(APP)/ebin/use_red.beam
  2011. $i "Check that the application was compiled correctly"
  2012. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  2013. ok = application:start($(APP)), \
  2014. {ok, Mods = [use_blue, use_red]} \
  2015. = application:get_key($(APP), modules), \
  2016. [{module, M} = code:load_file(M) || M <- Mods], \
  2017. halt()"
  2018. core-app-hrl-deps: init
  2019. $i "Create a multi application repository with no root application"
  2020. $t mkdir $(APP)/
  2021. $t cp ../erlang.mk $(APP)/
  2022. $t echo "include erlang.mk" > $(APP)/Makefile
  2023. $i "Create a new application named my_app"
  2024. $t $(MAKE) -C $(APP) new-lib in=my_app $v
  2025. $t echo "DEPS = cowlib" > $(APP)/apps/my_app/Makefile
  2026. $t echo "dep_cowlib_commit = master" >> $(APP)/apps/my_app/Makefile
  2027. $t echo "include ../../erlang.mk" >> $(APP)/apps/my_app/Makefile
  2028. $t printf "%s\n" "-module(boy)." "-include_lib(\"cowlib/include/cow_inline.hrl\")." > $(APP)/apps/my_app/src/boy.erl
  2029. $t printf "%s\n" "-module(girl)." > $(APP)/apps/my_app/src/girl.erl
  2030. $i "Build the application"
  2031. $t $(MAKE) -C $(APP) $v
  2032. $i "Check that all compiled files exist"
  2033. $t test -f $(APP)/apps/my_app/my_app.d
  2034. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  2035. $t test -f $(APP)/apps/my_app/ebin/boy.beam
  2036. $t test -f $(APP)/apps/my_app/ebin/girl.beam
  2037. $t test -f $(APP)/deps/cowlib/ebin/cowlib.app
  2038. ifndef LEGACY
  2039. $i "Check that the application was compiled correctly"
  2040. $t $(ERL) -pa $(APP)/apps/*/ebin/ -eval " \
  2041. ok = application:load(my_app), \
  2042. {ok, MyAppDeps} = application:get_key(my_app, applications), \
  2043. true = lists:member(cowlib, MyAppDeps), \
  2044. halt()"
  2045. endif
  2046. $i "Touch cowlib .hrl file; check that only required files are rebuilt"
  2047. $t printf "%s\n" \
  2048. $(APP)/apps/my_app/my_app.d \
  2049. $(APP)/apps/my_app/ebin/my_app.app \
  2050. $(APP)/apps/my_app/ebin/boy.beam \
  2051. $(APP)/apps/my_app/src/boy.erl | sort > $(APP)/EXPECT
  2052. $t $(SLEEP)
  2053. $t touch $(APP)/deps/cowlib/include/cow_inline.hrl
  2054. $t $(SLEEP)
  2055. $t $(MAKE) -C $(APP) $v
  2056. $t find $(APP)/apps/my_app -type f -newer $(APP)/deps/cowlib/include/cow_inline.hrl | sort | diff $(APP)/EXPECT -
  2057. $t rm $(APP)/EXPECT
  2058. $i "Clean Cowlib"
  2059. $t $(MAKE) -C $(APP)/deps/cowlib clean $v
  2060. $i "Check that Cowlib compiled files were removed"
  2061. $t test ! -e $(APP)/deps/cowlib/ebin/cowlib.app
  2062. $i "Build the application again"
  2063. $t $(MAKE) -C $(APP) $v
  2064. $i "Check that Cowlib compiled files exist"
  2065. $t test -f $(APP)/deps/cowlib/ebin/cowlib.app
  2066. $i "Clean the application"
  2067. $t $(MAKE) -C $(APP) clean $v
  2068. $i "Check that Cowlib is still here"
  2069. $t test -d $(APP)/deps/cowlib
  2070. $i "Check that all relevant files were removed"
  2071. $t test ! -e $(APP)/apps/my_app/my_app.d
  2072. $t test ! -e $(APP)/apps/my_app/ebin/my_app.app
  2073. $t test ! -e $(APP)/apps/my_app/ebin/boy.beam
  2074. $t test ! -e $(APP)/apps/my_app/ebin/girl.beam
  2075. $i "Distclean the application"
  2076. $t $(MAKE) -C $(APP) distclean $v
  2077. $i "Check that all relevant files were removed"
  2078. $t test ! -e $(APP)/deps
  2079. $i "Build the application"
  2080. $t $(MAKE) -C $(APP) $v
  2081. $i "Check that all compiled files exist"
  2082. $t test -f $(APP)/apps/my_app/my_app.d
  2083. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  2084. $t test -f $(APP)/apps/my_app/ebin/boy.beam
  2085. $t test -f $(APP)/apps/my_app/ebin/girl.beam
  2086. $t test -d $(APP)/deps/cowlib
  2087. ifndef LEGACY
  2088. $i "Check that the application was compiled correctly"
  2089. $t $(ERL) -pa $(APP)/apps/*/ebin/ -eval " \
  2090. ok = application:load(my_app), \
  2091. {ok, MyAppDeps} = application:get_key(my_app, applications), \
  2092. true = lists:member(cowlib, MyAppDeps), \
  2093. halt()"
  2094. endif
  2095. core-app-hrl-include-loop: init
  2096. $i "Bootstrap a new OTP library named $(APP)"
  2097. $t mkdir $(APP)/
  2098. $t cp ../erlang.mk $(APP)/
  2099. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  2100. $i "Generate .hrl files with header loop"
  2101. $t mkdir $(APP)/include/
  2102. $t printf "%s\n" "-include(\"blue.hrl\")." > $(APP)/include/red.hrl
  2103. $t printf "%s\n" "-include(\"red.hrl\")." > $(APP)/include/blue.hrl
  2104. $i "Generate .erl files dependent from headers"
  2105. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  2106. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  2107. $i "Build the application. Compilation should fail"
  2108. $t ! $(MAKE) -C $(APP) $v
  2109. $i "Check .d file"
  2110. $t grep -q "src/use_blue.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2111. $t grep -q "src/use_red.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2112. core-app-hrl-include_lib-loop: init
  2113. $i "Bootstrap a new OTP library named $(APP)"
  2114. $t mkdir $(APP)/
  2115. $t cp ../erlang.mk $(APP)/
  2116. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  2117. $i "Generate .hrl files with heaeder loop"
  2118. $t mkdir $(APP)/include/
  2119. $t printf "%s\n" "-include_lib(\"blue.hrl\")." > $(APP)/include/red.hrl
  2120. $t printf "%s\n" "-include_lib(\"red.hrl\")." > $(APP)/include/blue.hrl
  2121. $i "Generate .erl files dependent from headers"
  2122. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  2123. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  2124. $i "Build the application. Compilation should fail"
  2125. $t ! $(MAKE) -C $(APP) $v
  2126. $i "Check .d file"
  2127. $t grep -q "src/use_blue.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2128. $t grep -q "src/use_red.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2129. core-app-hrl-include-loop-define-protected: init
  2130. $i "Bootstrap a new OTP library named $(APP)"
  2131. $t mkdir $(APP)/
  2132. $t cp ../erlang.mk $(APP)/
  2133. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  2134. $i "Generate .hrl files with hrl loop protection "
  2135. $t mkdir $(APP)/include/
  2136. $t printf "%s\n" "-ifndef(BLUE_HRL_LOADED)." "-define(BLUE_HRL_LOADED,true)." "-include(\"red.hrl\")." "-endif." > $(APP)/include/blue.hrl
  2137. $t printf "%s\n" "-ifndef(RED_HRL_LOADED)." "-define(RED_HRL_LOADED,true)." "-include(\"blue.hrl\")." "-endif." > $(APP)/include/red.hrl
  2138. $i "Generate .erl files dependent from headers"
  2139. $t printf "%s\n" "-module(use_blue)." "-include(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  2140. $t printf "%s\n" "-module(use_red)." "-include(\"red.hrl\")." > $(APP)/src/use_red.erl
  2141. $i "Build the application. Compilation should fail"
  2142. $t ! $(MAKE) -C $(APP) $v ; ret=$$?
  2143. $i "Check .d file"
  2144. $t grep -q "src/use_blue.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2145. $t grep -q "src/use_red.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2146. core-app-hrl-include_lib-loop-define-protected: init
  2147. $i "Bootstrap a new OTP library named $(APP)"
  2148. $t mkdir $(APP)/
  2149. $t cp ../erlang.mk $(APP)/
  2150. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  2151. $i "Generate .hrl files with hrl loop protection "
  2152. $t mkdir $(APP)/include/
  2153. $t printf "%s\n" "-ifndef(BLUE_HRL_LOADED)." "-define(BLUE_HRL_LOADED,true)." "-include_lib(\"red.hrl\")." "-endif." > $(APP)/include/blue.hrl
  2154. $t printf "%s\n" "-ifndef(RED_HRL_LOADED)." "-define(RED_HRL_LOADED,true)." "-include_lib(\"blue.hrl\")." "-endif." > $(APP)/include/red.hrl
  2155. $i "Generate .erl files dependent from headers"
  2156. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"blue.hrl\")." > $(APP)/src/use_blue.erl
  2157. $t printf "%s\n" "-module(use_red)." "-include_lib(\"red.hrl\")." > $(APP)/src/use_red.erl
  2158. $i "Build the application"
  2159. $t $(MAKE) -C $(APP) $v ; ret=$$?
  2160. $i "Check .d file"
  2161. $t grep -q "src/use_blue.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2162. $t grep -q "src/use_red.erl:: include/blue.hrl include/red.hrl; @touch" $(APP)/$(APP).d
  2163. core-app-hrl-multiapps-include-loop-define-protected: init
  2164. $i "Create a multi application repository with no root application"
  2165. $t mkdir $(APP)/
  2166. $t cp ../erlang.mk $(APP)/
  2167. $t echo "include erlang.mk" > $(APP)/Makefile
  2168. $i "Create a new application named my_app"
  2169. $t $(MAKE) -C $(APP) new-lib in=my_app $v
  2170. $i "Create a new library named my_lib"
  2171. $t $(MAKE) -C $(APP) new-lib in=my_lib $v
  2172. $i "Add my_lib as LOCAL_DEPS of my_app"
  2173. $t echo "LOCAL_DEPS = my_lib" >> $(APP)/apps/my_app/Makefile
  2174. $i "Generate .hrl files"
  2175. $t mkdir $(APP)/apps/my_lib/include/
  2176. $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
  2177. $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
  2178. $i "Generate .erl files dependent from headers"
  2179. $t printf "%s\n" "-module(use_blue)." "-include_lib(\"my_lib/include/blue.hrl\")." > $(APP)/apps/my_app/src/use_blue.erl
  2180. $t printf "%s\n" "-module(use_red)." "-include_lib(\"my_lib/include/red.hrl\")." > $(APP)/apps/my_app/src/use_red.erl
  2181. $i "Build the application"
  2182. $t $(MAKE) -C $(APP) $v
  2183. $i "Check that all compiled files exist"
  2184. $t test -f $(APP)/apps/my_app/my_app.d
  2185. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  2186. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  2187. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  2188. $i "Check that the application was compiled correctly"
  2189. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  2190. {ok, _Apps } = application:ensure_all_started(my_app), \
  2191. {ok, Mods = [use_blue, use_red]} \
  2192. = application:get_key(my_app, modules), \
  2193. [{module, M} = code:load_file(M) || M <- Mods], \
  2194. halt()"
  2195. $i "Touch one .hrl file; check that only required files are rebuilt"
  2196. # The use_red.erl gets touched because of its dependency to red.hrl.
  2197. $t printf "%s\n" \
  2198. $(APP)/apps/my_app/my_app.d \
  2199. $(APP)/apps/my_app/ebin/my_app.app \
  2200. $(APP)/apps/my_app/ebin/use_red.beam \
  2201. $(APP)/apps/my_app/src/use_red.erl \
  2202. $(APP)/apps/my_app/src/use_blue.erl \
  2203. $(APP)/apps/my_app/ebin/use_blue.beam | sort > $(APP)/EXPECT
  2204. $t $(SLEEP)
  2205. $t touch $(APP)/apps/my_lib/include/red.hrl
  2206. $t $(SLEEP)
  2207. $t $(MAKE) -C $(APP) $v
  2208. $t find $(APP)/apps/my_app -type f -newer $(APP)/apps/my_lib/include/red.hrl | sort | diff $(APP)/EXPECT -
  2209. $t rm $(APP)/EXPECT
  2210. $i "Check that the application was compiled correctly"
  2211. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  2212. {ok, _Apps } = application:ensure_all_started(my_app), \
  2213. {ok, Mods = [use_blue, use_red]} \
  2214. = application:get_key(my_app, modules), \
  2215. [{module, M} = code:load_file(M) || M <- Mods], \
  2216. halt()"
  2217. $i "Clean the application"
  2218. $t $(MAKE) -C $(APP) clean $v
  2219. $i "Check that source files still exist"
  2220. $t test -f $(APP)/Makefile
  2221. $t test -f $(APP)/erlang.mk
  2222. $t test -f $(APP)/apps/my_lib/Makefile
  2223. $t test -f $(APP)/apps/my_lib/include/blue.hrl
  2224. $t test -f $(APP)/apps/my_lib/include/red.hrl
  2225. $t test -f $(APP)/apps/my_app/Makefile
  2226. $t test -f $(APP)/apps/my_app/src/use_blue.erl
  2227. $t test -f $(APP)/apps/my_app/src/use_red.erl
  2228. ifdef LEGACY
  2229. $t test -f $(APP)/apps/my_lib/src/my_lib.app.src
  2230. $t test -f $(APP)/apps/my_app/src/my_app.app.src
  2231. endif
  2232. $i "Check that all build artifacts are removed"
  2233. $t test ! -e $(APP)/apps/my_lib/my_app.d
  2234. $t test ! -e $(APP)/apps/my_lib/ebin/
  2235. $t test ! -e $(APP)/apps/my_app/my_app.d
  2236. $t test ! -e $(APP)/apps/my_app/ebin/
  2237. $i "Build the application again"
  2238. $t $(MAKE) -C $(APP) $v
  2239. $i "Check that all compiled files exist"
  2240. $t test -f $(APP)/apps/my_app/my_app.d
  2241. $t test -f $(APP)/apps/my_app/ebin/my_app.app
  2242. $t test -f $(APP)/apps/my_app/ebin/use_blue.beam
  2243. $t test -f $(APP)/apps/my_app/ebin/use_red.beam
  2244. $i "Check that the application was compiled correctly"
  2245. $t $(ERL) -pa $(APP)/apps/my_app/ebin/ $(APP)/apps/my_lib/ebin/ -eval " \
  2246. {ok, _Apps } = application:ensure_all_started(my_app), \
  2247. {ok, Mods = [use_blue, use_red]} \
  2248. = application:get_key(my_app, modules), \
  2249. [{module, M} = code:load_file(M) || M <- Mods], \
  2250. halt()"
  2251. core-app-test-build-outofdate-files-only: init
  2252. $i "Bootstrap a new OTP library named $(APP)"
  2253. $t mkdir $(APP)/
  2254. $t cp ../erlang.mk $(APP)/
  2255. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  2256. $i "Generate .erl test files"
  2257. $t mkdir $(APP)/test/
  2258. $t printf "%s\n" "-module(use_blue)." > $(APP)/test/use_blue.erl
  2259. $t printf "%s\n" "-module(use_red)." > $(APP)/test/use_red.erl
  2260. $i "Build the application testsuite"
  2261. $t $(MAKE) -C $(APP) test-build $v
  2262. $i "Check that all compiled files exist"
  2263. $t test -f $(APP)/test/use_blue.beam
  2264. $t test -f $(APP)/test/use_red.beam
  2265. $t $(SLEEP)
  2266. $t touch $(APP)/build-1
  2267. $i "Re-un the make command; check that nothing is rebuilt"
  2268. $t $(MAKE) -C $(APP) test-build $v
  2269. $t test $(APP)/test/use_blue.beam -ot $(APP)/build-1
  2270. $t test $(APP)/test/use_red.beam -ot $(APP)/build-1
  2271. $i "Touch one .erl file; check that only required files are rebuilt"
  2272. $t $(SLEEP)
  2273. $t touch $(APP)/test/use_blue.erl
  2274. $t $(MAKE) -C $(APP) test-build $v
  2275. $t test $(APP)/test/use_blue.beam -nt $(APP)/build-1
  2276. $t test $(APP)/test/use_red.beam -ot $(APP)/build-1
  2277. $t touch $(APP)/build-2
  2278. $i "Touch one Makefile; check that all files are rebuilt"
  2279. $t $(SLEEP)
  2280. $t touch $(APP)/Makefile
  2281. $t $(MAKE) -C $(APP) test-build $v
  2282. $t test $(APP)/test/use_blue.beam -nt $(APP)/build-2
  2283. $t test $(APP)/test/use_red.beam -nt $(APP)/build-2
  2284. $i "Add a syntax error to the test; check that the build fails"
  2285. $t $(SLEEP)
  2286. $t echo "garbage" >> $(APP)/test/use_blue.erl
  2287. $t ! $(MAKE) -C $(APP) test-build $v
  2288. $t ! test -f $(APP)/test/use_blue.beam