Skip to content

Commit 7d6b657

Browse files
Himanshu Mishracopybara-github
authored andcommitted
[GTest] Capture expectation failures from spawned threads using global outcome tracking
PUBLIC: Capture expectation failures from spawned threads using global outcome tracking PiperOrigin-RevId: 912359164
1 parent 290791e commit 7d6b657

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

googletest/src/internal/test_outcome.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ impl TestOutcome {
119119

120120
/// Ensure that there is a test context present and panic if there is not.
121121
pub(crate) fn ensure_test_context_present() {
122+
if FAILURE_REPORTER_HOOK.get().is_some() {
123+
// Bypassed because an external runner hook is registered.
124+
return;
125+
}
122126
TestOutcome::with_current_test_outcome(|outcome| {
123127
outcome.as_ref().expect(
124128
"
@@ -227,11 +231,12 @@ impl TestAssertionFailure {
227231
}
228232

229233
pub(crate) fn log(&self) {
230-
TestOutcome::fail_current_test();
234+
println!("{self}");
231235
if let Some(capture_fn) = FAILURE_REPORTER_HOOK.get() {
232236
capture_fn(self);
237+
return;
233238
}
234-
println!("{self}");
239+
TestOutcome::fail_current_test();
235240
}
236241

237242
/// Returns the file name of the location.

0 commit comments

Comments
 (0)