[test-suite] r251892 - cmake/lit: Report all commandlines and only show outputs in error case
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 2 18:47:00 PST 2015
Author: matze
Date: Mon Nov 2 20:47:00 2015
New Revision: 251892
URL: http://llvm.org/viewvc/llvm-project?rev=251892&view=rev
Log:
cmake/lit: Report all commandlines and only show outputs in error case
Modified:
test-suite/trunk/lit.cfg
Modified: test-suite/trunk/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/lit.cfg?rev=251892&r1=251891&r2=251892&view=diff
==============================================================================
--- test-suite/trunk/lit.cfg (original)
+++ test-suite/trunk/lit.cfg Mon Nov 2 20:47:00 2015
@@ -73,35 +73,12 @@ def collectCompileTime(test):
return compile_time
def runScript(test, litConfig, script, tmpBase, useExternalSh = False):
- # Create the output directory if it does not already exist.
- lit.util.mkdir_p(os.path.dirname(tmpBase))
-
execdir = os.path.dirname(test.getExecPath())
if useExternalSh:
res = executeScript(test, litConfig, tmpBase, script, execdir)
else:
res = executeScriptInternal(test, litConfig, tmpBase, script, execdir)
- if isinstance(res, lit.Test.Result):
- return res
-
- out,err,exitCode = res
- # 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,)
-
- if exitCode == 0:
- status = Test.PASS
- else:
- status = Test.FAIL
-
- result = lit.Test.Result(status, output)
- return result
+ return res
class TestSuiteTest(FileBasedTest):
def __init__(self):
@@ -146,27 +123,49 @@ class TestSuiteTest(FileBasedTest):
return line
runscript = map(prependRunSafely, runscript)
- # Run RUN: part of the script n times
+ # Create the output directory if it does not already exist.
+ lit.util.mkdir_p(os.path.dirname(tmpBase))
+
+ # Execute runscript (the "RUN:" part)
+ output = ""
n_runs = 1
runtimes = []
for n in range(n_runs):
- runresult = runScript(test, litConfig, runscript, tmpBase)
- if runresult.code == Test.FAIL:
- return runresult
+ res = runScript(test, litConfig, runscript, tmpBase)
+ if isinstance(res, lit.Test.Result):
+ return res
+
+ output += "\n" + "\n".join(runscript)
+
+ out, err, exitCode = res
+ if exitCode == Test.FAIL:
+ # Only show command output in case of errors
+ output += "\n" + out
+ output += "\n" + err
+ return lit.Test.Result(Test.FAIL, output)
+
timefile = "%s.time" % (outfile,)
runtime = getUserTimeFromTimeOutput(timefile)
runtimes.append(runtime)
- # Run verification of results
- verifyresult = runScript(test, litConfig, verifyscript, tmpBase)
- if verifyresult.code == Test.FAIL:
- return verifyresult
+ # Run verification script (the "VERIFY:" part)
+ res = runScript(test, litConfig, verifyscript, tmpBase)
+ if isinstance(res, lit.Test.Result):
+ return res
+ out, err, exitCode = res
+
+ output += "\n" + "\n".join(verifyscript)
+ if exitCode != 0:
+ output += "\n" + out
+ output += "\n" + err
+ return lit.Test.Result(Test.FAIL, output)
compile_time = collectCompileTime(test)
- runresult.addMetric('exec_time', lit.Test.toMetricValue(runtimes[0]))
- runresult.addMetric('compile_time', lit.Test.toMetricValue(compile_time))
- return runresult
+ result = lit.Test.Result(Test.PASS, output)
+ result.addMetric('exec_time', lit.Test.toMetricValue(runtimes[0]))
+ result.addMetric('compile_time', lit.Test.toMetricValue(compile_time))
+ return result
config.name = 'test-suite'
config.test_format = TestSuiteTest()
More information about the llvm-commits
mailing list