plugin_cover.mk 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. # Common Test plugin.
  2. COVER_TARGETS = $(call list_targets,cover)
  3. .PHONY: cover $(COVER_TARGETS)
  4. cover: $(COVER_TARGETS)
  5. cover-ct: init
  6. $i "Bootstrap a new OTP application named $(APP)"
  7. $t mkdir $(APP)/
  8. $t cp ../erlang.mk $(APP)/
  9. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  10. $i "Generate a Common Test suite"
  11. $t mkdir $(APP)/test
  12. $t printf "%s\n" \
  13. "-module($(APP)_SUITE)." \
  14. "-export([all/0, ok/1])." \
  15. "all() -> [ok]." \
  16. "ok(_) -> application:start($(APP))." > $(APP)/test/$(APP)_SUITE.erl
  17. $i "Run Common Test with code coverage enabled"
  18. $t $(MAKE) -C $(APP) ct COVER=1 $v
  19. $i "Check that the generated files exist"
  20. $t test -f $(APP)/cover/ct.coverdata
  21. $t test -f $(APP)/test/ct.cover.spec
  22. $i "Check that the generated files are removed on clean"
  23. $t $(MAKE) -C $(APP) clean $v
  24. $t test ! -e $(APP)/cover/ct.coverdata
  25. $t test ! -e $(APP)/test/ct.cover.spec
  26. cover-ct-excl-mods: init
  27. $i "Bootstrap a new OTP application named $(APP)"
  28. $t mkdir $(APP)/
  29. $t cp ../erlang.mk $(APP)/
  30. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  31. $i "Add supervisor module to the cover exclude module list "
  32. $t perl -ni.bak -e 'print;if ($$.==1) {print "COVER_EXCLUDE_MODS = $(APP)_sup \n"}' $(APP)/Makefile
  33. $i "Generate a Common Test suite"
  34. $t mkdir $(APP)/test
  35. $t printf "%s\n" \
  36. "-module($(APP)_SUITE)." \
  37. "-export([all/0, ok/1])." \
  38. "all() -> [ok]." \
  39. "ok(_) -> application:start($(APP))." > $(APP)/test/$(APP)_SUITE.erl
  40. $i "Run Common Test with code coverage enabled"
  41. $t $(MAKE) -C $(APP) ct COVER=1 $v
  42. $i "Check that the generated files exist"
  43. $t test -f $(APP)/cover/ct.coverdata
  44. $t test -f $(APP)/test/ct.cover.spec
  45. $i "Check that the supervisor module is not included in the cover report"
  46. $t ! test -e $(APP)/logs/ct_run.*/$(APP)_sup.COVER.html
  47. cover-ct-incl-apps: init
  48. $i "Bootstrap a new OTP application named $(APP)"
  49. $t mkdir $(APP)/
  50. $t cp ../erlang.mk $(APP)/
  51. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  52. $i "Create a new application app_one"
  53. $t $(MAKE) -C $(APP) new-app in=app_one $v
  54. $i "Create a new application app_two"
  55. $t $(MAKE) -C $(APP) new-app in=app_two $v
  56. $i "Create a new application app_three"
  57. $t $(MAKE) -C $(APP) new-app in=app_three $v
  58. $i "Add all three apps to LOCAL_DEPS"
  59. $t perl -ni.bak -e 'print;if ($$.==1) {print "LOCAL_DEPS = app_one app_two app_three\n"}' $(APP)/Makefile
  60. ifdef LEGACY
  61. $i "Add all three apps to the applications key in the .app.src file"
  62. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tapp_one,\n\t\tapp_two,\n\t\tapp_three,\n"}' $(APP)/src/$(APP).app.src
  63. endif
  64. $i "Add app_one and app_three to the code coverage"
  65. $t perl -ni.bak -e 'print;if ($$.==1) {print "COVER_APPS = app_one app_three\n"}' $(APP)/Makefile
  66. $i "Generate a Common Test suite"
  67. $t mkdir $(APP)/test
  68. $t printf "%s\n" \
  69. "-module($(APP)_SUITE)." \
  70. "-export([all/0, ok/1])." \
  71. "all() -> [ok]." \
  72. "ok(_) -> application:ensure_all_started($(APP))." > $(APP)/test/$(APP)_SUITE.erl
  73. $i "Run Common Test with code coverage enabled"
  74. $t $(MAKE) -C $(APP) ct COVER=1 $v
  75. $i "Check that app_one and app_three were covered, but app_two wasn't"
  76. $t test -f $(APP)/logs/ct_run.*/app_one_app.COVER.html
  77. $t test -f $(APP)/logs/ct_run.*/app_three_app.COVER.html
  78. $t ! test -e $(APP)/logs/ct_run.*/app_two_app.COVER.html
  79. cover-ct-incl-apps-default: init
  80. $i "Bootstrap a new OTP application named $(APP)"
  81. $t mkdir $(APP)/
  82. $t cp ../erlang.mk $(APP)/
  83. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  84. $i "Create a new application app_one"
  85. $t $(MAKE) -C $(APP) new-app in=app_one $v
  86. $i "Create a new application app_two"
  87. $t $(MAKE) -C $(APP) new-app in=app_two $v
  88. $i "Create a new application app_three"
  89. $t $(MAKE) -C $(APP) new-app in=app_three $v
  90. $i "Add all three apps to LOCAL_DEPS"
  91. $t perl -ni.bak -e 'print;if ($$.==1) {print "LOCAL_DEPS = app_one app_two app_three\n"}' $(APP)/Makefile
  92. ifdef LEGACY
  93. $i "Add all three apps to the applications key in the .app.src file"
  94. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tapp_one,\n\t\tapp_two,\n\t\tapp_three,\n"}' $(APP)/src/$(APP).app.src
  95. endif
  96. $i "Generate a Common Test suite"
  97. $t mkdir $(APP)/test
  98. $t printf "%s\n" \
  99. "-module($(APP)_SUITE)." \
  100. "-export([all/0, ok/1])." \
  101. "all() -> [ok]." \
  102. "ok(_) -> application:ensure_all_started($(APP))." > $(APP)/test/$(APP)_SUITE.erl
  103. $i "Run Common Test with code coverage enabled"
  104. $t $(MAKE) -C $(APP) ct COVER=1 $v
  105. $i "Check that all apps were covered by default"
  106. $t test -f $(APP)/logs/ct_run.*/app_one_app.COVER.html
  107. $t test -f $(APP)/logs/ct_run.*/app_two_app.COVER.html
  108. $t test -f $(APP)/logs/ct_run.*/app_three_app.COVER.html
  109. cover-ct-incl-deps: init
  110. $i "Bootstrap a new OTP application named $(APP)"
  111. $t mkdir $(APP)/
  112. $t cp ../erlang.mk $(APP)/
  113. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  114. $i "Add Cowboy 1.0.0 to the list of dependencies"
  115. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\ndep_cowboy_commit = 1.0.0\n"}' $(APP)/Makefile
  116. ifdef LEGACY
  117. $i "Add Cowboy to the applications key in the .app.src file"
  118. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowboy,\n"}' $(APP)/src/$(APP).app.src
  119. endif
  120. $i "Add Cowboy and Cowlib to the code coverage"
  121. $t perl -ni.bak -e 'print;if ($$.==1) {print "COVER_DEPS = cowboy cowlib\n"}' $(APP)/Makefile
  122. $i "Generate a Common Test suite"
  123. $t mkdir $(APP)/test
  124. $t printf "%s\n" \
  125. "-module($(APP)_SUITE)." \
  126. "-export([all/0, ok/1])." \
  127. "all() -> [ok]." \
  128. "ok(_) -> application:ensure_all_started($(APP))." > $(APP)/test/$(APP)_SUITE.erl
  129. $i "Run Common Test with code coverage enabled"
  130. $t $(MAKE) -C $(APP) ct COVER=1 $v
  131. $i "Check that Cowboy and Cowlib were covered, but Ranch wasn't"
  132. $t test -f $(APP)/logs/ct_run.*/cowboy_app.COVER.html
  133. $t test -f $(APP)/logs/ct_run.*/cow_http_hd.COVER.html
  134. $t ! test -e $(APP)/logs/ct_run.*/ranch_app.COVER.html
  135. cover-ct-single-suite: init
  136. $i "Bootstrap a new OTP application named $(APP)"
  137. $t mkdir $(APP)/
  138. $t cp ../erlang.mk $(APP)/
  139. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  140. $i "Generate a Common Test suite"
  141. $t mkdir $(APP)/test
  142. $t printf "%s\n" \
  143. "-module($(APP)_SUITE)." \
  144. "-export([all/0, ok/1])." \
  145. "all() -> [ok]." \
  146. "ok(_) -> application:start($(APP))." > $(APP)/test/$(APP)_SUITE.erl
  147. $i "Run Common Test against this specific test suite with code coverage enabled"
  148. $t $(MAKE) -C $(APP) ct-$(APP) COVER=1 $v
  149. $i "Check that the generated files exist"
  150. $t test -f $(APP)/cover/ct.coverdata
  151. $t test -f $(APP)/test/ct.cover.spec
  152. $i "Check that the generated files are removed on clean"
  153. $t $(MAKE) -C $(APP) clean $v
  154. $t test ! -e $(APP)/cover/ct.coverdata
  155. $t test ! -e $(APP)/test/ct.cover.spec
  156. cover-custom-dir: init
  157. $i "Bootstrap a new OTP application 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 COVER_DATA_DIR in the Makefile"
  162. $t perl -ni.bak -e 'print;if ($$.==1) {print "COVER_DATA_DIR = custom_dir\n"}' $(APP)/Makefile
  163. $i "Generate a module containing EUnit tests"
  164. $t printf "%s\n" \
  165. "-module($(APP))." \
  166. "-ifdef(TEST)." \
  167. "-include_lib(\"eunit/include/eunit.hrl\")." \
  168. "ok_test() -> ok." \
  169. "-endif." > $(APP)/src/$(APP).erl
  170. $i "Generate a Common Test suite"
  171. $t mkdir $(APP)/test
  172. $t printf "%s\n" \
  173. "-module($(APP)_SUITE)." \
  174. "-export([all/0, ok/1])." \
  175. "all() -> [ok]." \
  176. "ok(_) -> ok." > $(APP)/test/$(APP)_SUITE.erl
  177. $i "Run Common Test with code coverage enabled"
  178. $t $(MAKE) -C $(APP) ct COVER=1 $v
  179. $i "Run EUnit with code coverage enabled"
  180. $t $(MAKE) -C $(APP) eunit COVER=1 $v
  181. $i "Check that the generated file exists"
  182. $t test -f $(APP)/custom_dir/ct.coverdata
  183. $t test -f $(APP)/custom_dir/eunit.coverdata
  184. $i "Merge coverdata files into all.coverdata"
  185. $t $(MAKE) -C $(APP) all.coverdata $v
  186. $t test -f $(APP)/custom_dir/all.coverdata
  187. $i "Check that the generated file is removed on clean"
  188. $t $(MAKE) -C $(APP) clean $v
  189. $t test ! -e $(APP)/custom_dir/eunit.coverdata
  190. $t test ! -e $(APP)/custom_dir/ct.coverdata
  191. $t test ! -e $(APP)/custom_dir/all.coverdata
  192. $i "Check that the custom dir is removed on distclean"
  193. $t $(MAKE) -C $(APP) distclean $v
  194. $t test ! -e $(APP)/custom_dir/
  195. $i "Check that the custom dir is not removed if not empty"
  196. $t mkdir $(APP)/custom_dir
  197. $t touch $(APP)/custom_dir/file
  198. $t $(MAKE) -C $(APP) distclean $v
  199. $t test -f $(APP)/custom_dir/file
  200. cover-eunit: init
  201. $i "Bootstrap a new OTP application named $(APP)"
  202. $t mkdir $(APP)/
  203. $t cp ../erlang.mk $(APP)/
  204. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  205. $i "Generate a module containing EUnit tests"
  206. $t printf "%s\n" \
  207. "-module($(APP))." \
  208. "-ifdef(TEST)." \
  209. "-include_lib(\"eunit/include/eunit.hrl\")." \
  210. "ok_test() -> ok." \
  211. "-endif." > $(APP)/src/$(APP).erl
  212. $i "Run EUnit with code coverage enabled"
  213. $t $(MAKE) -C $(APP) eunit COVER=1 $v
  214. $i "Check that the generated file exists"
  215. $t test -f $(APP)/cover/eunit.coverdata
  216. $i "Check that the generated file is removed on clean"
  217. $t $(MAKE) -C $(APP) clean $v
  218. $t test ! -e $(APP)/cover/eunit.coverdata
  219. cover-eunit-apps-only: init
  220. $i "Create a multi application repository with no root application"
  221. $t mkdir $(APP)/
  222. $t cp ../erlang.mk $(APP)/
  223. $t echo "include erlang.mk" > $(APP)/Makefile
  224. $i "Create a new application named my_app"
  225. $t $(MAKE) -C $(APP) new-app in=my_app $v
  226. $i "Generate a module containing EUnit tests in my_app"
  227. $t printf "%s\n" \
  228. "-module(my_app)." \
  229. "-ifdef(TEST)." \
  230. "-include_lib(\"eunit/include/eunit.hrl\")." \
  231. "ok_test() -> ok." \
  232. "-endif." > $(APP)/apps/my_app/src/my_app.erl
  233. $i "Run EUnit with code coverage enabled"
  234. $t $(MAKE) -C $(APP) eunit COVER=1 $v
  235. $i "Check that no file was generated in the top-level directory"
  236. $t ! test -f $(APP)/cover/eunit.coverdata
  237. $i "Check that the generated file exists"
  238. $t test -f $(APP)/apps/my_app/cover/eunit.coverdata
  239. cover-eunit-excl-mods: init
  240. $i "Bootstrap a new OTP application named $(APP)"
  241. $t mkdir $(APP)/
  242. $t cp ../erlang.mk $(APP)/
  243. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  244. $i "Add supervisor module to the cover exclude module list "
  245. $t perl -ni.bak -e 'print;if ($$.==1) {print "COVER_EXCLUDE_MODS = $(APP)_sup \n"}' $(APP)/Makefile
  246. $i "Generate a module containing EUnit tests"
  247. $t printf "%s\n" \
  248. "-module($(APP))." \
  249. "-ifdef(TEST)." \
  250. "-include_lib(\"eunit/include/eunit.hrl\")." \
  251. "ok_test() -> application:ensure_all_started($(APP))." \
  252. "-endif." > $(APP)/src/$(APP).erl
  253. $i "Run EUnit with code coverage enabled"
  254. $t $(MAKE) -C $(APP) eunit COVER=1 $v
  255. $i "Build the cover report"
  256. $t $(MAKE) -C $(APP) cover-report $v
  257. $i "Check that app was covered, but supervisor wasn't"
  258. $t test -f $(APP)/cover/$(APP)_app.COVER.html
  259. $t ! test -e $(APP)/cover/$(APP)_sup.COVER.html
  260. cover-eunit-incl-apps: init
  261. $i "Bootstrap a new OTP application named $(APP)"
  262. $t mkdir $(APP)/
  263. $t cp ../erlang.mk $(APP)/
  264. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  265. $i "Create a new application app_one"
  266. $t $(MAKE) -C $(APP) new-app in=app_one $v
  267. $i "Create a new application app_two"
  268. $t $(MAKE) -C $(APP) new-app in=app_two $v
  269. $i "Create a new application app_three"
  270. $t $(MAKE) -C $(APP) new-app in=app_three $v
  271. $i "Add all three apps to LOCAL_DEPS"
  272. $t perl -ni.bak -e 'print;if ($$.==1) {print "LOCAL_DEPS = app_one app_two app_three\n"}' $(APP)/Makefile
  273. ifdef LEGACY
  274. $i "Add all three apps to the applications key in the .app.src file"
  275. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tapp_one,\n\t\tapp_two,\n\t\tapp_three,\n"}' $(APP)/src/$(APP).app.src
  276. endif
  277. $i "Add app_one and app_three to the code coverage"
  278. $t perl -ni.bak -e 'print;if ($$.==1) {print "COVER_APPS = app_one app_three\n"}' $(APP)/Makefile
  279. $i "Generate a module containing EUnit tests"
  280. $t printf "%s\n" \
  281. "-module($(APP))." \
  282. "-ifdef(TEST)." \
  283. "-include_lib(\"eunit/include/eunit.hrl\")." \
  284. "ok_test() -> application:ensure_all_started($(APP))." \
  285. "-endif." > $(APP)/src/$(APP).erl
  286. $i "Run EUnit with code coverage enabled"
  287. $t $(MAKE) -C $(APP) eunit COVER=1 $v
  288. $i "Build the cover report"
  289. $t $(MAKE) -C $(APP) cover-report $v
  290. $i "Check that app_one and app_three were covered, but app_two wasn't"
  291. $t test -f $(APP)/cover/app_one_app.COVER.html
  292. $t test -f $(APP)/cover/app_three_app.COVER.html
  293. $t ! test -e $(APP)/cover/app_two_app.COVER.html
  294. cover-eunit-incl-apps-default: init
  295. $i "Bootstrap a new OTP application named $(APP)"
  296. $t mkdir $(APP)/
  297. $t cp ../erlang.mk $(APP)/
  298. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  299. $i "Create a new application app_one"
  300. $t $(MAKE) -C $(APP) new-app in=app_one $v
  301. $i "Create a new application app_two"
  302. $t $(MAKE) -C $(APP) new-app in=app_two $v
  303. $i "Create a new application app_three"
  304. $t $(MAKE) -C $(APP) new-app in=app_three $v
  305. $i "Add all three apps to LOCAL_DEPS"
  306. $t perl -ni.bak -e 'print;if ($$.==1) {print "LOCAL_DEPS = app_one app_two app_three\n"}' $(APP)/Makefile
  307. ifdef LEGACY
  308. $i "Add all three apps to the applications key in the .app.src file"
  309. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tapp_one,\n\t\tapp_two,\n\t\tapp_three,\n"}' $(APP)/src/$(APP).app.src
  310. endif
  311. $i "Generate a module containing EUnit tests"
  312. $t printf "%s\n" \
  313. "-module($(APP))." \
  314. "-ifdef(TEST)." \
  315. "-include_lib(\"eunit/include/eunit.hrl\")." \
  316. "ok_test() -> application:ensure_all_started($(APP))." \
  317. "-endif." > $(APP)/src/$(APP).erl
  318. $i "Run EUnit with code coverage enabled"
  319. $t $(MAKE) -C $(APP) eunit COVER=1 $v
  320. $i "Build the cover report"
  321. $t $(MAKE) -C $(APP) cover-report $v
  322. $i "Check that all apps were covered by default"
  323. $t test -f $(APP)/cover/app_one_app.COVER.html
  324. $t test -f $(APP)/cover/app_two_app.COVER.html
  325. $t test -f $(APP)/cover/app_three_app.COVER.html
  326. cover-eunit-incl-deps: init
  327. $i "Bootstrap a new OTP application named $(APP)"
  328. $t mkdir $(APP)/
  329. $t cp ../erlang.mk $(APP)/
  330. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
  331. $i "Add Cowboy 1.0.0 to the list of dependencies"
  332. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\ndep_cowboy_commit = 1.0.0\n"}' $(APP)/Makefile
  333. ifdef LEGACY
  334. $i "Add Cowboy to the applications key in the .app.src file"
  335. $t perl -ni.bak -e 'print;if ($$.==7) {print "\t\tcowboy,\n"}' $(APP)/src/$(APP).app.src
  336. endif
  337. $i "Add Cowboy and Cowlib to the code coverage"
  338. $t perl -ni.bak -e 'print;if ($$.==1) {print "COVER_DEPS = cowboy cowlib\n"}' $(APP)/Makefile
  339. $i "Generate a module containing EUnit tests"
  340. $t printf "%s\n" \
  341. "-module($(APP))." \
  342. "-ifdef(TEST)." \
  343. "-include_lib(\"eunit/include/eunit.hrl\")." \
  344. "ok_test() -> application:ensure_all_started($(APP))." \
  345. "-endif." > $(APP)/src/$(APP).erl
  346. $i "Run EUnit with code coverage enabled"
  347. $t $(MAKE) -C $(APP) eunit COVER=1 $v
  348. $i "Build the cover report"
  349. $t $(MAKE) -C $(APP) cover-report $v
  350. $i "Check that Cowboy and Cowlib were covered, but Ranch wasn't"
  351. $t test -f $(APP)/cover/cowboy_app.COVER.html
  352. $t test -f $(APP)/cover/cow_http_hd.COVER.html
  353. $t ! test -e $(APP)/cover/ranch_app.COVER.html
  354. cover-proper: init
  355. $i "Bootstrap a new OTP application named $(APP)"
  356. $t mkdir $(APP)/
  357. $t cp ../erlang.mk $(APP)/
  358. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  359. $i "Add PropEr to the list of dependencies"
  360. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = proper\n"}' $(APP)/Makefile
  361. $i "Generate a module containing Proper properties"
  362. $t printf "%s\n" \
  363. "-module($(APP))." \
  364. "-ifdef(TEST)." \
  365. "-include_lib(\"proper/include/proper.hrl\")." \
  366. "prop_foo() -> ?FORALL(_, any(), true)." \
  367. "-endif." > $(APP)/src/$(APP).erl
  368. $i "Run PropEr with code coverage enabled"
  369. $t $(MAKE) -C $(APP) proper COVER=1 $v
  370. $i "Check that the generated file exists"
  371. $t test -f $(APP)/cover/proper.coverdata
  372. $i "Check that the generated file is removed on clean"
  373. $t $(MAKE) -C $(APP) clean $v
  374. $t test ! -e $(APP)/cover/proper.coverdata
  375. cover-report-and-merge: init
  376. $i "Bootstrap a new OTP application named $(APP)"
  377. $t mkdir $(APP)/
  378. $t cp ../erlang.mk $(APP)/
  379. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  380. $i "Generate a Common Test suite"
  381. $t mkdir $(APP)/test
  382. $t printf "%s\n" \
  383. "-module($(APP)_SUITE)." \
  384. "-export([all/0, ok/1])." \
  385. "all() -> [ok]." \
  386. "ok(_) -> ok." > $(APP)/test/$(APP)_SUITE.erl
  387. $i "Generate a module containing EUnit tests"
  388. $t printf "%s\n" \
  389. "-module($(APP))." \
  390. "-ifdef(TEST)." \
  391. "-include_lib(\"eunit/include/eunit.hrl\")." \
  392. "ok_test() -> ok." \
  393. "-endif." > $(APP)/src/$(APP).erl
  394. $i "Run tests with code coverage enabled"
  395. $t $(MAKE) -C $(APP) tests COVER=1 $v
  396. $i "Check that the generated files exist"
  397. $t test -f $(APP)/cover/$(APP).COVER.html
  398. $t test -f $(APP)/cover/index.html
  399. $t test -f $(APP)/cover/ct.coverdata
  400. $t test -f $(APP)/cover/eunit.coverdata
  401. $t test -f $(APP)/test/ct.cover.spec
  402. $i "Merge coverdata files into all.coverdata"
  403. $t $(MAKE) -C $(APP) all.coverdata $v
  404. $t test -f $(APP)/cover/all.coverdata
  405. $i "Check that the generated files are removed on clean"
  406. $t $(MAKE) -C $(APP) clean $v
  407. $t test ! -e $(APP)/cover/all.coverdata
  408. $t test ! -e $(APP)/cover/ct.coverdata
  409. $t test ! -e $(APP)/cover/eunit.coverdata
  410. $t test ! -e $(APP)/test/ct.cover.spec
  411. $i "Check that the cover report is removed on distclean"
  412. $t $(MAKE) -C $(APP) distclean $v
  413. $t test ! -e $(APP)/cover/
  414. cover-triq: init
  415. $i "Bootstrap a new OTP application named $(APP)"
  416. $t mkdir $(APP)/
  417. $t cp ../erlang.mk $(APP)/
  418. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  419. $i "Add Triq to the list of dependencies"
  420. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = triq\n"}' $(APP)/Makefile
  421. $i "Generate a module containing Triq properties"
  422. $t printf "%s\n" \
  423. "-module($(APP))." \
  424. "-ifdef(TEST)." \
  425. "-include_lib(\"triq/include/triq.hrl\")." \
  426. "prop_foo() -> ?FORALL(_, any(), true)." \
  427. "-endif." > $(APP)/src/$(APP).erl
  428. $i "Run Triq with code coverage enabled"
  429. $t $(MAKE) -C $(APP) triq COVER=1 $v
  430. $i "Check that the generated file exists"
  431. $t test -f $(APP)/cover/triq.coverdata
  432. $i "Check that the generated file is removed on clean"
  433. $t $(MAKE) -C $(APP) clean $v
  434. $t test ! -e $(APP)/cover/triq.coverdata