core_app.mk 88 KB

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