1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00

[lit] worker.py: Improve code for executing a single test

llvm-svn: 375194
This commit is contained in:
Julian Lettner 2019-10-18 00:50:34 +00:00
parent 5a048d66d7
commit e117eb0745

View File

@ -56,19 +56,20 @@ def _execute_test_in_parallelism_group(test, lit_config, parallelism_semaphores)
else:
_execute_test(test, lit_config)
def _execute_test(test, lit_config):
"""Execute one test"""
start = time.time()
result = _execute_test_handle_errors(test, lit_config)
end = time.time()
result.elapsed = end - start
test.setResult(result)
def _execute_test_handle_errors(test, lit_config):
try:
start_time = time.time()
result = test.config.test_format.execute(test, lit_config)
# Support deprecated result from execute() which returned the result
# code and additional output as a tuple.
if isinstance(result, tuple):
code, output = result
result = lit.Test.Result(code, output)
elif not isinstance(result, lit.Test.Result):
raise ValueError("unexpected result from test execution")
result.elapsed = time.time() - start_time
return _adapt_result(test.config.test_format.execute(test, lit_config))
except KeyboardInterrupt:
raise
except:
@ -77,6 +78,14 @@ def _execute_test(test, lit_config):
output = 'Exception during script execution:\n'
output += traceback.format_exc()
output += '\n'
result = lit.Test.Result(lit.Test.UNRESOLVED, output)
return lit.Test.Result(lit.Test.UNRESOLVED, output)
test.setResult(result)
# Support deprecated result from execute() which returned the result
# code and additional output as a tuple.
def _adapt_result(result):
if isinstance(result, lit.Test.Result):
return result
assert isinstance(result, tuple)
code, output = result
return lit.Test.Result(code, output)