mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-19 13:07:56 +00:00
Add a --coverage option to 'python setup.py test' and 'python setup.py trial'. refs #1698
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
parent
a1cc7df23d
commit
11809c3367
24
setup.py
24
setup.py
@ -153,6 +153,7 @@ class Trial(Command):
|
|||||||
("reporter=", None, "The reporter to use for this test run."),
|
("reporter=", None, "The reporter to use for this test run."),
|
||||||
("suite=", "s", "Specify the test suite."),
|
("suite=", "s", "Specify the test suite."),
|
||||||
("quiet", None, "Don't display version numbers and paths of Tahoe dependencies."),
|
("quiet", None, "Don't display version numbers and paths of Tahoe dependencies."),
|
||||||
|
("coverage", "c", "Collect branch coverage information."),
|
||||||
]
|
]
|
||||||
|
|
||||||
def initialize_options(self):
|
def initialize_options(self):
|
||||||
@ -162,12 +163,35 @@ class Trial(Command):
|
|||||||
self.reporter = None
|
self.reporter = None
|
||||||
self.suite = "allmydata"
|
self.suite = "allmydata"
|
||||||
self.quiet = False
|
self.quiet = False
|
||||||
|
self.coverage = False
|
||||||
|
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
args = [sys.executable, os.path.join('bin', 'tahoe')]
|
args = [sys.executable, os.path.join('bin', 'tahoe')]
|
||||||
|
|
||||||
|
if self.coverage:
|
||||||
|
from errno import ENOENT
|
||||||
|
coverage_cmd = 'coverage'
|
||||||
|
try:
|
||||||
|
subprocess.call([coverage_cmd, 'help'])
|
||||||
|
except OSError as e:
|
||||||
|
if e.errno != ENOENT:
|
||||||
|
raise
|
||||||
|
coverage_cmd = 'python-coverage'
|
||||||
|
try:
|
||||||
|
rc = subprocess.call([coverage_cmd, 'help'])
|
||||||
|
except OSError as e:
|
||||||
|
if e.errno != ENOENT:
|
||||||
|
raise
|
||||||
|
print >>sys.stderr
|
||||||
|
print >>sys.stderr, "Couldn't find the command 'coverage' nor 'python-coverage'."
|
||||||
|
print >>sys.stderr, "coverage can be installed using 'pip install coverage', or on Debian-based systems, 'apt-get install python-coverage'."
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
args += ['@' + coverage_cmd, 'run', '--branch', '--source=src/allmydata', '@tahoe']
|
||||||
|
|
||||||
if not self.quiet:
|
if not self.quiet:
|
||||||
args.append('--version-and-path')
|
args.append('--version-and-path')
|
||||||
args += ['debug', 'trial']
|
args += ['debug', 'trial']
|
||||||
|
Loading…
Reference in New Issue
Block a user