Package buildbot :: Package steps :: Module dummy
[frames] | no frames]

Source Code for Module buildbot.steps.dummy

  1  # This file is part of Buildbot.  Buildbot is free software: you can 
  2  # redistribute it and/or modify it under the terms of the GNU General Public 
  3  # License as published by the Free Software Foundation, version 2. 
  4  # 
  5  # This program is distributed in the hope that it will be useful, but WITHOUT 
  6  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
  7  # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
  8  # details. 
  9  # 
 10  # You should have received a copy of the GNU General Public License along with 
 11  # this program; if not, write to the Free Software Foundation, Inc., 51 
 12  # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
 13  # 
 14  # Copyright Buildbot Team Members 
 15   
 16   
 17  from twisted.internet import reactor 
 18  from buildbot.process.buildstep import BuildStep, LoggingBuildStep 
 19  from buildbot.process.buildstep import LoggedRemoteCommand 
 20  from buildbot.status.builder import SUCCESS, FAILURE 
 21   
 22  # these classes are used internally by buildbot unit tests 
 23   
24 -class Dummy(BuildStep):
25 """I am a dummy no-op step, which runs entirely on the master, and simply 26 waits 5 seconds before finishing with SUCCESS 27 """ 28 29 haltOnFailure = True 30 flunkOnFailure = True 31 name = "dummy" 32
33 - def __init__(self, timeout=5, **kwargs):
34 """ 35 @type timeout: int 36 @param timeout: the number of seconds to delay before completing 37 """ 38 BuildStep.__init__(self, **kwargs) 39 self.addFactoryArguments(timeout=timeout) 40 self.timeout = timeout 41 self.timer = None
42
43 - def start(self):
44 self.step_status.setText(["delay", "%s secs" % self.timeout]) 45 self.timer = reactor.callLater(self.timeout, self.done)
46
47 - def interrupt(self, reason):
48 if self.timer: 49 self.timer.cancel() 50 self.timer = None 51 self.step_status.setText(["delay", "interrupted"]) 52 self.finished(FAILURE)
53
54 - def done(self):
55 self.finished(SUCCESS)
56
57 -class FailingDummy(Dummy):
58 """I am a dummy no-op step that 'runs' master-side and finishes (with a 59 FAILURE status) after 5 seconds.""" 60 61 name = "failing dummy" 62
63 - def start(self):
64 self.step_status.setText(["boom", "%s secs" % self.timeout]) 65 self.timer = reactor.callLater(self.timeout, self.done)
66
67 - def done(self):
68 self.finished(FAILURE)
69
70 -class RemoteDummy(LoggingBuildStep):
71 """I am a dummy no-op step that runs on the remote side and 72 simply waits 5 seconds before completing with success. 73 See L{buildbot.slave.commands.DummyCommand} 74 """ 75 76 haltOnFailure = True 77 flunkOnFailure = True 78 name = "remote dummy" 79
80 - def __init__(self, timeout=5, **kwargs):
81 """ 82 @type timeout: int 83 @param timeout: the number of seconds to delay 84 """ 85 LoggingBuildStep.__init__(self, **kwargs) 86 self.addFactoryArguments(timeout=timeout) 87 self.timeout = timeout 88 self.description = ["remote", "delay", "%s secs" % timeout]
89
90 - def describe(self, done=False):
91 return self.description
92
93 - def start(self):
94 args = {'timeout': self.timeout} 95 cmd = LoggedRemoteCommand("dummy", args) 96 self.startCommand(cmd)
97
98 -class Wait(LoggingBuildStep):
99 """I start a command on the slave that waits for the unit test to 100 tell it when to finish. 101 """ 102 103 name = "wait"
104 - def __init__(self, handle, **kwargs):
105 LoggingBuildStep.__init__(self, **kwargs) 106 self.addFactoryArguments(handle=handle) 107 self.handle = handle
108
109 - def describe(self, done=False):
110 return ["wait: %s" % self.handle]
111
112 - def start(self):
113 args = {'handle': (self.handle, self.build.reason)} 114 cmd = LoggedRemoteCommand("dummy.wait", args) 115 self.startCommand(cmd)
116