[ovs-dev] [unixctl_py 3/6] tests: Add code coverage for Python.

Ethan Jackson ethan at nicira.com
Fri Mar 2 01:33:07 UTC 2012


I had to leave one abs_srcdir, otherwise coverage.py got confused.
Here's an incremental.

---
 Makefile.am       |    2 +-
 tests/atlocal.in  |    4 ----
 tests/automake.mk |    6 +++---
 3 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index d287c9e..4eab72a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -118,7 +118,7 @@ SUFFIXES += .in
 
 .PHONY: clean-pycov
 clean-pycov:
-	cd $(abs_top_srcdir) && rm -f $(PYCOV_CLEAN_FILES)
+	cd $(srcdir) && rm -f $(PYCOV_CLEAN_FILES)
 CLEAN_LOCAL += clean-pycov
 
 # If we're checked out from a Git repository, make sure that every
diff --git a/tests/atlocal.in b/tests/atlocal.in
index 48817eb..1d37b59 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -7,10 +7,6 @@ if test x"$PYTHON" = x; then
     PYTHON='@PYTHON@'
 fi
 
-if test x"$COVERAGE_FILE" = x; then
-    export COVERAGE_FILE
-fi
-
 PYTHONPATH=$abs_top_srcdir/python:$abs_top_builddir/tests:$PYTHONPATH
 export PYTHONPATH
 
diff --git a/tests/automake.mk b/tests/automake.mk
index 387d9cd..a2ed7d7 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -70,16 +70,16 @@ check-local: tests/atconfig tests/atlocal $(TESTSUITE)
 # Requires coverage.py http://nedbatchelder.com/code/coverage/.
 
 COVERAGE = coverage
-COVERAGE_FILE=$(abs_top_srcdir)/.coverage
+COVERAGE_FILE='$(abs_srcdir)/.coverage'
 check-pycov: all tests/atconfig tests/atlocal $(TESTSUITE) clean-pycov
 	COVERAGE_FILE=$(COVERAGE_FILE) PYTHON='$(COVERAGE) run -p' $(SHELL) '$(TESTSUITE)' -C tests AUTOTEST_PATH=$(AUTOTEST_PATH) $(TESTSUITEFLAGS)
-	@cd $(abs_top_srcdir) && coverage combine && COVERAGE_FILE=$(COVERAGE_FILE) coverage annotate
+	@cd $(srcdir) && $(COVERAGE) combine && COVERAGE_FILE=$(COVERAGE_FILE) $(COVERAGE) annotate
 	@echo
 	@echo '----------------------------------------------------------------------'
 	@echo 'Annotated coverage source has the ",cover" extension.'
 	@echo '----------------------------------------------------------------------'
 	@echo
-	@COVERAGE_FILE=$(COVERAGE_FILE) coverage report
+	@COVERAGE_FILE=$(COVERAGE_FILE) $(COVERAGE) report
 
 # lcov support
 
-- 
1.7.9.2




More information about the dev mailing list