Mercurial > hg
changeset 21356:f96d7dfd8cb5
run-tests: move outputcoverage() into TestRunner
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 19 Apr 2014 23:49:23 -0700 |
parents | d83f4e94512a |
children | 4c4f64b8df3c |
files | tests/run-tests.py |
diffstat | 1 files changed, 24 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Sat Apr 19 23:47:59 2014 -0700 +++ b/tests/run-tests.py Sat Apr 19 23:49:23 2014 -0700 @@ -386,29 +386,6 @@ 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. @@ -1121,7 +1098,7 @@ runner.outputtimes() if runner.options.anycoverage: - outputcoverage(runner) + runner.outputcoverage() except KeyboardInterrupt: failed = True print "\ninterrupted!" @@ -1301,6 +1278,29 @@ 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()