From 7ef9bece319d076f08126072061d6b01f5382c6a Mon Sep 17 00:00:00 2001 From: Alexander Abdugafarov Date: Thu, 18 Sep 2025 17:47:08 +0500 Subject: [PATCH 1/2] Make miri work with proptest --- .github/workflows/ub-detection.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ub-detection.yml b/.github/workflows/ub-detection.yml index ca4b8b6..cda1168 100644 --- a/.github/workflows/ub-detection.yml +++ b/.github/workflows/ub-detection.yml @@ -19,4 +19,6 @@ jobs: - run: | rustup +nightly component add miri cargo +nightly miri setup - MIRIFLAGS="-Zmiri-strict-provenance" cargo +nightly miri test --lib + PROPTEST_DISABLE_FAILURE_PERSISTENCE=true \ + MIRIFLAGS="-Zmiri-env-forward=PROPTEST_DISABLE_FAILURE_PERSISTENCE -Zmiri-strict-provenance" \ + cargo +nightly miri test --lib From 1642abbdf69c0a5dcd27de5380df44a0ba5377b4 Mon Sep 17 00:00:00 2001 From: Alexander Abdugafarov Date: Mon, 22 Sep 2025 22:52:26 +0500 Subject: [PATCH 2/2] Added proptest to workspace dependencies --- Cargo.toml | 1 + template_crate/Cargo.toml | 3 +++ template_crate/src/lib.rs | 11 +++++++++++ 3 files changed, 15 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 88aeeda..49d9fde 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ license = "Apache-2.0" # TODO(template) update license if needed publish = false [workspace.dependencies] +proptest = "1" [workspace.lints.rust] missing_docs = "deny" diff --git a/template_crate/Cargo.toml b/template_crate/Cargo.toml index aa411db..e0b327d 100644 --- a/template_crate/Cargo.toml +++ b/template_crate/Cargo.toml @@ -14,6 +14,9 @@ license.workspace = true # code break after upgrades thiserror = { version = "1.0", default-features = false } +[dev-dependencies] +proptest = { workspace = true } + # TODO(template) # don't forget to put this at every crate # to inherit workspace's lints diff --git a/template_crate/src/lib.rs b/template_crate/src/lib.rs index ba9e493..f3b62de 100644 --- a/template_crate/src/lib.rs +++ b/template_crate/src/lib.rs @@ -46,6 +46,7 @@ pub fn sub_small_integers(a: u8, b: u8) -> Result { #[cfg(test)] mod tests { use super::*; + use proptest::proptest; #[test] fn addition_of_bounded() { @@ -67,4 +68,14 @@ mod tests { add_small_integers(UPPER_BOUND - 1, UPPER_BOUND - 1) ); } + + proptest! { + #[test] + fn addition_proptest(a in 0_u8..20, b in 0_u8..20) { + assert_eq!( + a.checked_add(b), + add_small_integers(a, b).ok() + ); + } + } }