[Buildbot-commits] buildbot/buildbot/test test_run.py,1.52,1.53

Brian Warner warner at users.sourceforge.net
Thu Mar 20 17:43:11 UTC 2008


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

Modified Files:
	test_run.py 
Log Message:
[project @ #56:trigger.patch]
Schedulers that can be triggered by buildsteps, allowing more
fine-grained control than Dependent schedulers.

Original author: dustin at v.igoro.us
Date: 2008-02-17 04:49:06+00:00

Index: test_run.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_run.py,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- test_run.py	18 Mar 2008 21:41:24 -0000	1.52
+++ test_run.py	20 Mar 2008 17:43:09 -0000	1.53
@@ -628,6 +628,77 @@
         d = self.master.loadConfig(config_4_newbuilder)
         return d
 
+class Triggers(RunMixin, TestFlagMixin, unittest.TestCase):
+    config_trigger = config_base + """
+from buildbot.scheduler import Triggerable, Scheduler
+from buildbot.steps.trigger import Trigger
+from buildbot.steps.dummy import Dummy
+from buildbot.test.runutils import SetTestFlagStep
+c['schedulers'] = [
+    Scheduler('triggerer', None, 0.1, ['triggerer']),
+    Triggerable('triggeree', ['triggeree'])
+]
+triggerer = factory.BuildFactory([
+    s(SetTestFlagStep, flagname='triggerer_started'),
+    s(Trigger, flunkOnFailure=True, @ARGS@),
+    s(SetTestFlagStep, flagname='triggerer_finished'),
+    ])
+triggeree = factory.BuildFactory([
+    s(SetTestFlagStep, flagname='triggeree_started'),
+    s(@DUMMYCLASS@),
+    s(SetTestFlagStep, flagname='triggeree_finished'),
+    ])
+c['builders'] = [{'name': 'triggerer', 'slavename': 'bot1',
+                  'builddir': 'triggerer', 'factory': triggerer},
+                 {'name': 'triggeree', 'slavename': 'bot1',
+                  'builddir': 'triggeree', 'factory': triggeree}]
+"""
+
+    def mkConfig(self, args, dummyclass="Dummy"):
+        return self.config_trigger.replace("@ARGS@", args).replace("@DUMMYCLASS@", dummyclass)
+
+    def setupTest(self, args, dummyclass, checkFn):
+        self.clearFlags()
+        m = self.master
+        m.loadConfig(self.mkConfig(args, dummyclass))
+        m.readConfig = True
+        m.startService()
+
+        c = changes.Change("bob", ["Makefile", "foo/bar.c"], "changed stuff")
+        m.change_svc.addChange(c)
+
+        d = self.connectSlave(builders=['triggerer', 'triggeree'])
+        d.addCallback(self.startTimer, 0.5, checkFn)
+        return d
+
+    def startTimer(self, res, time, next_fn):
+        d = defer.Deferred()
+        reactor.callLater(time, d.callback, None)
+        d.addCallback(next_fn)
+        return d
+
+    def testTriggerBuild(self):
+        return self.setupTest("schedulers=['triggeree']",
+                "Dummy",
+                self._checkTriggerBuild)
+
+    def _checkTriggerBuild(self, res):
+        self.failIfFlagNotSet('triggerer_started')
+        self.failIfFlagNotSet('triggeree_started')
+        self.failIfFlagSet('triggeree_finished')
+        self.failIfFlagNotSet('triggerer_finished')
+
+    def testTriggerBuildWait(self):
+        return self.setupTest("schedulers=['triggeree'], waitForFinish=1",
+                "Dummy",
+                self._checkTriggerBuildWait)
+
+    def _checkTriggerBuildWait(self, res):
+        self.failIfFlagNotSet('triggerer_started')
+        self.failIfFlagNotSet('triggeree_started')
+        self.failIfFlagSet('triggeree_finished')
+        self.failIfFlagSet('triggerer_finished')
+
 config_test_flag = config_base + """
 from buildbot.scheduler import Scheduler
 c['schedulers'] = [Scheduler('quick', None, 0.1, ['dummy'])]





More information about the Commits mailing list