more NEWS items
[buildbot.git] / buildbot / steps / dummy.py
blobb27fc465fcf124f88e6c1449827156d2b9a6a0bd
2 from twisted.internet import reactor
3 from buildbot.process.buildstep import BuildStep, LoggingBuildStep
4 from buildbot.process.buildstep import LoggedRemoteCommand
5 from buildbot.status.builder import SUCCESS, FAILURE
7 # these classes are used internally by buildbot unit tests
9 class Dummy(BuildStep):
10 """I am a dummy no-op step, which runs entirely on the master, and simply
11 waits 5 seconds before finishing with SUCCESS
12 """
14 haltOnFailure = True
15 name = "dummy"
17 def __init__(self, timeout=5, **kwargs):
18 """
19 @type timeout: int
20 @param timeout: the number of seconds to delay before completing
21 """
22 BuildStep.__init__(self, **kwargs)
23 self.timeout = timeout
24 self.timer = None
26 def start(self):
27 self.step_status.setColor("yellow")
28 self.step_status.setText(["delay", "%s secs" % self.timeout])
29 self.timer = reactor.callLater(self.timeout, self.done)
31 def interrupt(self, reason):
32 if self.timer:
33 self.timer.cancel()
34 self.timer = None
35 self.step_status.setColor("red")
36 self.step_status.setText(["delay", "interrupted"])
37 self.finished(FAILURE)
39 def done(self):
40 self.step_status.setColor("green")
41 self.finished(SUCCESS)
43 class FailingDummy(Dummy):
44 """I am a dummy no-op step that 'runs' master-side and finishes (with a
45 FAILURE status) after 5 seconds."""
47 name = "failing dummy"
49 def start(self):
50 self.step_status.setColor("yellow")
51 self.step_status.setText(["boom", "%s secs" % self.timeout])
52 self.timer = reactor.callLater(self.timeout, self.done)
54 def done(self):
55 self.step_status.setColor("red")
56 self.finished(FAILURE)
58 class RemoteDummy(LoggingBuildStep):
59 """I am a dummy no-op step that runs on the remote side and
60 simply waits 5 seconds before completing with success.
61 See L{buildbot.slave.commands.DummyCommand}
62 """
64 haltOnFailure = True
65 name = "remote dummy"
67 def __init__(self, timeout=5, **kwargs):
68 """
69 @type timeout: int
70 @param timeout: the number of seconds to delay
71 """
72 LoggingBuildStep.__init__(self, **kwargs)
73 self.timeout = timeout
74 self.description = ["remote", "delay", "%s secs" % timeout]
76 def describe(self, done=False):
77 return self.description
79 def start(self):
80 args = {'timeout': self.timeout}
81 cmd = LoggedRemoteCommand("dummy", args)
82 self.startCommand(cmd)
84 class Wait(LoggingBuildStep):
85 """I start a command on the slave that waits for the unit test to
86 tell it when to finish.
87 """
89 name = "wait"
90 def __init__(self, handle, **kwargs):
91 LoggingBuildStep.__init__(self, **kwargs)
92 self.handle = handle
94 def describe(self, done=False):
95 return ["wait: %s" % self.handle]
97 def start(self):
98 args = {'handle': (self.handle, self.build.reason)}
99 cmd = LoggedRemoteCommand("dummy.wait", args)
100 self.startCommand(cmd)