[Buildbot-commits] buildbot/buildbot/test test_config.py,1.13,1.14

Brian Warner warner at users.sourceforge.net
Sat Apr 23 10:22:13 UTC 2005


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

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

clean up ChangeSource handling

2005-04-23  Brian Warner  <warner at lothar.com>

   * buildbot/changes/changes.py: import defer, oops
   (ChangeMaster): remove the .sources list, rely upon the fact that
   MultiServices can be treated as sequences of their children. This
   cleans up the add/remove ChangeSource routines a lot, as we keep
   exactly one list of the current sources instead of three.

   * buildbot/master.py (BuildMaster.__init__): remove .sources, set
   up an empty ChangeMaster at init time.
   (BuildMaster.loadChanges): if there are changes to be had from
   disk, replace self.change_svc with the new ones. If not, keep
   using the empty ChangeMaster set up in __init__.
   (BuildMaster.loadConfig_Sources): use list(self.change_svc)
   instead of a separate list, makes the code a bit cleaner.
   * buildbot/test/test_config.py (ConfigTest.testSimple): match it
   (ConfigTest.testSources): same, also wait for loadConfig to finish.
   Extend the test to make sure we can get rid of the sources when
   we're done.


Index: test_config.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_config.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- test_config.py	30 Sep 2004 23:03:52 -0000	1.13
+++ test_config.py	23 Apr 2005 10:22:11 -0000	1.14
@@ -4,6 +4,7 @@
 import os, os.path
 
 from twisted.trial import unittest
+dr = unittest.deferredResult
 from twisted.python import components
 
 try:
@@ -487,8 +488,7 @@
         # hasn't been started running
         self.failUnlessEqual(master.slavePortnum, 9999)
         self.checkPorts(master, [(9999, pb.PBServerFactory)])
-        self.failUnlessEqual(master.sources, [])
-        self.failUnlessEqual(master.change_svc.sources, [])
+        self.failUnlessEqual(list(master.change_svc), [])
         self.failUnlessEqual(master.botmaster.builders, {})
         self.failUnlessEqual(master.botmaster.interlocks, {})
         self.failUnlessEqual(master.checker.users,
@@ -547,23 +547,31 @@
         master = self.buildmaster
         master.loadChanges()
         master.loadConfig(emptyCfg)
-        self.failUnlessEqual(master.sources, [])
-        self.failUnlessEqual(master.change_svc.sources, [])
+        self.failUnlessEqual(list(master.change_svc), [])
 
-        master.loadConfig(sourcesCfg)
-        self.failUnlessEqual(len(master.sources), 1)
-        self.failUnlessEqual(len(master.change_svc.sources), 1)
-        s1 = master.change_svc.sources[0]
+        d = master.loadConfig(sourcesCfg)
+        dr(d)
+        self.failUnlessEqual(len(list(master.change_svc)), 1)
+        s1 = list(master.change_svc)[0]
         self.failUnless(isinstance(s1, FreshCVSSource))
         self.failUnlessEqual(s1.where, ("cvs.example.com", 1000))
         self.failUnlessEqual(s1.prefix, "Prefix/")
-        self.failUnlessEqual(s1, master.sources[0])
+        self.failUnlessEqual(s1, list(master.change_svc)[0])
+        self.failUnless(s1.parent)
 
         # verify that unchanged sources are not interrupted
-        master.loadConfig(sourcesCfg)
-        self.failUnlessEqual(len(master.change_svc.sources), 1)
-        s2 = master.change_svc.sources[0]
+        d = master.loadConfig(sourcesCfg)
+        dr(d)
+        self.failUnlessEqual(len(list(master.change_svc)), 1)
+        s2 = list(master.change_svc)[0]
         self.failUnlessIdentical(s1, s2)
+        self.failUnless(s1.parent)
+
+        # make sure we can get rid of the sources too
+        d = master.loadConfig(emptyCfg)
+        dr(d)
+        self.failUnlessEqual(list(master.change_svc), [])
+
 
     def testBuilders(self):
         master = self.buildmaster





More information about the Commits mailing list