Consolidate error reporting in lit.cfg
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@223599 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2050be27a4
commit
cd83c78703
59
test/lit.cfg
59
test/lit.cfg
@ -90,6 +90,16 @@ class LibcxxTestFormat(lit.formats.FileBasedTest):
|
||||
# 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.FileBasedTest):
|
||||
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.FileBasedTest):
|
||||
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.FileBasedTest):
|
||||
|
||||
# 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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user