summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2013-08-29 00:41:09 +0000
committerDaniel Dunbar <daniel@zuster.org>2013-08-29 00:41:09 +0000
commit501cba385cf2ae5db1d646ec75e1d4d57e015d80 (patch)
treeb7d812f6ac3c750e8388daad98e38fa147f331c3 /utils
parent8a1d9b207a2bec95dfdc72700f8edafd44c98c17 (diff)
downloadllvm-501cba385cf2ae5db1d646ec75e1d4d57e015d80.tar.gz
llvm-501cba385cf2ae5db1d646ec75e1d4d57e015d80.tar.bz2
llvm-501cba385cf2ae5db1d646ec75e1d4d57e015d80.tar.xz
[lit] Update shtest format to return lit.Test.Result objects.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189545 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/lit/lit/TestRunner.py61
1 files changed, 21 insertions, 40 deletions
diff --git a/utils/lit/lit/TestRunner.py b/utils/lit/lit/TestRunner.py
index cf98b7a371..120f89a21a 100644
--- a/utils/lit/lit/TestRunner.py
+++ b/utils/lit/lit/TestRunner.py
@@ -239,7 +239,7 @@ def executeScriptInternal(test, litConfig, tmpBase, commands, cwd):
cmds.append(ShUtil.ShParser(ln, litConfig.isWindows,
test.config.pipefail).parse())
except:
- return (Test.FAIL, "shell parser error on: %r" % ln)
+ return lit.Test.Result(Test.FAIL, "shell parser error on: %r" % ln)
cmd = cmds[0]
for c in cmds[1:]:
@@ -448,65 +448,36 @@ def parseIntegratedTestScript(test, normalize_slashes=False,
# Verify the script contains a run line.
if not script:
- return (Test.UNRESOLVED, "Test has no run line!")
+ return lit.Test.Result(Test.UNRESOLVED, "Test has no run line!")
# Check for unterminated run lines.
if script[-1][-1] == '\\':
- return (Test.UNRESOLVED, "Test has unterminated run lines (with '\\')")
+ return lit.Test.Result(Test.UNRESOLVED,
+ "Test has unterminated run lines (with '\\')")
# Check that we have the required features:
missing_required_features = [f for f in requires
if f not in test.config.available_features]
if missing_required_features:
msg = ', '.join(missing_required_features)
- return (Test.UNSUPPORTED,
- "Test requires the following features: %s" % msg)
+ return lit.Test.Result(Test.UNSUPPORTED,
+ "Test requires the following features: %s" % msg)
return script,tmpBase,execdir
-def formatTestOutput(status, out, err, exitCode, script):
- output = """\
-Script:
---
-%s
---
-Exit Code: %d
-
-""" % ('\n'.join(script), exitCode)
-
- # Append the stdout, if present.
- if out:
- output += """\
-Command Output (stdout):
---
-%s
---
-""" % (out,)
-
- # Append the stderr, if present.
- if err:
- output += """\
-Command Output (stderr):
---
-%s
---
-""" % (err,)
- return (status, output)
-
def executeShTest(test, litConfig, useExternalSh,
extra_substitutions=[]):
if test.config.unsupported:
return (Test.UNSUPPORTED, 'Test is unsupported')
res = parseIntegratedTestScript(test, useExternalSh, extra_substitutions)
- if len(res) == 2:
+ if isinstance(res, lit.Test.Result):
return res
+ if litConfig.noExecute:
+ return lit.Test.Result(Test.PASS)
script, tmpBase, execdir = res
- if litConfig.noExecute:
- return (Test.PASS, '')
-
# Create the output directory if it does not already exist.
lit.util.mkdir_p(os.path.dirname(tmpBase))
@@ -514,7 +485,7 @@ def executeShTest(test, litConfig, useExternalSh,
res = executeScript(test, litConfig, tmpBase, script, execdir)
else:
res = executeScriptInternal(test, litConfig, tmpBase, script, execdir)
- if len(res) == 2:
+ if isinstance(res, lit.Test.Result):
return res
out,err,exitCode = res
@@ -523,4 +494,14 @@ def executeShTest(test, litConfig, useExternalSh,
else:
status = Test.FAIL
- return formatTestOutput(status, out, err, exitCode, script)
+ # Form the output log.
+ output = """Script:\n--\n%s\n--\nExit Code: %d\n\n""" % (
+ '\n'.join(script), exitCode)
+
+ # Append the outputs, if present.
+ if out:
+ output += """Command Output (stdout):\n--\n%s\n--\n""" % (out,)
+ if err:
+ output += """Command Output (stderr):\n--\n%s\n--\n""" % (err,)
+
+ return lit.Test.Result(status, output)