diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 4ec7167e..bb3dbfd6 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -37,7 +37,7 @@ jobs:
- name: cargo clippy
uses: actions-rs/clippy-check@b5b5f21f4797c02da247df37026fcd0a5024aa4d # v1.0.7
with:
- args: --all-targets --all-features
+ args: --all-targets --features all_stable_features
token: ${{ secrets.GITHUB_TOKEN }}
test-latest-deps:
@@ -55,14 +55,29 @@ jobs:
- name: cargo update
run: cargo update
- name: cargo test --locked
- run: cargo test --locked --all-features
+ run: cargo test --locked --features all_stable_features
test:
runs-on: ubuntu-latest
name: test / ubuntu / ${{ matrix.toolchain }}
strategy:
matrix:
- toolchain: [stable, nightly, beta]
+ toolchain: [stable, beta]
+ steps:
+ - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
+ - name: Install ${{ matrix.toolchain }}
+ uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
+ with:
+ toolchain: ${{ matrix.toolchain }}
+ - name: cargo test --locked
+ run: cargo test --locked --features all_stable_features
+
+ test-nightly:
+ runs-on: ubuntu-latest
+ name: test / ubuntu / ${{ matrix.toolchain }}
+ strategy:
+ matrix:
+ toolchain: nightly
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Install ${{ matrix.toolchain }}
diff --git a/googletest/Cargo.toml b/googletest/Cargo.toml
index 7882340d..a57b49aa 100644
--- a/googletest/Cargo.toml
+++ b/googletest/Cargo.toml
@@ -41,3 +41,10 @@ rustversion = "1.0.22"
[dev-dependencies]
indoc = "2"
quickcheck = "1.0.3"
+
+[features]
+# Enables use of the nightly-only `thread_spawn_hook` for capturing test
+# failures in spawned threads.
+unstable_thread_spawn_hook = []
+# A group like `--all-features`, but excluding nightly-only features.
+all_stable_features = ["anyhow", "proptest"]
diff --git a/googletest/src/internal/test_outcome.rs b/googletest/src/internal/test_outcome.rs
index 341eb72f..4204f7f5 100644
--- a/googletest/src/internal/test_outcome.rs
+++ b/googletest/src/internal/test_outcome.rs
@@ -14,6 +14,8 @@
use std::cell::{RefCell, RefMut};
use std::fmt::{Debug, Display, Error, Formatter};
+use std::sync::atomic::{AtomicBool, Ordering as AtomicOrdering};
+use std::sync::Arc;
use std::thread_local;
/// The outcome hitherto of running a test.
@@ -23,16 +25,45 @@ use std::thread_local;
///
/// **For internal use only. API stablility is not guaranteed!**
#[doc(hidden)]
-pub enum TestOutcome {
- /// The test ran or is currently running and no assertions have failed.
- Success,
- /// The test ran or is currently running and at least one assertion has
- /// failed.
- Failure,
+pub struct TestOutcome {
+ is_success: AtomicBool,
+}
+
+impl Default for TestOutcome {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
+impl TestOutcome {
+ pub fn new() -> Self {
+ Self { is_success: AtomicBool::new(true) }
+ }
+ pub fn fail(&self) {
+ self.is_success.store(false, AtomicOrdering::Relaxed)
+ }
+ #[must_use]
+ pub fn is_success(&self) -> bool {
+ self.is_success.load(AtomicOrdering::Relaxed)
+ }
+ #[must_use]
+ pub fn is_failed(&self) -> bool {
+ self.is_success.load(AtomicOrdering::Relaxed)
+ }
}
thread_local! {
- static CURRENT_TEST_OUTCOME: RefCell