--- /root/porting/buildbot-0.7.5/buildbot/steps/shell.py	2006-12-11 05:40:12.000000000 +0000
+++ /usr/lib/python2.4/site-packages/buildbot/steps/shell.py	2007-08-01 15:25:57.000000000 +0100
@@ -247,7 +247,62 @@
     descriptionDone = ["configure"]
     command = ["./configure"]
 
-class Compile(ShellCommand):
+class WarningCountingShellCommand(ShellCommand):
+    warnCount = 0
+
+    def __init__(self, workdir,
+                 description=None, descriptionDone=None,
+                 command=None,
+                 **kwargs):
+        # See if we've been given a regular expression to use to match
+        # warngins. If not, use a default that assumes any line with "warning"
+        # present is a warning. This may lead to false positives in some cases.
+        if kwargs.has_key('warningPattern'):
+            warningPattern = kwargs['warningPattern']
+            del kwargs['warningPattern']
+        else:
+            warningPattern = '.*warning[: ].*'
+
+        # Now compile a regular expression from whichever warning pattern we're
+        # using
+        if "" != warningPattern:
+            self.warningRegExp = re.compile(warningPattern)
+        else:
+            self.warningRegExp = None
+
+        # And upcall to let the base class do its work
+        ShellCommand.__init__(self, workdir,
+                              description, descriptionDone,
+                              command,
+                              **kwargs)
+
+    def createSummary(self, log):
+        self.warnCount = 0
+
+        # Check if each line in the output from this command matched out
+        # warnings regular expressions. If did, bump the warnings count and
+        # add the line to the collection of lines with warnings
+        if None != self.warningRegExp:
+            warnings = []
+            for line in log.getText().split("\n"):
+                if self.warningRegExp.match(line):
+                    warnings.append(line)
+                    self.warnCount += 1
+
+            # If there were any warnings, make the log if lines with warngins
+            # available
+            if self.warnCount:
+                self.addCompleteLog("warnings", "".join(warnings))
+
+    def evaluateCommand(self, cmd):
+        if cmd.rc != 0:
+            return FAILURE
+        if self.warnCount:
+            return WARNINGS
+        return SUCCESS
+
+
+class Compile(WarningCountingShellCommand):
 
     name = "compile"
     haltOnFailure = 1
@@ -260,11 +315,12 @@
     # traversed (assuming 'make' is being used)
 
     def createSummary(self, cmd):
-        # TODO: grep for the characteristic GCC warning/error lines and
+        # TODO: grep for the characteristic GCC error lines and
         # assemble them into a pair of buffers
+        WarningCountingShellCommand.createSummary(self, cmd)
         pass
 
-class Test(ShellCommand):
+class Test(WarningCountingShellCommand):
 
     name = "test"
     warnOnFailure = 1

