[libcxx] r223599 - Consolidate error reporting in lit.cfg
Eric Fiselier
eric at efcs.ca
Sat Dec 6 20:28:51 PST 2014
Author: ericwf
Date: Sat Dec 6 22:28:50 2014
New Revision: 223599
URL: http://llvm.org/viewvc/llvm-project?rev=223599&view=rev
Log:
Consolidate error reporting in lit.cfg
Modified:
libcxx/trunk/test/lit.cfg
Modified: libcxx/trunk/test/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/lit.cfg?rev=223599&r1=223598&r2=223599&view=diff
==============================================================================
--- libcxx/trunk/test/lit.cfg (original)
+++ libcxx/trunk/test/lit.cfg Sat Dec 6 22:28:50 2014
@@ -90,6 +90,16 @@ class LibcxxTestFormat(lit.formats.FileB
# Evaluate the test.
return self._evaluate_test(test, use_verify, lit_config)
+ def _make_report(self, cmd, out, err, rc):
+ report = "Command: %s\n" % cmd
+ report += "Exit Code: %d\n" % rc
+ if out:
+ report += "Standard Output:\n--\n%s--\n" % out
+ if err:
+ report += "Standard Error:\n--\n%s--\n" % err
+ report += '\n'
+ return cmd, report, rc
+
def _build(self, exec_path, source_path, compile_only=False,
use_verify=False):
cmd = [self.cxx_under_test, '-o', exec_path,
@@ -104,7 +114,7 @@ class LibcxxTestFormat(lit.formats.FileB
cmd += ['-Xclang', '-verify']
out, err, rc = lit.util.executeCommand(cmd)
- return cmd, out, err, rc
+ return self._make_report(cmd, out, err, rc)
def _clean(self, exec_path):
os.remove(exec_path)
@@ -118,8 +128,8 @@ class LibcxxTestFormat(lit.formats.FileB
cmd.append(exec_path)
if lit_config.useValgrind:
cmd = lit_config.valgrindArgs + cmd
- out, err, exitCode = lit.util.executeCommand(cmd, cwd=in_dir)
- return cmd, out, err, exitCode
+ out, err, rc = lit.util.executeCommand(cmd, cwd=in_dir)
+ return self._make_report(cmd, out, err, rc)
def _evaluate_test(self, test, use_verify, lit_config):
name = test.path_in_suite[-1]
@@ -132,54 +142,31 @@ class LibcxxTestFormat(lit.formats.FileB
# If this is a compile (failure) test, build it and check for failure.
if expected_compile_fail:
- cmd, out, err, rc = self._build('/dev/null', source_path,
- compile_only=True,
- use_verify=use_verify)
+ cmd, report, rc = self._build('/dev/null', source_path,
+ compile_only=True,
+ use_verify=use_verify)
expected_rc = 0 if use_verify else 1
if rc == expected_rc:
return lit.Test.PASS, ""
else:
- report = """Command: %s\n""" % ' '.join(["'%s'" % a
- for a in cmd])
- report += """Exit Code: %d\n""" % rc
- if out:
- report += """Standard Output:\n--\n%s--""" % out
- if err:
- report += """Standard Error:\n--\n%s--""" % err
- report += "\n\nExpected compilation to fail!"
- return lit.Test.FAIL, report
+ return lit.Test.FAIL, report + 'Expected compilation to fail!\n'
else:
exec_file = tempfile.NamedTemporaryFile(suffix="exe", delete=False)
exec_path = exec_file.name
exec_file.close()
try:
- cmd, out, err, rc = self._build(exec_path, source_path)
+ cmd, report, rc = self._build(exec_path, source_path)
compile_cmd = cmd
if rc != 0:
- report = """Command: %s\n""" % ' '.join(["'%s'" % a
- for a in cmd])
- report += """Exit Code: %d\n""" % rc
- if out:
- report += """Standard Output:\n--\n%s--""" % out
- if err:
- report += """Standard Error:\n--\n%s--""" % err
- report += "\n\nCompilation failed unexpectedly!"
+ report += "Compilation failed unexpectedly!"
return lit.Test.FAIL, report
- cmd, out, err, rc = self._run(exec_path, lit_config,
- source_dir)
+ cmd, report, rc = self._run(exec_path, lit_config,
+ source_dir)
if rc != 0:
- report = """Compiled With: %s\n""" % \
- ' '.join(["'%s'" % a for a in compile_cmd])
- report += """Command: %s\n""" % \
- ' '.join(["'%s'" % a for a in cmd])
- report += """Exit Code: %d\n""" % rc
- if out:
- report += """Standard Output:\n--\n%s--""" % out
- if err:
- report += """Standard Error:\n--\n%s--""" % err
- report += "\n\nCompiled test failed unexpectedly!"
+ report = "Compiled With: %s\n%s" % (compile_cmd, report)
+ report += "Compiled test failed unexpectedly!"
return lit.Test.FAIL, report
finally:
try:
More information about the cfe-commits
mailing list