[Buildbot-commits] buildbot/buildbot/test test_steps.py,1.45,1.46

Brian Warner warner at users.sourceforge.net
Sun Dec 23 07:17:03 UTC 2007


Update of /cvsroot/buildbot/buildbot/buildbot/test
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv4392/buildbot/test

Modified Files:
	test_steps.py 
Log Message:
[project @ make Compile and Test count warnings, by regexp. Closes #74.]

Original author: warner at lothar.com
Date: 2007-12-23 07:12:34+00:00

Index: test_steps.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_steps.py,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- test_steps.py	15 Dec 2007 01:02:04 -0000	1.45
+++ test_steps.py	23 Dec 2007 07:17:01 -0000	1.46
@@ -24,7 +24,7 @@
 from buildbot.buildslave import BuildSlave
 from buildbot.steps import shell, source, python
 from buildbot.status import builder
-from buildbot.status.builder import SUCCESS, FAILURE
+from buildbot.status.builder import SUCCESS, WARNINGS, FAILURE
 from buildbot.test.runutils import RunMixin, rmtree
 from buildbot.test.runutils import makeBuildStep, StepTester
 from buildbot.slave import commands, registry
@@ -522,3 +522,100 @@
         self.failUnless("import*=1" in desc)
         self.failIf("misc" in desc)
 
+
+class OrdinaryCompile(shell.Compile):
+    warningPattern = "ordinary line"
+
+class Warnings(StepTester, unittest.TestCase):
+    def testCompile1(self):
+        self.masterbase = "Warnings.testCompile1"
+        step = self.makeStep(shell.Compile)
+        output = \
+"""Compile started
+normal line
+warning: oh noes!
+ordinary line
+error (but we aren't looking for errors now, are we)
+line 23: warning: we are now on line 23
+ending line
+"""
+        log = step.addLog("stdio")
+        log.addStdout(output)
+        log.finish()
+        step.createSummary(log)
+        self.failUnlessEqual(step.getProperty("warnings-count"), 2)
+        logs = {}
+        for log in step.step_status.getLogs():
+            logs[log.getName()] = log
+        self.failUnless("warnings" in logs)
+        lines = logs["warnings"].readlines()
+        self.failUnlessEqual(len(lines), 2)
+        self.failUnlessEqual(lines[0], "warning: oh noes!\n")
+        self.failUnlessEqual(lines[1],
+                             "line 23: warning: we are now on line 23\n")
+
+        cmd = buildstep.RemoteCommand(None, {})
+        cmd.rc = 0
+        results = step.evaluateCommand(cmd)
+        self.failUnlessEqual(results, WARNINGS)
+
+    def testCompile2(self):
+        self.masterbase = "Warnings.testCompile2"
+        step = self.makeStep(shell.Compile, warningPattern="ordinary line")
+        output = \
+"""Compile started
+normal line
+warning: oh noes!
+ordinary line
+error (but we aren't looking for errors now, are we)
+line 23: warning: we are now on line 23
+ending line
+"""
+        log = step.addLog("stdio")
+        log.addStdout(output)
+        log.finish()
+        step.createSummary(log)
+        self.failUnlessEqual(step.getProperty("warnings-count"), 1)
+        logs = {}
+        for log in step.step_status.getLogs():
+            logs[log.getName()] = log
+        self.failUnless("warnings" in logs)
+        lines = logs["warnings"].readlines()
+        self.failUnlessEqual(len(lines), 1)
+        self.failUnlessEqual(lines[0], "ordinary line\n")
+
+        cmd = buildstep.RemoteCommand(None, {})
+        cmd.rc = 0
+        results = step.evaluateCommand(cmd)
+        self.failUnlessEqual(results, WARNINGS)
+
+    def testCompile3(self):
+        self.masterbase = "Warnings.testCompile3"
+        step = self.makeStep(OrdinaryCompile)
+        output = \
+"""Compile started
+normal line
+warning: oh noes!
+ordinary line
+error (but we aren't looking for errors now, are we)
+line 23: warning: we are now on line 23
+ending line
+"""
+        step.setProperty("warnings-count", 10)
+        log = step.addLog("stdio")
+        log.addStdout(output)
+        log.finish()
+        step.createSummary(log)
+        self.failUnlessEqual(step.getProperty("warnings-count"), 11)
+        logs = {}
+        for log in step.step_status.getLogs():
+            logs[log.getName()] = log
+        self.failUnless("warnings" in logs)
+        lines = logs["warnings"].readlines()
+        self.failUnlessEqual(len(lines), 1)
+        self.failUnlessEqual(lines[0], "ordinary line\n")
+
+        cmd = buildstep.RemoteCommand(None, {})
+        cmd.rc = 0
+        results = step.evaluateCommand(cmd)
+        self.failUnlessEqual(results, WARNINGS)





More information about the Commits mailing list