[PATCH 061 of 179 tests-refactor] run-tests: move outputcoverage() into TestRunner
Gregory Szorc
gregory.szorc at gmail.com
Fri May 2 13:38:18 CDT 2014
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1397976563 25200
# Sat Apr 19 23:49:23 2014 -0700
# Branch stable
# Node ID c44452f2c5830bd8fee88ffa65b898f62571d490
# Parent 8a4ad4abe4cd37419363baab641614c528fa9cd0
run-tests: move outputcoverage() into TestRunner
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -379,39 +379,16 @@ def terminate(proc):
getattr(proc, 'terminate', lambda : os.kill(proc.pid, signal.SIGTERM))()
except OSError:
pass
def killdaemons(pidfile):
return killmod.killdaemons(pidfile, tryhard=False, remove=True,
logfn=vlog)
-def outputcoverage(runner):
-
- vlog('# Producing coverage report')
- os.chdir(runner.pythondir)
-
- def covrun(*args):
- cmd = 'coverage %s' % ' '.join(args)
- vlog('# Running: %s' % cmd)
- os.system(cmd)
-
- covrun('-c')
- omit = ','.join(os.path.join(x, '*') for x in
- [runner.bindir, runner.testdir])
- covrun('-i', '-r', '"--omit=%s"' % omit) # report
- if runner.options.htmlcov:
- htmldir = os.path.join(runner.testdir, 'htmlcov')
- covrun('-i', '-b', '"--directory=%s"' % htmldir, '"--omit=%s"' % omit)
- if runner.options.annotate:
- adir = os.path.join(runner.testdir, 'annotated')
- if not os.path.isdir(adir):
- os.mkdir(adir)
- covrun('-i', '-a', '"--directory=%s"' % adir, '"--omit=%s"' % omit)
-
class Test(object):
"""Encapsulates a single, runnable test.
Test instances can be run multiple times via run(). However, multiple
runs cannot be run concurrently.
"""
def __init__(self, runner, test, count, refpath):
@@ -1114,17 +1091,17 @@ def runtests(runner, tests):
print "# Ran %d tests, %d skipped, %d warned, %d failed." % (
tested, skipped + ignored, warned, failed)
if results['!']:
print 'python hash seed:', os.environ['PYTHONHASHSEED']
if runner.options.time:
runner.outputtimes()
if runner.options.anycoverage:
- outputcoverage(runner)
+ runner.outputcoverage()
except KeyboardInterrupt:
failed = True
print "\ninterrupted!"
if failed:
return 1
if warned:
return 80
@@ -1294,16 +1271,39 @@ class TestRunner(object):
def outputtimes(self):
vlog('# Producing time report')
times.sort(key=lambda t: (t[1], t[0]), reverse=True)
cols = '%7.3f %s'
print '\n%-7s %s' % ('Time', 'Test')
for test, timetaken in times:
print cols % (timetaken, test)
+ def outputcoverage(self):
+ vlog('# Producing coverage report')
+ os.chdir(self.pythondir)
+
+ def covrun(*args):
+ cmd = 'coverage %s' % ' '.join(args)
+ vlog('# Running: %s' % cmd)
+ os.system(cmd)
+
+ covrun('-c')
+ omit = ','.join(os.path.join(x, '*') for x in
+ [self.bindir, self.testdir])
+ covrun('-i', '-r', '"--omit=%s"' % omit) # report
+ if self.options.htmlcov:
+ htmldir = os.path.join(self.testdir, 'htmlcov')
+ covrun('-i', '-b', '"--directory=%s"' % htmldir,
+ '"--omit=%s"' % omit)
+ if self.options.annotate:
+ adir = os.path.join(self.testdir, 'annotated')
+ if not os.path.isdir(adir):
+ os.mkdir(adir)
+ covrun('-i', '-a', '"--directory=%s"' % adir, '"--omit=%s"' % omit)
+
def main(args, parser=None):
runner = TestRunner()
parser = parser or getparser()
(options, args) = parseargs(args, parser)
runner.options = options
os.umask(022)
More information about the Mercurial-devel
mailing list