You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2011/03/14 02:23:41 UTC
svn commit: r1081243 - in /incubator/libcloud/trunk: .coveragerc setup.py
Author: tomaz
Date: Mon Mar 14 01:23:41 2011
New Revision: 1081243
URL: http://svn.apache.org/viewvc?rev=1081243&view=rev
Log:
Add coverage command.
Added:
incubator/libcloud/trunk/.coveragerc
Modified:
incubator/libcloud/trunk/setup.py
Added: incubator/libcloud/trunk/.coveragerc
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/.coveragerc?rev=1081243&view=auto
==============================================================================
--- incubator/libcloud/trunk/.coveragerc (added)
+++ incubator/libcloud/trunk/.coveragerc Mon Mar 14 01:23:41 2011
@@ -0,0 +1,27 @@
+# .coveragerc to control coverage.py
+[run]
+branch = True
+source = libcloud
+
+[report]
+# Regexes for lines to exclude from consideration
+exclude_lines =
+ # Have to re-enable the standard pragma
+ pragma: no cover
+
+ # Don't complain about missing debug-only code:
+ def __repr__
+ if self\.debug
+
+ # Don't complain if tests don't hit defensive assertion code:
+ raise AssertionError
+ raise NotImplementedError
+
+ # Don't complain if non-runnable code isn't run:
+ if 0:
+ if __name__ == .__main__.:
+
+ignore_errors = True
+
+[html]
+directory = coverage_html_report
Modified: incubator/libcloud/trunk/setup.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/setup.py?rev=1081243&r1=1081242&r2=1081243&view=diff
==============================================================================
--- incubator/libcloud/trunk/setup.py (original)
+++ incubator/libcloud/trunk/setup.py Mon Mar 14 01:23:41 2011
@@ -41,6 +41,10 @@ class TestCommand(Command):
pass
def run(self):
+ status = self._run_tests()
+ sys.exit(status)
+
+ def _run_tests(self):
secrets = pjoin(self._dir, 'test', 'secrets.py')
if not os.path.isfile(secrets):
print "Missing %s" % (secrets)
@@ -77,7 +81,7 @@ class TestCommand(Command):
tests = TestLoader().loadTestsFromNames(testfiles)
t = TextTestRunner(verbosity = 2)
res = t.run(tests)
- sys.exit(not res.wasSuccessful())
+ return not res.wasSuccessful()
class ApiDocsCommand(Command):
user_options = []
@@ -100,6 +104,27 @@ class ApiDocsCommand(Command):
% (HTML_VIEWSOURCE_BASE, PROJECT_BASE_DIR)
)
+class CoverageCommand(Command):
+ user_options = []
+
+ def initialize_options(self):
+ pass
+
+ def finalize_options(self):
+ pass
+
+ def run(self):
+ import coverage
+ cov = coverage.coverage(config_file='.coveragerc')
+ cov.start()
+
+ tc = TestCommand(self.distribution)
+ tc._run_tests()
+
+ cov.stop()
+ cov.save()
+ cov.html_report()
+
# pre-2.6 will need the ssl PyPI package
pre_python26 = (sys.version_info[0] == 2 and sys.version_info[1] < 6)
@@ -125,7 +150,8 @@ setup(
url='http://incubator.apache.org/libcloud/',
cmdclass={
'test': TestCommand,
- 'apidocs': ApiDocsCommand
+ 'apidocs': ApiDocsCommand,
+ 'coverage': CoverageCommand
},
classifiers=[
'Development Status :: 4 - Beta',