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

Julian Lettner via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 17 17:50:34 PDT 2019


Author: yln
Date: Thu Oct 17 17:50:34 2019
New Revision: 375194

URL: http://llvm.org/viewvc/llvm-project?rev=375194&view=rev
Log:
[lit] worker.py: Improve code for executing a single test

Modified:
    llvm/trunk/utils/lit/lit/worker.py

Modified: llvm/trunk/utils/lit/lit/worker.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/worker.py?rev=375194&r1=375193&r2=375194&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/worker.py (original)
+++ llvm/trunk/utils/lit/lit/worker.py Thu Oct 17 17:50:34 2019
@@ -56,19 +56,20 @@ def _execute_test_in_parallelism_group(t
     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)




More information about the llvm-commits mailing list