From a3d2f9b53ac006cb972b61b0dbfcb5babe4356bf Mon Sep 17 00:00:00 2001 From: Julian Lettner Date: Fri, 18 Oct 2019 00:50:37 +0000 Subject: [PATCH] [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 --- llvm/utils/lit/lit/Test.py | 12 ------------ llvm/utils/lit/lit/worker.py | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/llvm/utils/lit/lit/Test.py b/llvm/utils/lit/lit/Test.py index a10419f33fa1..dffa735fde7c 100644 --- a/llvm/utils/lit/lit/Test.py +++ b/llvm/utils/lit/lit/Test.py @@ -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) diff --git a/llvm/utils/lit/lit/worker.py b/llvm/utils/lit/lit/worker.py index 3a4868ea7c48..a4e77be9d737 100644 --- a/llvm/utils/lit/lit/worker.py +++ b/llvm/utils/lit/lit/worker.py @@ -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))