Skip to content

Commit

Permalink
Merge pull request #757 from uuid-rs/ci/more-miri
Browse files Browse the repository at this point in the history
Expand miri tests to cover all features
  • Loading branch information
KodrAus committed Jun 24, 2024
2 parents e62647f + 252770b commit 0c561e3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ jobs:
cargo +nightly miri setup
- name: Default features
run: cargo +nightly miri test --lib
run: cargo +nightly miri test --lib --all-features

- name: BE
run: cargo +nightly miri test --target s390x-unknown-linux-gnu --lib
run: cargo +nightly miri test --target s390x-unknown-linux-gnu --lib --all-features

clippy:
name: Build / Clippy
Expand Down
16 changes: 16 additions & 0 deletions src/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ fn now() -> (u64, u32) {

#[cfg(all(
feature = "std",
not(miri),
any(
not(feature = "js"),
not(all(
Expand All @@ -353,6 +354,21 @@ fn now() -> (u64, u32) {
(dur.as_secs(), dur.subsec_nanos())
}

#[cfg(all(feature = "std", miri))]
fn now() -> (u64, u32) {
use std::{sync::Mutex, time::Duration};

static TS: Mutex<u64> = Mutex::new(0);

let ts = Duration::from_nanos({
let mut ts = TS.lock().unwrap();
*ts += 1;
*ts
});

(ts.as_secs(), ts.subsec_nanos())
}

/// A counter that can be used by version 1 and version 6 UUIDs to support
/// the uniqueness of timestamps.
///
Expand Down

0 comments on commit 0c561e3

Please sign in to comment.