core_app.mk 90 KB

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