diff --git a/master/buildbot/process/buildstep.py b/master/buildbot/process/buildstep.py index df76efa5337..2a3c8c84dad 100644 --- a/master/buildbot/process/buildstep.py +++ b/master/buildbot/process/buildstep.py @@ -43,11 +43,12 @@ class RemoteCommand(pb.Referenceable): debug = False def __init__(self, remote_command, args, ignore_updates=False, - collectStdout=False, decodeRC={0:SUCCESS}): + collectStdout=False, collectStderr=False, decodeRC={0:SUCCESS}): self.logs = {} self.delayedLogs = {} self._closeWhenFinished = {} self.collectStdout = collectStdout + self.collectStderr = collectStderr self.stdout = '' self._startTime = None @@ -206,6 +207,8 @@ def addStdout(self, data): def addStderr(self, data): if 'stdio' in self.logs: self.logs['stdio'].addStderr(data) + if self.collectStderr: + self.stderr += data def addHeader(self, data): if 'stdio' in self.logs: @@ -354,7 +357,8 @@ def __init__(self, workdir, command, env=None, want_stdout=1, want_stderr=1, timeout=20*60, maxTime=None, logfiles={}, usePTY="slave-config", logEnviron=True, - collectStdout=False, interruptSignal=None, + collectStdout=False,collectStderr=False, + interruptSignal=None, initialStdin=None, decodeRC={0:SUCCESS}): self.command = command # stash .command, set it later @@ -377,7 +381,8 @@ def __init__(self, workdir, command, env=None, if interruptSignal is not None: args['interruptSignal'] = interruptSignal RemoteCommand.__init__(self, "shell", args, collectStdout=collectStdout, - decodeRC=decodeRC) + collectStderr=collectStderr, + decodeRC=decodeRC) def _start(self): self.args['command'] = self.command diff --git a/master/buildbot/test/fake/remotecommand.py b/master/buildbot/test/fake/remotecommand.py index a9e9ae7ff8d..13ed80b31e2 100644 --- a/master/buildbot/test/fake/remotecommand.py +++ b/master/buildbot/test/fake/remotecommand.py @@ -28,7 +28,7 @@ class FakeRemoteCommand(object): active = False def __init__(self, remote_command, args, - ignore_updates=False, collectStdout=False, decodeRC={0:SUCCESS}): + ignore_updates=False, collectStdout=False, collectStderr=False, decodeRC={0:SUCCESS}): # copy the args and set a few defaults self.remote_command = remote_command self.args = args.copy() @@ -36,10 +36,13 @@ def __init__(self, remote_command, args, self.delayedLogs = {} self.rc = -999 self.collectStdout = collectStdout + self.collectStderr = collectStderr self.updates = {} self.decodeRC = decodeRC if collectStdout: self.stdout = '' + if collectStderr: + self.stderr = '' def run(self, step, remote): # delegate back to the test case @@ -76,6 +79,7 @@ def __init__(self, workdir, command, env=None, want_stdout=1, want_stderr=1, timeout=20*60, maxTime=None, logfiles={}, usePTY="slave-config", logEnviron=True, collectStdout=False, + collectStderr=False, interruptSignal=None, initialStdin=None, decodeRC={0:SUCCESS}): args = dict(workdir=workdir, command=command, env=env or {}, want_stdout=want_stdout, want_stderr=want_stderr, @@ -83,7 +87,9 @@ def __init__(self, workdir, command, env=None, timeout=timeout, maxTime=maxTime, logfiles=logfiles, usePTY=usePTY, logEnviron=logEnviron) FakeRemoteCommand.__init__(self, "shell", args, - collectStdout=collectStdout, decodeRC=decodeRC) + collectStdout=collectStdout, + collectStderr=collectStderr, + decodeRC=decodeRC) class FakeLogFile(object): @@ -247,6 +253,8 @@ def runBehavior(self, behavior, args, command): command.stdout += streams['stdout'] if 'stderr' in streams: command.logs[name].addStderr(streams['stderr']) + if command.collectStderr: + command.stderr += streams['stderr'] elif behavior == 'callable': return defer.maybeDeferred(lambda : args[0](command)) else: