[Buildbot-devel] Question on getting custom text to show up in waterfall.

Alexander O'Donovan-Jones Alexander at ccpgames.com
Fri Jun 18 16:20:45 UTC 2010


This is from a PyFlakes wrapper I've got in my source. I've trimmed it a bit, but you should get the idea. I found it somewhere else, although where escapes at the moment. The crucial bit you're after is the self.descriptionDone.append(...) line

from buildbot.steps.shell import WarningCountingShellCommand
try:
    import cStringIO
    StringIO = cStringIO.StringIO
except ImportError:
    from StringIO import StringIO

def MyFlakes(WarningCountingShellCommand):
	MESSAGES = ("unused", "undefined", "redefs", "import*", "print", "misc")
	def createSummary(self, log):
        counts = {}
        summaries = {}
        for m in self.MESSAGES:
            counts[m] = 0
            summaries[m] = []

        first = True
        for line in StringIO(log.getText()).readlines():
            # the first few lines might contain echoed commands from a 'make
            # pyflakes' step, so don't count these as warnings. Stop ignoring
            # the initial lines as soon as we see one with a colon.
            if first:
                if line.find(":") != -1:
                    # there's the colon, this is the first real line
                    first = False
                    # fall through and parse the line
                else:
                    # skip this line, keep skipping non-colon lines
                    continue
            if line.find("imported but unused") != -1:
                m = "unused"
            elif line.find("*' used; unable to detect undefined names") != -1:
                m = "import*"
            elif line.find("undefined name") != -1:
                m = "undefined"
            elif line.find("redefinition of") != -1:
                m = "redefs"
            elif line.find("print statement used") != -1:
                m = "print"
            elif line.find("is assigned to but never used") != -1:
                m = "misc"
            elif line.find("Analysis complete") != -1:
                continue
            else:
                m = "misc"
            # occasionally we will get a blank line, so we don't actually want to do 
            # anything with it. However, if there's a section like "line.find('\n')" in 
            # the code block above, it'll match on too many lines.
            # instead we do it afterwards!
            if line.strip() == '':
                continue
            summaries[m].append(line)
            counts[m] += 1

        self.descriptionDone = self.descriptionDone[:]
        for m in self.MESSAGES:
            if counts[m]:
                self.descriptionDone.append("%s=%d" % (m, counts[m]))
                self.addCompleteLog(m, "".join(summaries[m]))
            self.setProperty("pyflakes-%s" % m, counts[m], "pyflakes")
        self.setProperty("pyflakes-total", sum(counts.values()), "pyflakes")

-----Original Message-----
From: Ben Greear [mailto:greearb at candelatech.com] 
Sent: Friday, June 18, 2010 3:39 PM
To: buildbot-devel at lists.sourceforge.net
Subject: [Buildbot-devel] Question on getting custom text to show up in waterfall.

I've managed to get some custom log files generated by overriding the
ShellCommand object:

class MyShellCommand(ShellCommand):
   def createSummary(self, log):
     failures = []
     passed = []
     pcount = 0
     fcount = 0
     for line in log.readlines():
         if "Tests Failed" in line:
             fcount += 1
             failures.append(line)
         elif "Test Failed" in line:
             fcount += 1
             failures.append(line)
         elif "Tests Succeeded" in line:
             pcount += 1
             passed.append(line)
         elif "Test Passed" in line:
             pcount += 1
             passed.append(line)

     failures.append("Total test failures: %i" % fcount)
     passed.append("Total test successes: %i" % pcount)
     self.addCompleteLog('failures', "".join(failures))
     self.addCompleteLog('passed', "".join(passed))


My factory looks like this:

f2 = factory.BuildFactory()
f2.addStep(Git(repourl=gitrepourl, mode="copy"))
f2.addStep(ShellCommand(command=["rm", "-fr", "obj"], workdir="build/xorp", descriptionDone="clean"))
f2.addStep(ShellCommand(command=["scons"], workdir="build/xorp", description="compiling", descriptionDone="compile"))
f2.addStep(MyShellCommand(command=["scons", "check"], workdir="build/xorp", description="checking", descriptionDone="check"))


I would now like to have the waterfall show a summary of passed
and failed, something like:

P: 400  F: 6

Where the 400 and 6 relate to pcount and fcount.

The idea is to be able to quickly glance at the waterfall page to see if
any particular slave is testing different than others, and longer-term, to
hopefully see passed tests increase and failed tests decrease.

Anyone know how to go about doing this?

Thanks,
Ben

-- 
Ben Greear <greearb at candelatech.com>
Candela Technologies Inc  http://www.candelatech.com

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Buildbot-devel mailing list
Buildbot-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/buildbot-devel





More information about the devel mailing list