[Buildbot-commits] buildbot/buildbot/test test_scheduler.py,1.6,1.7

Brian Warner warner at users.sourceforge.net
Fri Nov 25 23:26:37 UTC 2005


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

Modified Files:
	test_scheduler.py 
Log Message:
Revision: arch at buildbot.sf.net--2004/buildbot--dev--0--patch-436
Creator:  Brian Warner <warner at lothar.com>

fix AnyBranchScheduler when fileIsImportant=None

	* buildbot/scheduler.py (Scheduler): change fileIsImportant
	handling: treat self.fileIsImportant more as an attribute that
	contains a callable than as a method. If the attribute is None,
	don't call it and assume all filenames are important. It is still
	possible to provide a fileIsImportant method in a subclass,
	however.
	(AnyBranchScheduler): handle fileIsImportant=None, previously it
	was broken
	* buildbot/test/test_scheduler.py (Scheduling.testAnyBranch2):
	test using AnyBranchScheduler with fileIsImportant=None


Index: test_scheduler.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_scheduler.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- test_scheduler.py	14 Oct 2005 19:42:39 -0000	1.6
+++ test_scheduler.py	25 Nov 2005 23:26:35 -0000	1.7
@@ -89,7 +89,7 @@
 
 
     def testAnyBranch(self):
-        s = scheduler.AnyBranchScheduler("b1", None, 2, ["a","b"],
+        s = scheduler.AnyBranchScheduler("b1", None, 1, ["a","b"],
                                          fileIsImportant=self.isImportant)
         self.addScheduler(s)
 
@@ -107,7 +107,7 @@
         s.addChange(c4)
 
         d = defer.Deferred()
-        reactor.callLater(4, d.callback, None)
+        reactor.callLater(2, d.callback, None)
         d.addCallback(self._testAnyBranch_1)
         return maybeWait(d)
     def _testAnyBranch_1(self, res):
@@ -126,6 +126,42 @@
         self.failUnlessEqual(len(s2.changes), 1)
         self.failUnlessEqual(s2.patch, None)
 
+    def testAnyBranch2(self):
+        # like testAnyBranch but without fileIsImportant
+        s = scheduler.AnyBranchScheduler("b1", None, 2, ["a","b"])
+        self.addScheduler(s)
+        c1 = Change("alice", ["important", "not important"], "some changes",
+                    branch="branch1")
+        s.addChange(c1)
+        c2 = Change("bob", ["not important", "boring"], "some more changes",
+                    branch="branch1")
+        s.addChange(c2)
+        c3 = Change("carol", ["important", "dull"], "even more changes",
+                    branch="branch1")
+        s.addChange(c3)
+
+        c4 = Change("carol", ["important"], "other branch", branch="branch2")
+        s.addChange(c4)
+        d = defer.Deferred()
+        reactor.callLater(2, d.callback, None)
+        d.addCallback(self._testAnyBranch2_1)
+        return maybeWait(d)
+    def _testAnyBranch2_1(self, res):
+        self.failUnlessEqual(len(self.master.sets), 2)
+        self.master.sets.sort(lambda a,b: cmp(a.source.branch,
+                                              b.source.branch))
+        s1 = self.master.sets[0].source
+        self.failUnlessEqual(s1.branch, "branch1")
+        self.failUnlessEqual(s1.revision, None)
+        self.failUnlessEqual(len(s1.changes), 3)
+        self.failUnlessEqual(s1.patch, None)
+
+        s2 = self.master.sets[1].source
+        self.failUnlessEqual(s2.branch, "branch2")
+        self.failUnlessEqual(s2.revision, None)
+        self.failUnlessEqual(len(s2.changes), 1)
+        self.failUnlessEqual(s2.patch, None)
+
 
     def createMaildir(self, jobdir):
         os.mkdir(jobdir)





More information about the Commits mailing list