[Buildbot-commits] buildbot/buildbot/test test_scheduler.py,1.1,1.2
Brian Warner
warner at users.sourceforge.net
Wed Aug 10 07:06:14 UTC 2005
Update of /cvsroot/buildbot/buildbot/buildbot/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26773/buildbot/test
Modified Files:
test_scheduler.py
Log Message:
Revision: arch at buildbot.sf.net--2004/buildbot--dev--0--patch-273
Creator: Brian Warner <warner at lothar.com>
implement Try_Jobdir, with a unit test
* buildbot/scheduler.py (Try_Jobdir): implement the jobdir style
of the TryScheduler, no buildsetID or status-tracking support yet
* buildbot/test/test_scheduler.py (Scheduling.testTryJobdir): test it
* buildbot/changes/maildir.py (Maildir.setBasedir): make it
possible to set the basedir after __init__ time, so it is easier
to use as a Service-child of the BuildMaster instance
* buildbot/changes/maildirtwisted.py (MaildirService): make a form
that delivers messages to its Service parent instead of requiring
a subclass to be useful. This turns out to be much easier to build
unit tests around.
* buildbot/scripts/tryclient.py (createJob): utility code to
create jobfiles, will eventually be used by 'buildbot try'
Index: test_scheduler.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_scheduler.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- test_scheduler.py 10 Aug 2005 04:52:41 -0000 1.1
+++ test_scheduler.py 10 Aug 2005 07:06:12 -0000 1.2
@@ -1,5 +1,7 @@
# -*- test-case-name: buildbot.test.test_scheduler -*-
+import os
+
from twisted.trial import unittest
from twisted.internet import defer, reactor
from twisted.application import service
@@ -7,10 +9,16 @@
from buildbot import scheduler
from buildbot.twcompat import maybeWait
from buildbot.changes.changes import Change
+from buildbot.scripts import tryclient
+
class FakeMaster(service.MultiService):
+ d = None
def submitBuildSet(self, bs):
self.sets.append(bs)
+ if self.d:
+ reactor.callLater(0, self.d.callback, bs)
+ self.d = None
class Scheduling(unittest.TestCase):
def setUp(self):
@@ -129,11 +137,55 @@
self.failUnlessEqual(s2.revision, None)
self.failUnlessEqual(len(s2.changes), 1)
self.failUnlessEqual(s2.patch, None)
-
+
+
+ def createMaildir(self, jobdir):
+ os.mkdir(jobdir)
+ os.mkdir(os.path.join(jobdir, "new"))
+ os.mkdir(os.path.join(jobdir, "cur"))
+ os.mkdir(os.path.join(jobdir, "tmp"))
+
+ jobcounter = 1
+ def pushJob(self, jobdir, job):
+ while 1:
+ filename = "job_%d" % self.jobcounter
+ self.jobcounter += 1
+ if os.path.exists(os.path.join(jobdir, "new", filename)):
+ continue
+ if os.path.exists(os.path.join(jobdir, "tmp", filename)):
+ continue
+ if os.path.exists(os.path.join(jobdir, "cur", filename)):
+ continue
+ break
+ f = open(os.path.join(jobdir, "tmp", filename), "w")
+ f.write(job)
+ f.close()
+ os.rename(os.path.join(jobdir, "tmp", filename),
+ os.path.join(jobdir, "new", filename))
+
def testTryJobdir(self):
- raise unittest.SkipTest("not yet implemented")
- s = scheduler.Try_Jobdir("try1", ["a", "b"], "jobdir1")
+ self.master.basedir = "try_jobdir"
+ os.mkdir(self.master.basedir)
+ jobdir = "jobdir1"
+ jobdir_abs = os.path.join(self.master.basedir, jobdir)
+ self.createMaildir(jobdir_abs)
+ s = scheduler.Try_Jobdir("try1", ["a", "b"], jobdir)
self.addScheduler(s)
+ self.failIf(self.master.sets)
+ job1 = tryclient.createJob("buildsetID",
+ "branch1", "123", 1, "patch",
+ ["a", "b"])
+ self.master.d = d = defer.Deferred()
+ self.pushJob(jobdir_abs, job1)
+ d.addCallback(self._testTryJobdir_1)
+ return maybeWait(d, 5)
+ testTryJobdir.timeout = 5
+ def _testTryJobdir_1(self, bs):
+ self.failUnlessEqual(bs.builderNames, ["a", "b"])
+ self.failUnlessEqual(bs.source.branch, "branch1")
+ self.failUnlessEqual(bs.source.revision, "123")
+ self.failUnlessEqual(bs.source.patch, (1, "patch"))
+
def testTryUserpass(self):
raise unittest.SkipTest("not yet implemented")
More information about the Commits
mailing list