]> granicus.if.org Git - llvm/commitdiff
[lit] Move resolving of XFAIL result codes out of Test.setResult
authorJulian Lettner <jlettner@apple.com>
Fri, 18 Oct 2019 00:50:37 +0000 (00:50 +0000)
committerJulian Lettner <jlettner@apple.com>
Fri, 18 Oct 2019 00:50:37 +0000 (00:50 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@375195 91177308-0d34-0410-b5e6-96231b3b80d8

utils/lit/lit/Test.py
utils/lit/lit/worker.py

index a10419f33fa1ba7493ca1fb0aac05ac99b8e4ff9..dffa735fde7c05464a96f425176a821c94c1ba39 100644 (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)
 
index 3a4868ea7c489d3d6e2fcc9b27885dc5a43a6ec9..a4e77be9d7371d20cb2b22bb319829cbf20b6f77 100644 (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))