diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -91,3 +91,7 @@ .coverage coverage/ htmlcov/ +*.gcda +*.gcno +*.gcov +coverage.info diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -463,11 +463,43 @@ build_all_use_profile: $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-use -fprofile-correction" +# Compile and run with gcov +.PHONY=coverage coverage-test coverage-lcov coverage-report coverage: @echo "Building with support for coverage checking:" $(MAKE) clean $(MAKE) all CFLAGS="$(CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov" +coverage-test: + $(MAKE) profile-removal + $(MAKE) coverage + @echo "Running tests with coverage" + # ignore test failures + $(TESTRUNNER) $(TESTOPTS) || true + +COVERAGE_INFO=$(abs_builddir)/coverage.info +COVERAGE_REPORT=$(abs_builddir)/lcov-report + +coverage-lcov: + @rm -rf $(COVERAGE_INFO) $(COVERAGE_REPORT) + lcov --capture --directory $(abs_builddir) \ + --base-directory $(realpath $(abs_builddir)) \ + --path $(realpath $(abs_srcdir)) \ + --output-file $(COVERAGE_INFO) + lcov --remove $(COVERAGE_INFO) '*/Modules/_ctypes/libffi/*' \ + --output-file $(COVERAGE_INFO) + lcov --remove $(COVERAGE_INFO) '*/Modules/_sha3/keccak/*' \ + --output-file $(COVERAGE_INFO) + lcov --remove $(COVERAGE_INFO) '*/Modules/_decimal/libmpdec/*' \ + --output-file $(COVERAGE_INFO) + lcov --remove $(COVERAGE_INFO) '/usr/include/*' \ + --output-file $(COVERAGE_INFO) + genhtml $(COVERAGE_INFO) --output-directory $(COVERAGE_REPORT) \ + --title "CPython lcov report" + +coverage-report: + $(MAKE) coverage-test + $(MAKE) coverage-lcov # Build the interpreter $(BUILDPYTHON): Modules/python.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY)