Skip to content

Commit f6491e1

Browse files
committed
serial_test
1 parent 12cc902 commit f6491e1

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ wasi = "0.11"
6161
[dev-dependencies]
6262
average = "0.14"
6363
criterion = "=0.3.3"
64+
serial_test = "3.2"
6465

6566
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies]
6667
wasm-bindgen-test = "0.3"

src/instant.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -279,20 +279,19 @@ impl Into<prost_types::Timestamp> for Instant {
279279

280280
#[cfg(test)]
281281
mod tests {
282-
use once_cell::sync::Lazy;
283-
284282
use super::Instant;
285283
use crate::{with_clock, Clock};
284+
use serial_test::serial;
285+
use std::sync::LazyLock;
286286
use std::time::Duration;
287287
use std::{sync::Mutex, thread};
288288

289-
static RECENT_LOCK: Lazy<Mutex<()>> = Lazy::new(|| Mutex::new(()));
290-
291289
#[test]
292290
#[cfg_attr(
293291
all(target_arch = "wasm32", target_os = "unknown"),
294292
ignore = "WASM thread cannot sleep"
295293
)]
294+
#[serial]
296295
fn test_now() {
297296
let t0 = Instant::now();
298297
thread::sleep(Duration::from_millis(15));
@@ -311,9 +310,8 @@ mod tests {
311310
all(target_arch = "wasm32", target_os = "unknown"),
312311
ignore = "WASM thread cannot sleep"
313312
)]
313+
#[serial]
314314
fn test_recent() {
315-
let _guard = RECENT_LOCK.lock().unwrap();
316-
317315
// Ensures that the recent global value is zero so that the fallback logic can kick in.
318316
crate::set_recent(Instant(0));
319317

@@ -346,9 +344,8 @@ mod tests {
346344
all(target_arch = "wasm32", target_os = "unknown"),
347345
wasm_bindgen_test::wasm_bindgen_test
348346
)]
347+
#[serial]
349348
fn test_mocking() {
350-
let _guard = RECENT_LOCK.lock().unwrap();
351-
352349
// Ensures that the recent global value is zero so that the fallback logic can kick in.
353350
crate::set_recent(Instant(0));
354351

@@ -380,6 +377,7 @@ mod tests {
380377
all(target_arch = "wasm32", target_os = "unknown"),
381378
wasm_bindgen_test::wasm_bindgen_test
382379
)]
380+
#[serial]
383381
fn checked_arithmetic_u64_overflow() {
384382
fn nanos_to_dur(total_nanos: u128) -> Duration {
385383
let nanos_per_sec = Duration::from_secs(1).as_nanos();

0 commit comments

Comments
 (0)