From 6f8643492a1e3e9101436b6b534864fdd60fdff3 Mon Sep 17 00:00:00 2001 From: museun Date: Thu, 1 Jun 2023 18:17:28 -0400 Subject: [PATCH 1/2] bump version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 4a64423..967e793 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mock_instant" -version = "0.3.0" +version = "0.3.1" authors = ["museun "] edition = "2018" license = "0BSD" From 3fc06017029beb0610791295d4b92f43b30a0ddf Mon Sep 17 00:00:00 2001 From: museun Date: Fri, 16 Feb 2024 07:45:44 -0500 Subject: [PATCH 2/2] Mention in the readme that `sync` enables the global singleton for the MockClock across all threads --- README.md | 6 ++++++ src/lib.rs | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index d48d831..eab31b2 100644 --- a/README.md +++ b/README.md @@ -59,4 +59,10 @@ MockClock::advance_system_time(Duration::from_secs(2)); assert_eq!(now.elapsed().unwrap(), Duration::from_secs(17)); ``` +# Caveats + +If the `sync` feature is enabled then all tests using this crate will use a global singleton clock. + +see + License: 0BSD diff --git a/src/lib.rs b/src/lib.rs index 956359d..9eb3253 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,6 +9,10 @@ mock_instant = { version = "0.2", features = ["sync"] } It provides a replacement `std::time::Instant` and `std::time::SystemTime` that uses a deterministic thread-local 'clock' +**NOTE:** if this is enabled then all tests will use the same singleton `MockClock` source + +--- + You can swap out the `std::time::Instant` with this one by doing something similar to: ```rust #[cfg(test)]