From: Yuanfang Chen Date: Fri, 15 Jul 2022 19:16:18 +0000 (-0700) Subject: [lit][unit] makes sure to print stderr when no test failures are found X-Git-Tag: upstream/15.0.7~1526 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=65769429c0644c81d271e9d971f5b64191503f6e;p=platform%2Fupstream%2Fllvm.git [lit][unit] makes sure to print stderr when no test failures are found In some situations, like running tests with sanitizers, all test passes but the shard could still fail due to memory issues. --- diff --git a/llvm/utils/lit/lit/formats/googletest.py b/llvm/utils/lit/lit/formats/googletest.py index 5feefaa..6878ebc 100644 --- a/llvm/utils/lit/lit/formats/googletest.py +++ b/llvm/utils/lit/lit/formats/googletest.py @@ -163,6 +163,8 @@ class GoogleTest(TestFormat): res.append(l) assert False, f'gtest did not report the result for ' + test_name + found_failed_test = False + with open(test.gtest_json_file, encoding='utf-8') as f: jf = json.load(f) @@ -179,6 +181,7 @@ class GoogleTest(TestFormat): header = f"Script:\n--\n%s --gtest_filter=%s\n--\n" % ( ' '.join(cmd), testname) if 'failures' in testinfo: + found_failed_test = True output += header test_out = get_test_stdout(testname) if test_out: @@ -189,6 +192,12 @@ class GoogleTest(TestFormat): elif result != 'COMPLETED': output += header output += 'unresolved test result\n' + + # In some situations, like running tests with sanitizers, all test passes but + # the shard could still fail due to memory issues. + if not found_failed_test: + output += f"\n{out}\n--\nexit: {exitCode}\n--\n" + return lit.Test.FAIL, output def prepareCmd(self, cmd):