[Buildbot-commits] buildbot/buildbot/test runutils.py, 1.5, 1.6 test_steps.py, 1.18, 1.19

Brian Warner warner at users.sourceforge.net
Fri Jun 16 05:28:08 UTC 2006


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

Modified Files:
	runutils.py test_steps.py 
Log Message:
[project @ new LogObserver test, new setupBuildStepStatus utility method]

Original author: warner at lothar.com
Date: 2006-06-16 01:06:50

Index: runutils.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/runutils.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- runutils.py	29 May 2006 00:10:38 -0000	1.5
+++ runutils.py	16 Jun 2006 05:28:06 -0000	1.6
@@ -208,3 +208,17 @@
         # connection, and sees two connections at once.
         raise NotImplementedError
 
+
+def setupBuildStepStatus(basedir):
+    """Return a BuildStep with a suitable BuildStepStatus object, ready to
+    use."""
+    os.mkdir(basedir)
+    botmaster = None
+    s0 = builder.Status(botmaster, basedir)
+    s1 = s0.builderAdded("buildername", "buildername")
+    s2 = builder.BuildStatus(s1, 1)
+    s3 = builder.BuildStepStatus(s2)
+    s3.setName("foostep")
+    s3.started = True
+    s3.stepStarted()
+    return s3

Index: test_steps.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_steps.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- test_steps.py	16 Jun 2006 05:27:52 -0000	1.18
+++ test_steps.py	16 Jun 2006 05:28:06 -0000	1.19
@@ -24,7 +24,7 @@
 from buildbot.process import step, base, factory
 from buildbot.process.step import ShellCommand #, ShellCommands
 from buildbot.status import builder
-from buildbot.test.runutils import RunMixin
+from buildbot.test.runutils import RunMixin, setupBuildStep
 from buildbot.twcompat import maybeWait
 from buildbot.slave import commands
 
@@ -234,3 +234,31 @@
         d = self.doBuild("quick")
         return maybeWait(d)
 
+
+class MyObserver(step.LogObserver):
+    out = ""
+    def outReceived(self, data):
+        self.out = self.out + data
+
+class LogObserver(unittest.TestCase):
+    def testAdd(self):
+        bss = setupBuildStepStatus("logobserver")
+        build = None
+        s = step.BuildStep(build)
+        s.setStepStatus(bss)
+        o1,o2,o3 = MyObserver(), MyObserver(), MyObserver()
+
+        # add the log before the observer
+        l1 = s.addLog("one")
+        l1.addStdout("onestuff")
+        s.addLogObserver("one", o1)
+        self.failUnlessEqual(o1.out, "onestuff")
+        l1.addStdout(" morestuff")
+        self.failUnlessEqual(o1.out, "onestuff morestuff")
+
+        # add the observer before the log
+        s.addLogObserver("two", o2)
+        l2 = s.addLog("two")
+        l2.addStdout("twostuff")
+        self.failUnlessEqual(o2.out, "twostuff")
+





More information about the Commits mailing list