[Buildbot-commits] buildbot/buildbot/test runutils.py, 1.18, 1.19 test_config.py, 1.42, 1.43 test_properties.py, 1.6, 1.7 test_steps.py, 1.38, 1.39 test_vc.py, 1.73, 1.74 test_web.py, 1.43, 1.44

Brian Warner warner at users.sourceforge.net
Mon Jun 18 02:52:51 UTC 2007


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

Modified Files:
	runutils.py test_config.py test_properties.py test_steps.py 
	test_vc.py test_web.py 
Log Message:
[project @ use instances instead of class/kwarg tuples when putting BuildSteps in factories. Closes: #11.]

Original author: warner at lothar.com
Date: 2007-06-18 02:51:00+00:00

Index: runutils.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/runutils.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- runutils.py	11 Dec 2006 08:23:29 -0000	1.18
+++ runutils.py	18 Jun 2007 02:52:49 -0000	1.19
@@ -242,7 +242,8 @@
     br = BuildRequest("reason", ss)
     b = Build([br])
     b.setBuilder(b0)
-    s = step_class(build=b, **kwargs)
+    s = step_class(**kwargs)
+    s.setBuild(b)
     s.setStepStatus(bss)
     b.setupStatus(bss.getBuild())
     s.slaveVersion = fake_slaveVersion
@@ -398,9 +399,8 @@
 
     workdir = "build"
     def makeStep(self, factory, **kwargs):
-        if not kwargs.has_key("workdir"):
-            kwargs['workdir'] = self.workdir
         step = makeBuildStep(self.masterbase, factory, **kwargs)
+        step.setDefaultWorkdir(self.workdir)
         return step
 
     def runStep(self, step):

Index: test_config.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_config.py,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- test_config.py	11 Dec 2006 08:40:17 -0000	1.42
+++ test_config.py	18 Jun 2007 02:52:49 -0000	1.43
@@ -22,8 +22,8 @@
 from twisted.web.distrib import ResourcePublisher
 from buildbot.process.builder import Builder
 from buildbot.process.factory import BasicBuildFactory
-from buildbot.steps.source import CVS
-from buildbot.steps.shell import Compile, Test
+from buildbot.steps.source import CVS, Darcs
+from buildbot.steps.shell import Compile, Test, ShellCommand
 from buildbot.status import base
 words = None
 try:
@@ -1099,3 +1099,81 @@
     def _testStartService_4(self, res):
         self.failUnlessEqual(self.master.targetevents,
                              [('stop', 'b'), ('start', 'a')])
+
+cfg1 = \
+"""
+from buildbot.process.factory import BuildFactory, s
+from buildbot.steps.shell import ShellCommand
+from buildbot.steps.source import Darcs
+BuildmasterConfig = c = {}
+c['bots'] = [('bot1', 'pw1')]
+c['sources'] = []
+c['schedulers'] = []
+c['slavePortnum'] = 9999
+f1 = BuildFactory([ShellCommand(command='echo yes'),
+                   s(ShellCommand, command='old-style'),
+                   ])
+f1.addStep(Darcs(repourl='http://buildbot.net/repos/trunk'))
+f1.addStep(ShellCommand, command='echo old-style')
+c['builders'] = [{'name':'builder1', 'slavename':'bot1',
+                  'builddir':'workdir', 'factory':f1}]
+"""
+
+class Factories(unittest.TestCase):
+
+    def failUnlessExpectedShell(self, factory, defaults=True, **kwargs):
+        shell_args = {}
+        if defaults:
+            shell_args.update({'descriptionDone': None,
+                               'description': None,
+                               'workdir': None,
+                               'logfiles': {},
+                               })
+        shell_args.update(kwargs)
+        self.failUnlessIdentical(factory[0], ShellCommand)
+        if factory[1] != shell_args:
+            print
+            print "factory had:"
+            for k in sorted(factory[1].keys()):
+                print k
+            print "but we were expecting:"
+            for k in sorted(shell_args.keys()):
+                print k
+        self.failUnlessEqual(factory[1], shell_args)
+
+    def failUnlessExpectedDarcs(self, factory, **kwargs):
+        darcs_args = {'workdir': None,
+                      'alwaysUseLatest': False,
+                      'mode': 'update',
+                      'timeout': 1200,
+                      'retry': None,
+                      'baseURL': None,
+                      'defaultBranch': None,
+                      'logfiles': {},
+                      }
+        darcs_args.update(kwargs)
+        self.failUnlessIdentical(factory[0], Darcs)
+        if factory[1] != darcs_args:
+            print
+            print "factory had:"
+            for k in sorted(factory[1].keys()):
+                print k
+            print "but we were expecting:"
+            for k in sorted(darcs_args.keys()):
+                print k
+        self.failUnlessEqual(factory[1], darcs_args)
+
+    def testSteps(self):
+        m = BuildMaster(".")
+        m.loadConfig(cfg1)
+        b = m.botmaster.builders["builder1"]
+        steps = b.buildFactory.steps
+        self.failUnlessEqual(len(steps), 4)
+
+        self.failUnlessExpectedShell(steps[0], command="echo yes")
+        self.failUnlessExpectedShell(steps[1], defaults=False,
+                                     command="old-style")
+        self.failUnlessExpectedDarcs(steps[2],
+                                     repourl="http://buildbot.net/repos/trunk")
+        self.failUnlessExpectedShell(steps[3], defaults=False,
+                                     command="echo old-style")

Index: test_properties.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_properties.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- test_properties.py	11 Dec 2006 08:23:29 -0000	1.6
+++ test_properties.py	18 Jun 2007 02:52:49 -0000	1.7
@@ -50,11 +50,12 @@
     def testWithProperties(self):
         self.build.setProperty("revision", 47)
         self.failUnlessEqual(self.build_status.getProperty("revision"), 47)
-        c = ShellCommand(workdir=dir, build=self.build,
+        c = ShellCommand(workdir=dir,
                          command=["tar", "czf",
                                   WithProperties("build-%s.tar.gz",
                                                  "revision"),
                                   "source"])
+        c.setBuild(self.build)
         cmd = c._interpolateProperties(c.command)
         self.failUnlessEqual(cmd,
                              ["tar", "czf", "build-47.tar.gz", "source"])
@@ -62,55 +63,61 @@
     def testWithPropertiesDict(self):
         self.build.setProperty("other", "foo")
         self.build.setProperty("missing", None)
-        c = ShellCommand(workdir=dir, build=self.build,
+        c = ShellCommand(workdir=dir,
                          command=["tar", "czf",
                                   WithProperties("build-%(other)s.tar.gz"),
                                   "source"])
+        c.setBuild(self.build)
         cmd = c._interpolateProperties(c.command)
         self.failUnlessEqual(cmd,
                              ["tar", "czf", "build-foo.tar.gz", "source"])
 
     def testWithPropertiesEmpty(self):
         self.build.setProperty("empty", None)
-        c = ShellCommand(workdir=dir, build=self.build,
+        c = ShellCommand(workdir=dir,
                          command=["tar", "czf",
                                   WithProperties("build-%(empty)s.tar.gz"),
                                   "source"])
+        c.setBuild(self.build)
         cmd = c._interpolateProperties(c.command)
         self.failUnlessEqual(cmd,
                              ["tar", "czf", "build-.tar.gz", "source"])
 
     def testCustomBuildStep(self):
-        c = MyBuildStep(workdir=dir, build=self.build)
+        c = MyBuildStep(workdir=dir)
+        c.setBuild(self.build)
         cmd = c._interpolateProperties(c.command)
         self.failUnlessEqual(cmd,
                              ["tar", "czf", "build-1234.tar.gz", "source"])
 
     def testSourceStamp(self):
-        c = ShellCommand(workdir=dir, build=self.build,
+        c = ShellCommand(workdir=dir,
                          command=["touch",
                                   WithProperties("%s-dir", "branch"),
                                   WithProperties("%s-rev", "revision"),
                                   ])
+        c.setBuild(self.build)
         cmd = c._interpolateProperties(c.command)
         self.failUnlessEqual(cmd,
                              ["touch", "branch2-dir", "1234-rev"])
 
     def testSlaveName(self):
-        c = ShellCommand(workdir=dir, build=self.build,
+        c = ShellCommand(workdir=dir,
                          command=["touch",
                                   WithProperties("%s-slave", "slavename"),
                                   ])
+        c.setBuild(self.build)
         cmd = c._interpolateProperties(c.command)
         self.failUnlessEqual(cmd,
                              ["touch", "bot12-slave"])
 
     def testBuildNumber(self):
-        c = ShellCommand(workdir=dir, build=self.build,
+        c = ShellCommand(workdir=dir,
                          command=["touch",
                                   WithProperties("build-%d", "buildnumber"),
                                   WithProperties("builder-%s", "buildername"),
                                   ])
+        c.setBuild(self.build)
         cmd = c._interpolateProperties(c.command)
         self.failUnlessEqual(cmd,
                              ["touch", "build-5", "builder-fakebuilder"])

Index: test_steps.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_steps.py,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- test_steps.py	7 Feb 2007 04:25:29 -0000	1.38
+++ test_steps.py	18 Jun 2007 02:52:49 -0000	1.39
@@ -98,8 +98,8 @@
         dir = "murkle"
         self.expectedEvents = []
         buildstep.RemoteCommand.commandCounter[0] = 3
-        c = MyShellCommand(workdir=dir, command=cmd, build=self.build,
-                           timeout=10)
+        c = MyShellCommand(workdir=dir, command=cmd, timeout=10)
+        c.setBuild(self.build)
         self.assertEqual(self.remote.events, self.expectedEvents)
         c.step_status = self.build_status.addStepWithName("myshellcommand")
         d = c.startStep(self.remote)

Index: test_vc.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_vc.py,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- test_vc.py	7 Feb 2007 04:25:29 -0000	1.73
+++ test_vc.py	18 Jun 2007 02:52:49 -0000	1.74
@@ -2484,7 +2484,8 @@
     def testCVS1(self):
         r = base.BuildRequest("forced build", SourceStamp())
         b = base.Build([r])
-        s = source.CVS(cvsroot=None, cvsmodule=None, workdir=None, build=b)
+        s = source.CVS(cvsroot=None, cvsmodule=None)
+        s.setBuild(b)
         self.failUnlessEqual(s.computeSourceRevision(b.allChanges()), None)
 
     def testCVS2(self):
@@ -2496,7 +2497,8 @@
         submitted = "Wed, 08 Sep 2004 09:04:00 -0700"
         r.submittedAt = mktime_tz(parsedate_tz(submitted))
         b = base.Build([r])
-        s = source.CVS(cvsroot=None, cvsmodule=None, workdir=None, build=b)
+        s = source.CVS(cvsroot=None, cvsmodule=None)
+        s.setBuild(b)
         self.failUnlessEqual(s.computeSourceRevision(b.allChanges()),
                              "Wed, 08 Sep 2004 16:03:00 -0000")
 
@@ -2509,8 +2511,8 @@
         submitted = "Wed, 08 Sep 2004 09:04:00 -0700"
         r.submittedAt = mktime_tz(parsedate_tz(submitted))
         b = base.Build([r])
-        s = source.CVS(cvsroot=None, cvsmodule=None, workdir=None, build=b,
-                       checkoutDelay=10)
+        s = source.CVS(cvsroot=None, cvsmodule=None, checkoutDelay=10)
+        s.setBuild(b)
         self.failUnlessEqual(s.computeSourceRevision(b.allChanges()),
                              "Wed, 08 Sep 2004 16:02:10 -0000")
 
@@ -2530,14 +2532,16 @@
         r2.submittedAt = mktime_tz(parsedate_tz(submitted))
 
         b = base.Build([r1, r2])
-        s = source.CVS(cvsroot=None, cvsmodule=None, workdir=None, build=b)
+        s = source.CVS(cvsroot=None, cvsmodule=None)
+        s.setBuild(b)
         self.failUnlessEqual(s.computeSourceRevision(b.allChanges()),
                              "Wed, 08 Sep 2004 16:06:00 -0000")
 
     def testSVN1(self):
         r = base.BuildRequest("forced", SourceStamp())
         b = base.Build([r])
-        s = source.SVN(svnurl="dummy", workdir=None, build=b)
+        s = source.SVN(svnurl="dummy")
+        s.setBuild(b)
         self.failUnlessEqual(s.computeSourceRevision(b.allChanges()), None)
 
     def testSVN2(self):
@@ -2547,7 +2551,8 @@
         c.append(self.makeChange(revision=67))
         r = base.BuildRequest("forced", SourceStamp(changes=c))
         b = base.Build([r])
-        s = source.SVN(svnurl="dummy", workdir=None, build=b)
+        s = source.SVN(svnurl="dummy")
+        s.setBuild(b)
         self.failUnlessEqual(s.computeSourceRevision(b.allChanges()), 67)
 
 class Patch(VCBase, unittest.TestCase):

Index: test_web.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_web.py,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- test_web.py	17 Apr 2007 06:38:51 -0000	1.43
+++ test_web.py	18 Jun 2007 02:52:49 -0000	1.44
@@ -412,7 +412,8 @@
         bs.setReason("reason")
         bs.buildStarted(build1)
 
-        step1 = BuildStep(build=build1, name="setup")
+        step1 = BuildStep(name="setup")
+        step1.setBuild(build1)
         bss = bs.addStepWithName("setup")
         step1.setStepStatus(bss)
         bss.stepStarted()





More information about the Commits mailing list