[llvm] 4cd1c96 - [reland][lit][unit] makes sure to print stderr when no test failures are found
Yuanfang Chen via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 15 13:26:55 PDT 2022
Author: Yuanfang Chen
Date: 2022-07-15T13:26:30-07:00
New Revision: 4cd1c96d375aaaf8b48f0fddc8bd0a6619ff061c
URL: https://github.com/llvm/llvm-project/commit/4cd1c96d375aaaf8b48f0fddc8bd0a6619ff061c
DIFF: https://github.com/llvm/llvm-project/commit/4cd1c96d375aaaf8b48f0fddc8bd0a6619ff061c.diff
LOG: [reland][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.
Relands 65769429c0644c81d271e9d971f5b64191503
Added:
Modified:
llvm/utils/lit/lit/formats/googletest.py
llvm/utils/lit/lit/main.py
Removed:
################################################################################
diff --git a/llvm/utils/lit/lit/formats/googletest.py b/llvm/utils/lit/lit/formats/googletest.py
index 5feefaa84f12e..ed3a19e93982a 100644
--- a/llvm/utils/lit/lit/formats/googletest.py
+++ b/llvm/utils/lit/lit/formats/googletest.py
@@ -163,6 +163,8 @@ def get_test_stdout(test_name):
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 @@ def get_test_stdout(test_name):
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 @@ def get_test_stdout(test_name):
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):
@@ -217,7 +226,11 @@ def remove_gtest(tests):
discovered_tests = remove_gtest(discovered_tests)
gtests = [t for t in selected_tests if t.gtest_json_file]
selected_tests = remove_gtest(selected_tests)
+ has_failure = False
for test in gtests:
+ if test.isFailure():
+ has_failure = True
+
# In case gtest has bugs such that no JSON file was emitted.
if not os.path.exists(test.gtest_json_file):
selected_tests.append(test)
@@ -269,4 +282,4 @@ def remove_gtest(tests):
discovered_tests.append(subtest)
os.remove(test.gtest_json_file)
- return selected_tests, discovered_tests
+ return selected_tests, discovered_tests, has_failure
diff --git a/llvm/utils/lit/lit/main.py b/llvm/utils/lit/lit/main.py
index 27bcef1b1d464..67d9efa11fb12 100755
--- a/llvm/utils/lit/lit/main.py
+++ b/llvm/utils/lit/lit/main.py
@@ -108,7 +108,7 @@ def main(builtin_params={}):
record_test_times(selected_tests, lit_config)
- selected_tests, discovered_tests = GoogleTest.post_process_shard_results(
+ selected_tests, discovered_tests, has_failure = GoogleTest.post_process_shard_results(
selected_tests, discovered_tests)
if opts.time_tests:
@@ -127,7 +127,7 @@ def main(builtin_params={}):
if lit_config.numWarnings:
sys.stderr.write('\n%d warning(s) in tests\n' % lit_config.numWarnings)
- has_failure = any(t.isFailure() for t in discovered_tests)
+ has_failure = has_failure or any(t.isFailure() for t in discovered_tests)
if has_failure:
if opts.ignoreFail:
sys.stderr.write("\nExiting with status 0 instead of 1 because "
More information about the llvm-commits
mailing list