Skip to content

Commit e3a7c77

Browse files
committed
[lldb/Lit] Change the lldbtest format to behave more like shell test.
The current lldbtest format has a number of shortcomings, all related to how we omit information based on why the test fails. For example, a successful test would print nothing, even when `-a` is passed to lit. It's not up to the test format to decide whether to print something or not, that's handled by lit itself. For other test results we would sometimes print stdout & stderr, but not always, such as when a timeout was reached or we couldn't parse the dotest output. This patch changes the lldbtest format and makes it behave more like lit. We now always print the dotest invocation, the exit code, the output to stdout & stderr. If you're used to dealing with ShTests in lit, this will feel all very familiar. Differential revision: https://reviews.llvm.org/D73384
1 parent 632ba9f commit e3a7c77

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

lldb/test/API/lldbtest.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,33 +86,46 @@ def execute(self, test, litConfig):
8686
shutil.copy(python, copied_python)
8787
cmd[0] = copied_python
8888

89+
timeoutInfo = None
8990
try:
9091
out, err, exitCode = lit.util.executeCommand(
9192
cmd,
9293
env=test.config.environment,
9394
timeout=litConfig.maxIndividualTestTime)
9495
except lit.util.ExecuteCommandTimeoutException:
95-
return (lit.Test.TIMEOUT, 'Reached timeout of {} seconds'.format(
96-
litConfig.maxIndividualTestTime))
96+
timeoutInfo = 'Reached timeout of {} seconds'.format(
97+
litConfig.maxIndividualTestTime)
98+
99+
output = """Script:\n--\n%s\n--\nExit Code: %d\n""" % (
100+
' '.join(cmd), exitCode)
101+
if timeoutInfo is not None:
102+
output += """Timeout: %s\n""" % (timeoutInfo,)
103+
output += "\n"
104+
105+
if out:
106+
output += """Command Output (stdout):\n--\n%s\n--\n""" % (out,)
107+
if err:
108+
output += """Command Output (stderr):\n--\n%s\n--\n""" % (err,)
109+
110+
if timeoutInfo:
111+
return lit.Test.TIMEOUT, output
97112

98113
if exitCode:
99114
# Match FAIL but not XFAIL.
100115
for line in out.splitlines() + err.splitlines():
101116
if line.startswith('FAIL:'):
102-
return lit.Test.FAIL, out + err
117+
return lit.Test.FAIL, output
103118

104119
if 'XPASS:' in out or 'XPASS:' in err:
105-
return lit.Test.XPASS, out + err
120+
return lit.Test.XPASS, output
106121

107122
has_unsupported_tests = 'UNSUPPORTED:' in out or 'UNSUPPORTED:' in err
108123
has_passing_tests = 'PASS:' in out or 'PASS:' in err
109124
if has_unsupported_tests and not has_passing_tests:
110-
return lit.Test.UNSUPPORTED, out + err
125+
return lit.Test.UNSUPPORTED, output
111126

112127
passing_test_line = 'RESULT: PASSED'
113128
if passing_test_line not in out and passing_test_line not in err:
114-
msg = ('Unable to find %r in dotest output (exit code %d):\n\n%s%s'
115-
% (passing_test_line, exitCode, out, err))
116-
return lit.Test.UNRESOLVED, msg
129+
return lit.Test.UNRESOLVED, output
117130

118-
return lit.Test.PASS, ''
131+
return lit.Test.PASS, output

0 commit comments

Comments
 (0)