[Buildbot-commits] buildbot/buildbot/process factory.py,1.11,1.12 process_twisted.py,1.41,1.42

Brian Warner warner at users.sourceforge.net
Fri Apr 7 04:11:00 UTC 2006


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

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

SF#1412605 : add BuildFactory.addStep

	* buildbot/process/factory.py (BuildFactory.addStep): new method
	to add steps to a BuildFactory. Use it instead of f.steps.append,
	and you can probably avoid using the s() convenience function.
	Patch from Neal Norwitz, sf.net #1412605.
	(other): update all factories to use addStep
	* buildbot/process/process_twisted.py: update all factories to use
	addStep.


Index: factory.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/process/factory.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- factory.py	5 Nov 2005 21:52:08 -0000	1.11
+++ factory.py	7 Apr 2006 04:10:56 -0000	1.12
@@ -4,6 +4,7 @@
 from buildbot.process.base import Build
 from buildbot.process import step
 
+# deprecated, use BuildFactory.addStep
 def s(steptype, **kwargs):
     # convenience function for master.cfg files, to create step
     # specification tuples
@@ -15,12 +16,12 @@
     @type  buildClass: L{buildbot.process.base.Build}
     """
     buildClass = Build
-    steps = []
     useProgress = 1
     compare_attrs = ['buildClass', 'steps', 'useProgress']
 
     def __init__(self, steps=None):
-        if steps is None: steps = []
+        if steps is None:
+            steps = []
         self.steps = steps
 
     def newBuild(self, request):
@@ -32,6 +33,9 @@
         b.setSteps(self.steps)
         return b
 
+    def addStep(self, steptype, **kwargs):
+        self.steps.append((steptype, kwargs))
+
 
 # BuildFactory subclasses for common build tools
 
@@ -43,8 +47,7 @@
                  test=["make", "check"]):
         assert type(source) is tuple
         assert issubclass(source[0], step.BuildStep)
-        self.steps = []
-        self.steps.append(source)
+        BuildFactory.__init__(self, [source])
         if configure is not None:
             # we either need to wind up with a string (which will be
             # space-split), or with a list of strings (which will not). The
@@ -58,35 +61,29 @@
             else:
                 assert type(configure) in (list, tuple)
                 command = configure + configureFlags
-            self.steps.append(s(step.Configure,
-                                command=command,
-                                env=configureEnv))
+            self.addStep(step.Configure, command=command, env=configureEnv)
         if compile is not None:
-            self.steps.append(s(step.Compile, command=compile))
+            self.addStep(step.Compile, command=compile)
         if test is not None:
-            self.steps.append(s(step.Test, command=test))
+            self.addStep(step.Test, command=test)
 
 class CPAN(BuildFactory):
     def __init__(self, source, perl="perl"):
         assert type(source) is tuple
         assert issubclass(source[0], step.BuildStep)
-        self.steps = []
-        self.steps.append(source)
-        self.steps.append(s(step.Configure,
-                            command=[perl, "Makefile.PL"]))
-        self.steps.append(s(step.Compile, command=["make"]))
-        self.steps.append(s(step.Test, command=["make", "test"]))
+        BuildFactory.__init__(self, [source])
+        self.addStep(step.Configure, command=[perl, "Makefile.PL"])
+        self.addStep(step.Compile, command=["make"])
+        self.addStep(step.Test, command=["make", "test"])
 
 class Distutils(BuildFactory):
     def __init__(self, source, python="python", test=None):
         assert type(source) is tuple
         assert issubclass(source[0], step.BuildStep)
-        self.steps = []
-        self.steps.append(source)
-        self.steps.append(s(step.Compile,
-                            command=[python, "./setup.py", "build"]))
+        BuildFactory.__init__(self, [source])
+        self.addStep(step.Compile, command=[python, "./setup.py", "build"])
         if test is not None:
-            self.steps.append(s(step.Test, command=test))
+            self.addStep(step.Test, command=test)
 
 class Trial(BuildFactory):
     """Build a python module that uses distutils and trial. Set 'tests' to
@@ -107,6 +104,7 @@
                  buildpython=["python"], trialpython=[], trial=None,
                  testpath=".", randomly=None, recurse=None,
                  tests=None,  useTestCaseNames=False, env=None):
+        BuildFactory.__init__(self, [source])
         assert type(source) is tuple
         assert issubclass(source[0], step.BuildStep)
         assert tests or useTestCaseNames, "must use one or the other"
@@ -118,18 +116,16 @@
             self.recurse = recurse
 
         from buildbot.process import step_twisted
-        self.steps = []
-        self.steps.append(source)
         buildcommand = buildpython + ["./setup.py", "build"]
-        self.steps.append(s(step.Compile, command=buildcommand, env=env))
-        self.steps.append(s(step_twisted.Trial,
-                            python=trialpython, trial=self.trial,
-                            testpath=testpath,
-                            tests=tests, testChanges=useTestCaseNames,
-                            randomly=self.randomly,
-                            recurse=self.recurse,
-                            env=env,
-                            ))
+        self.addStep(step.Compile, command=buildcommand, env=env)
+        self.addStep(step_twisted.Trial,
+                     python=trialpython, trial=self.trial,
+                     testpath=testpath,
+                     tests=tests, testChanges=useTestCaseNames,
+                     randomly=self.randomly,
+                     recurse=self.recurse,
+                     env=env,
+                     )
 
 
 # compatibility classes, will go away. Note that these only offer

Index: process_twisted.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/process/process_twisted.py,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- process_twisted.py	26 Oct 2005 20:38:07 -0000	1.41
+++ process_twisted.py	7 Apr 2006 04:10:57 -0000	1.42
@@ -3,7 +3,7 @@
 # Build classes specific to the Twisted codebase
 
 from buildbot.process.base import Build
-from buildbot.process.factory import BuildFactory, s
+from buildbot.process.factory import BuildFactory
 from buildbot.process import step
 from buildbot.process.step_twisted import HLint, ProcessDocs, BuildDebs, \
      Trial, RemovePYCs
@@ -32,29 +32,23 @@
     # this to add the local tree to PYTHONPATH during tests
     workdir = "Twisted"
 
-    def __init__(self, svnurl, steps):
-        self.steps = []
-        self.steps.append(s(step.SVN, svnurl=svnurl, mode=self.mode))
-        self.steps.extend(steps)
+    def __init__(self, source):
+        BuildFactory.__init__(self, [source])
 
 class QuickTwistedBuildFactory(TwistedBaseFactory):
     treeStableTimer = 30
     useProgress = 0
 
     def __init__(self, source, python="python"):
+        TwistedBuildFactory.__init__(self, source)
         if type(python) is str:
             python = [python]
-        self.steps = []
-        self.steps.append(source)
-        self.steps.append(s(HLint, python=python[0]))
-        self.steps.append(s(RemovePYCs))
+        self.addStep(HLint, python=python[0])
+        self.addStep(RemovePYCs)
         for p in python:
             cmd = [p, "setup.py", "all", "build_ext", "-i"]
-            self.steps.append(s(step.Compile, command=cmd,
-                                flunkOnFailure=True))
-            self.steps.append(s(TwistedTrial,
-                                python=p, # can be a list
-                                testChanges=True))
+            self.addStep(step.Compile, command=cmd, flunkOnFailure=True)
+            self.addStep(TwistedTrial, python=p, testChanges=True)
 
 class FullTwistedBuildFactory(TwistedBaseFactory):
     treeStableTimer = 5*60
@@ -62,10 +56,9 @@
     def __init__(self, source, python="python",
                  processDocs=False, runTestsRandomly=False,
                  compileOpts=[], compileOpts2=[]):
-        self.steps = []
-        self.steps.append(source)
+        TwistedBuildFactory.__init__(self, source)
         if processDocs:
-            self.steps.append(s(ProcessDocs))
+            self.addStep(ProcessDocs)
 
         if type(python) == str:
             python = [python]
@@ -74,19 +67,17 @@
         cmd = (python + compileOpts + ["setup.py", "all", "build_ext"]
                + compileOpts2 + ["-i"])
 
-        self.steps.append(s(step.Compile, command=cmd, flunkOnFailure=True))
-        self.steps.append(s(RemovePYCs))
-        self.steps.append(s(TwistedTrial, python=python,
-                            randomly=runTestsRandomly))
+        self.addStep(step.Compile, command=cmd, flunkOnFailure=True)
+        self.addStep(RemovePYCs)
+        self.addStep(TwistedTrial, python=python, randomly=runTestsRandomly)
 
 class TwistedDebsBuildFactory(TwistedBaseFactory):
     treeStableTimer = 10*60
 
     def __init__(self, source, python="python"):
-        self.steps = []
-        self.steps.append(source)
-        self.steps.append(s(ProcessDocs, haltOnFailure=True))
-        self.steps.append(s(BuildDebs, warnOnWarnings=True))
+        TwistedBuildFactory.__init__(self, source)
+        self.addStep(ProcessDocs, haltOnFailure=True)
+        self.addStep(BuildDebs, warnOnWarnings=True)
 
 class TwistedReactorsBuildFactory(TwistedBaseFactory):
     treeStableTimer = 5*60
@@ -94,8 +85,7 @@
     def __init__(self, source,
                  python="python", compileOpts=[], compileOpts2=[],
                  reactors=None):
-        self.steps = []
-        self.steps.append(source)
+        TwistedBuildFactory.__init__(self, source)
 
         if type(python) == str:
             python = [python]
@@ -104,7 +94,7 @@
         cmd = (python + compileOpts + ["setup.py", "all", "build_ext"]
                + compileOpts2 + ["-i"])
 
-        self.steps.append(s(step.Compile, command=cmd, warnOnFailure=True))
+        self.addStep(step.Compile, command=cmd, warnOnFailure=True)
 
         if reactors == None:
             reactors = [
@@ -123,8 +113,7 @@
             #    # these are buggy, so tolerate failures for now
             #    flunkOnFailure = 0
             #    warnOnFailure = 1
-            self.steps.append(s(RemovePYCs)) # TODO: why?
-            self.steps.append(s(TwistedTrial, name=reactor,
-                                python=python, reactor=reactor,
-                                flunkOnFailure=flunkOnFailure,
-                                warnOnFailure=warnOnFailure))
+            self.stepaddStep(RemovePYCs) # TODO: why?
+            self.addStep(TwistedTrial, name=reactor, python=python,
+                         reactor=reactor, flunkOnFailure=flunkOnFailure,
+                         warnOnFailure=warnOnFailure)





More information about the Commits mailing list