[Python-checkins] r63449 - in python/trunk: Makefile.pre.in README

georg.brandl python-checkins at python.org
Sun May 18 13:46:52 CEST 2008


Author: georg.brandl
Date: Sun May 18 13:46:51 2008
New Revision: 63449

Log:
GHOP #217: add support for compiling Python with coverage checking enabled.


Modified:
   python/trunk/Makefile.pre.in
   python/trunk/README

Modified: python/trunk/Makefile.pre.in
==============================================================================
--- python/trunk/Makefile.pre.in	(original)
+++ python/trunk/Makefile.pre.in	Sun May 18 13:46:51 2008
@@ -375,6 +375,12 @@
 build_all_use_profile:
 	$(MAKE) all CFLAGS="$(CFLAGS) -fprofile-use"
 
+coverage:
+	@echo "Building with support for coverage checking:"
+	$(MAKE) clean
+	$(MAKE) all CFLAGS="$(CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov"
+
+
 # Build the interpreter
 $(BUILDPYTHON):	Modules/python.o $(LIBRARY) $(LDLIBRARY)
 		$(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ \

Modified: python/trunk/README
==============================================================================
--- python/trunk/README	(original)
+++ python/trunk/README	Sun May 18 13:46:51 2008
@@ -917,6 +917,26 @@
 link most extension modules statically.
 
 
+Coverage checking
+-----------------
+
+For C coverage checking using gcov, run "make coverage".  This will
+build a Python binary with profiling activated, and a ".gcno" and
+".gcda" file for every source file compiled with that option.  With
+the built binary, now run the code whose coverage you want to check.
+Then, you can see coverage statistics for each individual source file
+by running gcov, e.g.
+
+    gcov -o Modules zlibmodule
+
+This will create a "zlibmodule.c.gcov" file in the current directory
+containing coverage info for that source file.
+
+This works only for source files statically compiled into the
+executable; use the Makefile/Setup mechanism to compile and link
+extension modules you want to coverage-check statically.
+
+
 Testing
 -------
 


More information about the Python-checkins mailing list