From: Brian Warner Date: Tue, 9 Sep 2014 00:28:26 +0000 (-0700) Subject: Remove 'trialcoverage' plugin and support code X-Git-Tag: allmydata-tahoe-1.10.1a1~142^2 X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/frontends/FTP-and-SFTP.txt?a=commitdiff_plain;h=6ffcb501734053b4e77e060e5baea8b9c9396214;p=tahoe-lafs%2Ftahoe-lafs.git Remove 'trialcoverage' plugin and support code Closes ticket:2281 (trac). This removes src/allmydata/test/trial_coverage.py, which was a in-process way to run trial tests under the "coverage" code-coverage tool. These days, the preferred way to do this is with "coverage run", although the actual invocation is a bit messy because of the way bin/trial uses subprocess.call() to invoke the real entrypoint script with the right PYTHONPATH (see #1698 for details). Hopefully this will be improved to use a simpler "coverage run .." command in the future. This patch also removes twisted/plugins/allmydata_trial.py, which enabled the "--reporter=bwverbose-coverage" option. Finally it modifies setup.py to stop looking for that option and adding "trialcoverage" to the dependencies list, which gets us closer to removing "setup_requires" entirely. --- diff --git a/setup.py b/setup.py index 04e54c20..469f7c87 100644 --- a/setup.py +++ b/setup.py @@ -133,13 +133,6 @@ setup_requires = [] # https://bugs.launchpad.net/nevow/+bug/812537 has been fixed. setup_requires += [req for req in install_requires if req.startswith('Twisted') or req.startswith('zope.interface')] -# trialcoverage is required if you want the "trial" unit test runner to have a -# "--reporter=bwverbose-coverage" option which produces code-coverage results. -# The required version is 0.3.3, because that is the latest version that only -# depends on a version of pycoverage for which binary packages are available. -if "--reporter=bwverbose-coverage" in sys.argv: - setup_requires.append('trialcoverage >= 0.3.3') - # We no longer have any requirements specific to tests. tests_require=[] diff --git a/src/allmydata/test/trial_coverage.py b/src/allmydata/test/trial_coverage.py deleted file mode 100644 index 47569da1..00000000 --- a/src/allmydata/test/trial_coverage.py +++ /dev/null @@ -1,110 +0,0 @@ - -"""A Trial IReporter plugin that gathers coverage.py code-coverage information. - -Once this plugin is installed, trial can be invoked a new --reporter option: - - trial --reporter-bwverbose-coverage ARGS - -Once such a test run has finished, there will be a .coverage file in the -top-level directory. This file can be turned into a directory of .html files -(with index.html as the starting point) by running: - - coverage html -d OUTPUTDIR --omit=PREFIX1,PREFIX2,.. - -The 'coverage' tool thinks in terms of absolute filenames. 'coverage' doesn't -record data for files that come with Python, but it does record data for all -the various site-package directories. To show only information for Tahoe -source code files, you should provide --omit prefixes for everything else. -This probably means something like: - - --omit=/System/,/Library/,support/,src/allmydata/test/ - -Before using this, you need to install the 'coverage' package, which will -provide an executable tool named 'coverage' (as well as an importable -library). 'coverage report' will produce a basic text summary of the coverage -data. Our 'misc/coverage2text.py' tool produces a slightly more useful -summary, and 'misc/coverage2html.py' will produce a more useful HTML report. - -""" - -from twisted.trial.reporter import TreeReporter, VerboseTextReporter - -# These plugins are registered via twisted/plugins/allmydata_trial.py . See -# the notes there for an explanation of how that works. - -# Some notes about how trial Reporters are used: -# * Reporters don't really get told about the suite starting and stopping. -# * The Reporter class is imported before the test classes are. -# * The test classes are imported before the Reporter is created. To get -# control earlier than that requires modifying twisted/scripts/trial.py -# * Then Reporter.__init__ is called. -# * Then tests run, calling things like write() and addSuccess(). Each test is -# framed by a startTest/stopTest call. -# * Then the results are emitted, calling things like printErrors, -# printSummary, and wasSuccessful. -# So for code-coverage (not including import), start in __init__ and finish -# in printSummary. To include import, we have to start in our own import and -# finish in printSummary. - -import coverage -cov = coverage.coverage() -cov.start() - - -class CoverageTextReporter(VerboseTextReporter): - def __init__(self, *args, **kwargs): - VerboseTextReporter.__init__(self, *args, **kwargs) - - def stop_coverage(self): - cov.stop() - cov.save() - print "Coverage results written to .coverage" - def printSummary(self): - # for twisted-2.5.x - self.stop_coverage() - return VerboseTextReporter.printSummary(self) - def done(self): - # for twisted-8.x - self.stop_coverage() - return VerboseTextReporter.done(self) - -class sample_Reporter(object): - # this class, used as a reporter on a fully-passing test suite, doesn't - # trigger exceptions. So it is a guide to what methods are invoked on a - # Reporter. - def __init__(self, *args, **kwargs): - print "START HERE" - self.r = TreeReporter(*args, **kwargs) - self.shouldStop = self.r.shouldStop - self.separator = self.r.separator - self.testsRun = self.r.testsRun - self._starting2 = False - - def write(self, *args): - if not self._starting2: - self._starting2 = True - print "FIRST WRITE" - return self.r.write(*args) - - def startTest(self, *args, **kwargs): - return self.r.startTest(*args, **kwargs) - - def stopTest(self, *args, **kwargs): - return self.r.stopTest(*args, **kwargs) - - def addSuccess(self, *args, **kwargs): - return self.r.addSuccess(*args, **kwargs) - - def printErrors(self, *args, **kwargs): - return self.r.printErrors(*args, **kwargs) - - def writeln(self, *args, **kwargs): - return self.r.writeln(*args, **kwargs) - - def printSummary(self, *args, **kwargs): - print "PRINT SUMMARY" - return self.r.printSummary(*args, **kwargs) - - def wasSuccessful(self, *args, **kwargs): - return self.r.wasSuccessful(*args, **kwargs) - diff --git a/twisted/plugins/allmydata_trial.py b/twisted/plugins/allmydata_trial.py deleted file mode 100644 index c9ee5b9a..00000000 --- a/twisted/plugins/allmydata_trial.py +++ /dev/null @@ -1,41 +0,0 @@ -#! /usr/bin/env python - -from zope.interface import implements -from twisted.trial.itrial import IReporter -from twisted.plugin import IPlugin - -# register a plugin that can create our CoverageReporter. The reporter itself -# lives separately, in src/allmydata/test/trial_coverage.py - -# note that this allmydata_trial.py file is *not* in a package: there is no -# __init__.py in our parent directory. This is important, because otherwise -# ours would fight with Twisted's. When trial looks for plugins, it merely -# executes all the *.py files it finds in any twisted/plugins/ subdirectories -# of anything on sys.path . The namespace that results from executing these -# .py files is examined for instances which provide both IPlugin and the -# target interface (in this case, trial is looking for IReporter instances). -# Each such instance tells the application how to create a plugin by naming -# the module and class that should be instantiated. - -# When installing our package via setup.py, arrange for this file to be -# installed to the system-wide twisted/plugins/ directory. - -class _Reporter(object): - implements(IPlugin, IReporter) - - def __init__(self, name, module, description, longOpt, shortOpt, klass): - self.name = name - self.module = module - self.description = description - self.longOpt = longOpt - self.shortOpt = shortOpt - self.klass = klass - - -bwcov = _Reporter("Code-Coverage Reporter (colorless)", - "allmydata.test.trial_coverage", - description="Colorless verbose output (with 'coverage' coverage)", - longOpt="bwverbose-coverage", - shortOpt=None, - klass="CoverageTextReporter") -