From 9441446c63ef28590770db6cebb2300dc3b402f5 Mon Sep 17 00:00:00 2001 From: warner Date: Thu, 5 Oct 2006 05:39:11 +0100 Subject: [PATCH] PyFlakes: ignore initial output lines that weren't emitted by pyflakes --- ChangeLog | 8 ++++++++ buildbot/steps/python.py | 12 ++++++++++++ buildbot/test/test_steps.py | 36 +++++++++++++++++++++++++++++++++--- 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index c302e91..d73d724 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-10-04 Brian Warner + + * buildbot/steps/python.py (PyFlakes.createSummary): skip any + initial lines that weren't emitted by pyflakes. When the pyflakes + command is run under a Makefile, 'make' will echo the command it + runs to stdio, and that was getting logged as a "misc" warning. + * buildbot/test/test_steps.py (Python.testPyFlakes2): test it + 2006-10-01 Brian Warner * buildbot/status/html.py (HtmlResource.render): if we get a diff --git a/buildbot/steps/python.py b/buildbot/steps/python.py index 5c3efc8..1d7de9f 100644 --- a/buildbot/steps/python.py +++ b/buildbot/steps/python.py @@ -65,7 +65,19 @@ class PyFlakes(ShellCommand): 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: diff --git a/buildbot/test/test_steps.py b/buildbot/test/test_steps.py index f143291..5e01018 100644 --- a/buildbot/test/test_steps.py +++ b/buildbot/test/test_steps.py @@ -394,11 +394,12 @@ class CheckStepTester(StepTester, unittest.TestCase): return maybeWait(d) class Python(StepTester, unittest.TestCase): - def testPyFlakes(self): - self.masterbase = "Python.master" + def testPyFlakes1(self): + self.masterbase = "Python.testPyFlakes1" step = self.makeStep(python.PyFlakes) output = \ -"""buildbot/changes/freshcvsmail.py:5: 'FCMaildirSource' imported but unused +"""pyflakes buildbot +buildbot/changes/freshcvsmail.py:5: 'FCMaildirSource' imported but unused buildbot/clients/debug.py:9: redefinition of unused 'gtk' from line 9 buildbot/clients/debug.py:9: 'gnome' imported but unused buildbot/scripts/runner.py:323: redefinition of unused 'run' from line 321 @@ -415,6 +416,7 @@ buildbot/scripts/imaginary.py:18: 'from buildbot import *' used; unable to detec self.failUnless("undefined=1" in desc) self.failUnless("redefs=3" in desc) self.failUnless("import*=1" in desc) + self.failIf("misc=" in desc) self.failUnlessEqual(step.getProperty("pyflakes-unused"), 2) self.failUnlessEqual(step.getProperty("pyflakes-undefined"), 1) @@ -438,3 +440,31 @@ buildbot/scripts/imaginary.py:18: 'from buildbot import *' used; unable to detec cmd.rc = 0 results = step.evaluateCommand(cmd) self.failUnlessEqual(results, FAILURE) # because of the 'undefined' + + def testPyFlakes2(self): + self.masterbase = "Python.testPyFlakes2" + step = self.makeStep(python.PyFlakes) + output = \ +"""pyflakes buildbot +some more text here that should be ignored +buildbot/changes/freshcvsmail.py:5: 'FCMaildirSource' imported but unused +buildbot/clients/debug.py:9: redefinition of unused 'gtk' from line 9 +buildbot/clients/debug.py:9: 'gnome' imported but unused +buildbot/scripts/runner.py:323: redefinition of unused 'run' from line 321 +buildbot/scripts/runner.py:325: redefinition of unused 'run' from line 323 +buildbot/scripts/imaginary.py:12: undefined name 'size' +could not compile 'blah/blah.py':3: +pretend there was an invalid line here +buildbot/scripts/imaginary.py:18: 'from buildbot import *' used; unable to detect undefined names +""" + log = step.addLog("stdio") + log.addStdout(output) + log.finish() + step.createSummary(log) + desc = step.descriptionDone + self.failUnless("unused=2" in desc) + self.failUnless("undefined=1" in desc) + self.failUnless("redefs=3" in desc) + self.failUnless("import*=1" in desc) + self.failUnless("misc=2" in desc) + -- 2.11.4.GIT