diff options
author | Daniel Dunbar <daniel@zuster.org> | 2016-06-02 23:32:35 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2016-06-02 23:32:35 +0000 |
commit | c2708c86628c51ce1910a8493ef5b16adb723374 (patch) | |
tree | 77bcb6976cb01988206fb0987c3cbc1ee31c60ce /llvm/utils/lit | |
parent | 87383633392e9363820305f11b1f2de0a4c79087 (diff) | |
download | bcm5719-llvm-c2708c86628c51ce1910a8493ef5b16adb723374.tar.gz bcm5719-llvm-c2708c86628c51ce1910a8493ef5b16adb723374.zip |
[lit] Factor out a helper for shell command results.
llvm-svn: 271608
Diffstat (limited to 'llvm/utils/lit')
-rw-r--r-- | llvm/utils/lit/lit/TestRunner.py | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py index 3f02420572a..e4bc48daa7f 100644 --- a/llvm/utils/lit/lit/TestRunner.py +++ b/llvm/utils/lit/lit/TestRunner.py @@ -110,6 +110,16 @@ class TimeoutHelper(object): self._procs = [] # Python2 doesn't have list.clear() self._doneKillPass = True +class ShellCommandResult(object): + """Captures the result of an individual command.""" + + def __init__(self, command, stdout, stderr, exitCode, timeoutReached): + self.command = command + self.stdout = stdout + self.stderr = stderr + self.exitCode = exitCode + self.timeoutReached = timeoutReached + def executeShCmd(cmd, shenv, results, timeout=0): """ Wrapper around _executeShCmd that handles @@ -377,7 +387,8 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper): except: err = str(err) - results.append((cmd.commands[i], out, err, res, timeoutHelper.timeoutReached())) + results.append(ShellCommandResult( + cmd.commands[i], out, err, res, timeoutHelper.timeoutReached())) if cmd.pipe_err: # Python treats the exit code as a signed char. if exitCode is None: @@ -422,16 +433,19 @@ def executeScriptInternal(test, litConfig, tmpBase, commands, cwd): except InternalShellError: e = sys.exc_info()[1] exitCode = 127 - results.append((e.command, '', e.message, exitCode, False)) + results.append( + ShellCommandResult(e.command, '', e.message, exitCode, False)) out = err = '' - for i,(cmd, cmd_out, cmd_err, res, timeoutReached) in enumerate(results): - out += 'Command %d: %s\n' % (i, ' '.join('"%s"' % s for s in cmd.args)) - out += 'Command %d Result: %r\n' % (i, res) + for i,result in enumerate(results): + out += 'Command %d: %s\n' % (i, ' '.join('"%s"' % s + for s in result.command.args)) + out += 'Command %d Result: %r\n' % (i, result.exitCode) if litConfig.maxIndividualTestTime > 0: - out += 'Command %d Reached Timeout: %s\n\n' % (i, str(timeoutReached)) - out += 'Command %d Output:\n%s\n\n' % (i, cmd_out) - out += 'Command %d Stderr:\n%s\n\n' % (i, cmd_err) + out += 'Command %d Reached Timeout: %s\n\n' % ( + i, str(result.timeoutReached)) + out += 'Command %d Output:\n%s\n\n' % (i, result.stdout) + out += 'Command %d Stderr:\n%s\n\n' % (i, result.stderr) return out, err, exitCode, timeoutInfo |