[Buildbot-commits] buildbot/buildbot/test runutils.py, 1.11, 1.12 test_steps.py, 1.23, 1.24 test_web.py, 1.31, 1.32
Brian Warner
warner at users.sourceforge.net
Sun Aug 20 22:25:37 UTC 2006
Update of /cvsroot/buildbot/buildbot/buildbot/test
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv14956/buildbot/test
Modified Files:
runutils.py test_steps.py test_web.py
Log Message:
[project @ add BuildStep URLs]
Original author: warner at lothar.com
Date: 2006-08-20 22:24:14
Index: runutils.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/runutils.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- runutils.py 20 Jun 2006 08:08:58 -0000 1.11
+++ runutils.py 20 Aug 2006 22:25:35 -0000 1.12
@@ -7,7 +7,9 @@
from buildbot import master, interfaces
from buildbot.twcompat import maybeWait
from buildbot.slave import bot
-from buildbot.process.base import BuildRequest
+from buildbot.process.builder import Builder
+from buildbot.process.base import BuildRequest, Build
+from buildbot.process.step import BuildStep
from buildbot.sourcestamp import SourceStamp
from buildbot.status import builder
@@ -227,6 +229,22 @@
s3.stepStarted()
return s3
+def makeBuildStep(basedir):
+ bss = setupBuildStepStatus(basedir)
+
+ ss = SourceStamp()
+ setup = {'name': "builder1", "slavename": "bot1",
+ 'builddir': "builddir", 'factory': None}
+ b0 = Builder(setup, bss.getBuild().getBuilder())
+ br = BuildRequest("reason", ss)
+ b = Build([br])
+ b.setBuilder(b0)
+ s = BuildStep(b)
+ s.setStepStatus(bss)
+ b.setupStatus(bss.getBuild())
+ return s
+
+
def findDir():
# the same directory that holds this script
return util.sibpath(__file__, ".")
Index: test_steps.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_steps.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- test_steps.py 6 Aug 2006 07:05:49 -0000 1.23
+++ test_steps.py 20 Aug 2006 22:25:35 -0000 1.24
@@ -25,6 +25,7 @@
from buildbot.process.step import ShellCommand #, ShellCommands
from buildbot.status import builder
from buildbot.test.runutils import RunMixin, rmtree, setupBuildStepStatus
+from buildbot.test.runutils import makeBuildStep
from buildbot.twcompat import maybeWait
from buildbot.slave import commands
@@ -160,6 +161,11 @@
self.assertEqual(self.results, 0)
+class MyObserver(step.LogObserver):
+ out = ""
+ def outReceived(self, data):
+ self.out = self.out + data
+
class Steps(unittest.TestCase):
def testMultipleStepInstances(self):
steps = [
@@ -176,6 +182,84 @@
b = f.newBuild([req])
#for s in b.steps: print s.name
+ # test the various methods available to buildsteps
+
+ def test_getProperty(self):
+ s = makeBuildStep("test_steps.Steps.test_getProperty")
+ bs = s.step_status.getBuild()
+
+ s.setProperty("prop1", "value1")
+ s.setProperty("prop2", "value2")
+ self.failUnlessEqual(s.getProperty("prop1"), "value1")
+ self.failUnlessEqual(bs.getProperty("prop1"), "value1")
+ self.failUnlessEqual(s.getProperty("prop2"), "value2")
+ self.failUnlessEqual(bs.getProperty("prop2"), "value2")
+ s.setProperty("prop1", "value1a")
+ self.failUnlessEqual(s.getProperty("prop1"), "value1a")
+ self.failUnlessEqual(bs.getProperty("prop1"), "value1a")
+
+
+ def test_addURL(self):
+ s = makeBuildStep("test_steps.Steps.test_addURL")
+ s.addURL("coverage", "http://coverage.example.org/target")
+ s.addURL("icon", "http://coverage.example.org/icon.png")
+ bs = s.step_status
+ links = bs.getURLs()
+ expected = {"coverage": "http://coverage.example.org/target",
+ "icon": "http://coverage.example.org/icon.png",
+ }
+ self.failUnlessEqual(links, expected)
+
+ def test_addLog(self):
+ s = makeBuildStep("test_steps.Steps.test_addLog")
+ l = s.addLog("newlog")
+ l.addStdout("some stdout here")
+ l.finish()
+ bs = s.step_status
+ logs = bs.getLogs()
+ self.failUnlessEqual(len(logs), 1)
+ l1 = logs[0]
+ self.failUnlessEqual(l1.getText(), "some stdout here")
+
+ def test_addHTMLLog(self):
+ s = makeBuildStep("test_steps.Steps.test_addHTMLLog")
+ l = s.addHTMLLog("newlog", "some html here")
+ bs = s.step_status
+ logs = bs.getLogs()
+ self.failUnlessEqual(len(logs), 1)
+ l1 = logs[0]
+ self.failUnless(isinstance(l1, builder.HTMLLogFile))
+ self.failUnlessEqual(l1.getText(), "some html here")
+
+ def test_addCompleteLog(self):
+ s = makeBuildStep("test_steps.Steps.test_addCompleteLog")
+ l = s.addCompleteLog("newlog", "some stdout here")
+ bs = s.step_status
+ logs = bs.getLogs()
+ self.failUnlessEqual(len(logs), 1)
+ l1 = logs[0]
+ self.failUnlessEqual(l1.getText(), "some stdout here")
+
+ def test_addLogObserver(self):
+ s = makeBuildStep("test_steps.Steps.test_addLogObserver")
+ bss = s.step_status
+ 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")
+
+
class VersionCheckingStep(step.BuildStep):
def start(self):
# give our test a chance to run. It is non-trivial for a buildstep to
@@ -201,7 +285,7 @@
c['slavePortnum'] = 0
"""
-class Version(RunMixin, unittest.TestCase):
+class SlaveVersion(RunMixin, unittest.TestCase):
def setUp(self):
RunMixin.setUp(self)
self.master.loadConfig(version_config)
@@ -233,36 +317,10 @@
self.failIf(s.slaveVersionIsOlderThan("svn", "1.1"))
self.failUnless(s.slaveVersionIsOlderThan("svn", cver + ".1"))
+ self.failUnlessEqual(s.getSlaveName(), "bot1")
+
def testCompare(self):
self.master._checker = self.checkCompare
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")
-
Index: test_web.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_web.py,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- test_web.py 16 Jun 2006 05:28:13 -0000 1.31
+++ test_web.py 20 Aug 2006 22:25:35 -0000 1.32
@@ -16,6 +16,7 @@
from buildbot.status import html, builder
from buildbot.changes.changes import Change
from buildbot.process import step, base
+from buildbot.test.runutils import setupBuildStepStatus
class ConfiguredMaster(master.BuildMaster):
"""This BuildMaster variant has a static config file, provided as a
@@ -249,6 +250,32 @@
def _test_waterfall_5(self, robotstxt):
self.failUnless(robotstxt == self.robots_txt_contents)
+class WaterfallSteps(unittest.TestCase):
+
+ # failUnlessSubstring copied from twisted-2.1.0, because this helps us
+ # maintain compatibility with python2.2.
+ def failUnlessSubstring(self, substring, astring, msg=None):
+ """a python2.2 friendly test to assert that substring is found in
+ astring parameters follow the semantics of failUnlessIn
+ """
+ if astring.find(substring) == -1:
+ raise self.failureException(msg or "%r not found in %r"
+ % (substring, astring))
+ return substring
+ assertSubstring = failUnlessSubstring
+
+ def test_urls(self):
+ s = setupBuildStepStatus("test_web.test_urls")
+ s.addURL("coverage", "http://coverage.example.org/target")
+ s.addURL("icon", "http://coverage.example.org/icon.png")
+ box = html.IBox(s).getBox()
+ td = box.td()
+ e1 = '<a href="http://coverage.example.org/target">coverage</a>'
+ self.failUnlessSubstring(e1, td)
+ e2 = '<a href="http://coverage.example.org/icon.png">icon</a>'
+ self.failUnlessSubstring(e2, td)
+
+
geturl_config = """
from buildbot.status import html
More information about the Commits
mailing list