[PATCH] D81892: [lit] Provide consistent stdout and stderr in the internal shell
Louis Dionne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 15 16:02:54 PDT 2020
ldionne created this revision.
ldionne added reviewers: yln, delcypher.
Herald added subscribers: llvm-commits, dexonsmith, jkorous.
Herald added a project: LLVM.
ldionne added a comment.
This is going to require a lot of fixes in Lit's own tests. I'd like to know whether we're interested to proceed this way before I go ahead and fix them.
Note that without this change, it's fairly difficult to extract precise stdout or stderr results after running a command through the internal Shell format, as explained in the commit message. That's the motivation for the change.
Before this patch, evaluating commands in the internal shell results in
a (out, err, exitCode, timeoutInfo) quadruple where the standard output
contains a detailed trace of everything that was executed, and where
the standard error doesn't contain anything.
Instead, it should return the standard output/error of the executed
commands, like an external shell would. Otherwise, it is impossible
retrieve the standard output/error when calling executeScriptInternal
without parsing that trace.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D81892
Files:
llvm/utils/lit/lit/TestRunner.py
Index: llvm/utils/lit/lit/TestRunner.py
===================================================================
--- llvm/utils/lit/lit/TestRunner.py
+++ llvm/utils/lit/lit/TestRunner.py
@@ -894,10 +894,6 @@
out = err = ''
for i,result in enumerate(results):
- # Write the command line run.
- out += '$ %s\n' % (' '.join('"%s"' % s
- for s in result.command.args),)
-
# If nothing interesting happened, move on.
if litConfig.maxIndividualTestTime == 0 and \
result.exitCode == 0 and \
@@ -905,25 +901,10 @@
continue
# Otherwise, something failed or was printed, show it.
-
- # Add the command output, if redirected.
- for (name, path, data) in result.outputFiles:
- if data.strip():
- out += "# redirected output from %r:\n" % (name,)
- data = to_string(data.decode('utf-8', errors='replace'))
- if len(data) > 1024:
- out += data[:1024] + "\n...\n"
- out += "note: data was truncated\n"
- else:
- out += data
- out += "\n"
-
if result.stdout.strip():
- out += '# command output:\n%s\n' % (result.stdout,)
+ out += result.stdout
if result.stderr.strip():
- out += '# command stderr:\n%s\n' % (result.stderr,)
- if not result.stdout.strip() and not result.stderr.strip():
- out += "note: command had no output on stdout or stderr\n"
+ err += result.stderr
# Show the error conditions:
if result.exitCode != 0:
@@ -933,10 +914,10 @@
codeStr = hex(int(result.exitCode & 0xFFFFFFFF)).rstrip("L")
else:
codeStr = str(result.exitCode)
- out += "error: command failed with exit status: %s\n" % (
+ err += "\nerror: command failed with exit status: %s\n" % (
codeStr,)
if litConfig.maxIndividualTestTime > 0 and result.timeoutReached:
- out += 'error: command reached timeout: %s\n' % (
+ err += '\nerror: command reached timeout: %s\n' % (
str(result.timeoutReached),)
return out, err, exitCode, timeoutInfo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81892.270897.patch
Type: text/x-patch
Size: 2313 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200615/664defc1/attachment.bin>
More information about the llvm-commits
mailing list