diff options
| -rw-r--r-- | talpid-time/Cargo.toml | 3 | ||||
| -rw-r--r-- | talpid-time/src/lib.rs | 10 |
2 files changed, 11 insertions, 2 deletions
diff --git a/talpid-time/Cargo.toml b/talpid-time/Cargo.toml index 40fd2f5e74..4f6158ee53 100644 --- a/talpid-time/Cargo.toml +++ b/talpid-time/Cargo.toml @@ -10,6 +10,9 @@ rust-version.workspace = true [lints] workspace = true +[features] +test = [] + [dependencies] tokio = { workspace = true, features = ["time"] } libc = "0.2" diff --git a/talpid-time/src/lib.rs b/talpid-time/src/lib.rs index 3b536eda54..4ca9c8bf5d 100644 --- a/talpid-time/src/lib.rs +++ b/talpid-time/src/lib.rs @@ -1,14 +1,20 @@ use std::time::Duration; -#[cfg(target_os = "windows")] +#[cfg(all(not(feature = "test"), target_os = "windows"))] mod inner { pub use std::time::Instant; } -#[cfg(unix)] +#[cfg(all(not(feature = "test"), unix))] #[path = "unix.rs"] mod inner; +#[cfg(feature = "test")] +mod inner { + /// Use mockable time for tests + pub use tokio::time::Instant; +} + const MAX_SLEEP_INTERVAL: Duration = Duration::from_secs(60); /// Represents a measurement of a monotonic clock. |
