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
18 def __init__(self
, timeout
=5, **kwargs
):
21 @param timeout: the number of seconds to delay before completing
23 BuildStep
.__init
__(self
, **kwargs
)
24 self
.addFactoryArguments(timeout
=timeout
)
25 self
.timeout
= timeout
29 self
.step_status
.setText(["delay", "%s secs" % self
.timeout
])
30 self
.timer
= reactor
.callLater(self
.timeout
, self
.done
)
32 def interrupt(self
, reason
):
36 self
.step_status
.setText(["delay", "interrupted"])
37 self
.finished(FAILURE
)
40 self
.finished(SUCCESS
)
42 class FailingDummy(Dummy
):
43 """I am a dummy no-op step that 'runs' master-side and finishes (with a
44 FAILURE status) after 5 seconds."""
46 name
= "failing dummy"
49 self
.step_status
.setText(["boom", "%s secs" % self
.timeout
])
50 self
.timer
= reactor
.callLater(self
.timeout
, self
.done
)
53 self
.finished(FAILURE
)
55 class RemoteDummy(LoggingBuildStep
):
56 """I am a dummy no-op step that runs on the remote side and
57 simply waits 5 seconds before completing with success.
58 See L{buildbot.slave.commands.DummyCommand}
65 def __init__(self
, timeout
=5, **kwargs
):
68 @param timeout: the number of seconds to delay
70 LoggingBuildStep
.__init
__(self
, **kwargs
)
71 self
.addFactoryArguments(timeout
=timeout
)
72 self
.timeout
= timeout
73 self
.description
= ["remote", "delay", "%s secs" % timeout
]
75 def describe(self
, done
=False):
76 return self
.description
79 args
= {'timeout': self
.timeout
}
80 cmd
= LoggedRemoteCommand("dummy", args
)
81 self
.startCommand(cmd
)
83 class Wait(LoggingBuildStep
):
84 """I start a command on the slave that waits for the unit test to
85 tell it when to finish.
89 def __init__(self
, handle
, **kwargs
):
90 LoggingBuildStep
.__init
__(self
, **kwargs
)
91 self
.addFactoryArguments(handle
=handle
)
94 def describe(self
, done
=False):
95 return ["wait: %s" % self
.handle
]
98 args
= {'handle': (self
.handle
, self
.build
.reason
)}
99 cmd
= LoggedRemoteCommand("dummy.wait", args
)
100 self
.startCommand(cmd
)