Skip to content

Instantly share code, notes, and snippets.

@abyx
Created May 9, 2010 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abyx/395269 to your computer and use it in GitHub Desktop.
Save abyx/395269 to your computer and use it in GitHub Desktop.
from buildbot.process.properties import WithProperties
from buildbot.steps.shell import ShellCommand
from buildbot.interface import LOG_CHANNEL_STDERR as STDERR
class Nose(ShellCommand):
def __init__(self):
self.coverage_path = '/var/www/foo/coverage-%s'
self.coverage_url = 'http://example.com/foo/coverage-%s'
d = WithProperties('--cover-html-dir=' + self.coverage_path,
'buildnumber')
command = ['nosetests', '--with-coverage', '--cover-erase',
'--cover-html', d]
ShellCommand.__init__(self, command=command)
def createSummary(self, log):
buildnumber = self.getProperty('buildnumber')
coverage_index = ((self.coverage_path + '/index.html')
% buildnumber)
lines = [line.strip() for line in
log.readlines(channel=STDERR)]
percentage = 'N/A'
for line in lines:
if line.startswith('TOTAL'):
percentage = line.split()[-1]
break
self.addURL("coverage %s" % percentage,
self.coverage_url % buildnumber)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment