[Buildbot-devel] filtering stdout/stderr from build steps?

Brian Warner warner-buildbot at lothar.com
Thu Nov 20 21:45:07 UTC 2003


> I was wondering how to make a simple "FilteredShellCommand" class that 
> filters its stdout/stderr before sending it off as the progress.  One 
> of the build mechanisms I use generates a whole pile of output that I'd 
> like to clean up before posting to the build log.  I also need to 
> filter the output b/c the build command always succeeds so I have to 
> parse the output to determine if the build should be marked as passed 
> or failed.  It wasn't clear to me from reading the source how I would 
> do that.

Take a look at buildbot.process.step_twisted.RunUnitTests.finished . The
self.log object lets you grab stdout, stderr, or interleaved stdout+stderr
with the getStdout, getStderr, getAll methods. The RunUnitTests step then
puts them through a filter that scans for a few test-summary lines and uses
the passed/failed counts to influence the way the step results are described.
finished() returns a tuple of two items: the first is a success code
(SUCCESS, FAILURE, WARNINGS, etc), the second is a list of strings (one per
line) which are put into the step's box on the waterfall display.

Steps can also create new files for their event box..
step.ShellCommand.finishStatusSummary is a hook which passes the combined
stdout/stderr to a summary function and puts the results in new files (i.e.
new links from the event box). Any ShellCommand subclass can stash a function
in the .summaryFunction attribute and it will be called this way.
step_twisted.trialTextSummarizer is an example: it scans through the test
output looking for just the results (skipping the progress markers) and
creates a file called "summary" with the stripped-down output.

The finished() result is used to decide whether the step succeeded or failed,
so to do something other than "rc!=0 means failure" you'll need to override
it. The .summaryFunction hook is designed to producing more readable log
output, but it cannot affect the basic pass/fail status of a step.

cheers,
 -Brian




More information about the devel mailing list