Browse Source

Use erlang.mk for tests and coverage report

Viktor Söderqvist 10 years ago
parent
commit
88fa61a600
4 changed files with 20 additions and 26 deletions
  1. 4 0
      .gitignore
  2. 1 1
      .travis.yml
  3. 15 22
      Makefile
  4. 0 3
      rebar.config

+ 4 - 0
.gitignore

@@ -12,3 +12,7 @@ ebin
 rel/example_project
 .concrete/DEV_MODE
 .rebar
+cover
+*.coverdata
+tests.output
+test/ct.cover.spec

+ 1 - 1
.travis.yml

@@ -3,7 +3,7 @@ services:
   - mysql
 before_script:
   - mysql -uroot -e "grant all privileges on otptest.* to otptest@localhost identified by 'otptest'"
-script: 'rebar eunit'
+script: 'make tests'
 otp_release:
   - 17.3
   - 17.0

+ 15 - 22
Makefile

@@ -1,14 +1,11 @@
 # MySQL/OTP
 #
 # This Makefile should be complete enough for this project to be used as an
-## erlang.mk dependency.
-#
-# We use rebar for eunit with coverage since erlang.mk doesn't have this yet.
-# 'make tests' is not usable. Try 'rebar eunit' or 'make eunit-coverage'.
+# erlang.mk dependency.
 #
 # Additional targets:
 #
-#  - eunit-coverage: Creates doc/eunit.html with the coverage and eunit output.
+#  - tests-report:   Creates doc/eunit.html with the coverage and eunit output.
 #  - gh-pages:       Generates docs and eunit reports and commits these in the
 #                    gh-pages which Github publishes automatically when pushed.
 
@@ -19,19 +16,14 @@ SHELL_PATH = -pa ebin
 
 include erlang.mk
 
-.PHONY: gh-pages eunit eunit-report CHANGELOG.md
+.PHONY: gh-pages tests-report CHANGELOG.md
 
 CHANGELOG.md:
 	./changelog.sh > $@
 
-eunit:
-	@mkdir -p .eunit
-	@rm -f .eunit/index.html # make sure we don't get an old one if cover=false
-	@rebar eunit | tee .eunit/output
-
 # Update the local 'gh-pages' branch with pregenerated output files
 # (trick from https://groups.google.com/forum/#!topic/github/XYxkdzxpgCo)
-gh-pages: docs eunit-report
+gh-pages: docs tests-report
 	@if [ $$(git name-rev --name-only HEAD) != master ] ; then \
 	  echo "Not on master. Aborting." ; \
 	  false ; \
@@ -47,16 +39,17 @@ gh-pages: docs eunit-report
 	@rm gitindex.tmp
 	@echo "Committed $$(git describe --tags) in the gh-pages branch."
 
-# Build eunit.html containing the coverage report and the eunit output in the
+# Build eunit.html containing the coverage report and the test output in the
 # doc directory.
-eunit-report: eunit
-	@(echo '<!DOCTYPE html>' ; \
-	 cat .eunit/index.html | sed 's!</body></html>!!' ; \
-	 echo '<h3>Output of <code>make eunit</code></h3><pre>' ; \
-	 sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g;' .eunit/output ; \
+tests-report: test_command=$(MAKE) --no-print-directory tests COVER=1 \
+              COVER_REPORT_DIR= EUNIT_OPTS={verbose,true}
+tests-report:
+	@rm -f cover/*.html
+	@$(test_command) | tee tests.output
+	@$(MAKE) --no-print-directory cover-report
+	@(cat cover/index.html | sed 's!</body></html>!!' ; \
+	 echo '<h3>Output of <code>$(test_command)</code></h3><pre>' ; \
+	 sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g;' tests.output ; \
 	 echo '</pre>' ; \
-	 echo '<p><em>Generated using rebar and EUnit,' ; \
-	 date -u '+%d %h %Y %H:%M:%S UTC.' ; \
-	 echo '</em></p>' ; \
 	 echo '</body></html>') > doc/eunit.html
-	@cp .eunit/*.COVER.html doc/
+	@cp cover/*.COVER.html doc/

+ 0 - 3
rebar.config

@@ -1,3 +0,0 @@
-{cover_enabled, true}.
-{eunit_opts, [verbose]}.
-{edoc_opts, [{stylesheet_file, "priv/edoc-style.css"}, {todo, true}]}.