[lit] Move resolving of XFAIL result codes out of Test.setResult

This will allow us to serialize just the result object instead of the
whole lit.Test object back from the worker to the main lit process.

llvm-svn: 375195
This commit is contained in:
Julian Lettner 2019-10-18 00:50:37 +00:00
parent 13bf5eb1f4
commit a3d2f9b53a
2 changed files with 21 additions and 12 deletions

View File

@ -231,18 +231,6 @@ class Test:
self.result = result
# Apply the XFAIL handling to resolve the result exit code.
try:
if self.isExpectedToFail():
if self.result.code == PASS:
self.result.code = XPASS
elif self.result.code == FAIL:
self.result.code = XFAIL
except ValueError as e:
# Syntax error in an XFAIL line.
self.result.code = UNRESOLVED
self.result.output = str(e)
def getFullName(self):
return self.suite.config.name + ' :: ' + '/'.join(self.path_in_suite)

View File

@ -64,9 +64,30 @@ def _execute_test(test, lit_config):
end = time.time()
result.elapsed = end - start
resolve_result_code(result, test)
test.setResult(result)
# TODO(yln): is this the right place to deal with this?
# isExpectedToFail() only works after the test has been executed.
def resolve_result_code(result, test):
try:
expected_to_fail = test.isExpectedToFail()
except ValueError as e:
# Syntax error in an XFAIL line.
result.code = lit.Test.UNRESOLVED
result.output = str(e)
else:
if expected_to_fail:
# pass -> unexpected pass
if result.code is lit.Test.PASS:
result.code = lit.Test.XPASS
# fail -> expected fail
if result.code is lit.Test.FAIL:
result.code = lit.Test.XFAIL
def _execute_test_handle_errors(test, lit_config):
try:
return _adapt_result(test.config.test_format.execute(test, lit_config))