Skip to content

Commit

Permalink
Mention in the readme that sync enables the
Browse files Browse the repository at this point in the history
global singleton for the MockClock across all threads
  • Loading branch information
museun committed Feb 16, 2024
1 parent 6f86434 commit 3fc0601
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/museun/mock_instant/issues/6>

License: 0BSD
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit 3fc0601

Please sign in to comment.