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)
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:
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):
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)
discovered_tests.append(subtest)
os.remove(test.gtest_json_file)
- return selected_tests, discovered_tests
+ return selected_tests, discovered_tests, has_failure
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:
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 "