Comments
Patch
@@ -1946,10 +1946,16 @@ class TestRunner(object):
shutil.copyfile(custom, target)
rc = os.path.join(self._testdir, '.coveragerc')
vlog('# Installing coverage rc to %s' % rc)
os.environ['COVERAGE_PROCESS_START'] = rc
- fn = os.path.join(self._installdir, '..', '.coverage')
- os.environ['COVERAGE_FILE'] = fn
+ covdir = os.path.join(self._installdir, '..', 'coverage')
+ try:
+ os.mkdir(covdir)
+ except OSError, e:
+ if e.errno != errno.EEXIST:
+ raise
+
+ os.environ['COVERAGE_DIR'] = covdir
def _checkhglib(self, verb):
"""Ensure that the 'mercurial' package imported by python is
the one we expect it to be. If not, print a warning to stderr."""
@@ -1986,11 +1992,11 @@ class TestRunner(object):
vlog('# Producing coverage report')
# chdir is the easiest way to get short, relative paths in the
# output.
os.chdir(self._pythondir)
- covdir = os.path.join(self._installdir, '..')
- cov = coverage(data_file=os.path.join(covdir, '.coverage'))
- cov.load()
+ covdir = os.path.join(self._installdir, '..', 'coverage')
+ cov = coverage(data_file=os.path.join(covdir, 'cov'))
+ cov.combine()
omit = [os.path.join(x, '*') for x in [self._bindir, self._testdir]]
cov.report(ignore_errors=True, omit=omit)
@@ -1,5 +1,16 @@
-try:
- import coverage
- getattr(coverage, 'process_startup', lambda: None)()
-except ImportError:
- pass
+import os
+
+if os.environ.get('COVERAGE_PROCESS_START'):
+ try:
+ import coverage
+ import random
+
+ # uuid is better, but not available in Python 2.4.
+ covpath = os.path.join(os.environ['COVERAGE_DIR'],
+ 'cov.%s' % random.randrange(0, 1000000000000))
+ cov = coverage.coverage(data_file=covpath, auto_data=True)
+ cov._warn_no_data = False
+ cov._warn_unimported_source = False
+ cov.start()
+ except ImportError:
+ pass