From 64cb43c7db8ff13ff92a9abbc7f766a14d975b06 Mon Sep 17 00:00:00 2001 From: doug-q <141026920+doug-q@users.noreply.github.com> Date: Thu, 16 May 2024 09:22:54 +0100 Subject: [PATCH] test: really ignore tests which depend on typetag when cfg(miri) (#1058) Previous fix failed because the `#[ignore]` attribute only applies to the first `#[case]`. --- hugr/src/ops/constant.rs | 3 ++- hugr/src/ops/constant/custom.rs | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/hugr/src/ops/constant.rs b/hugr/src/ops/constant.rs index 2d1a5dce2..5d11df71e 100644 --- a/hugr/src/ops/constant.rs +++ b/hugr/src/ops/constant.rs @@ -156,7 +156,8 @@ pub enum Value { /// is another `CustomSerialized` we do not attempt to recurse. This behaviour /// may change in future. /// -/// ```rust +#[cfg_attr(not(miri), doc = "```")] // this doctest depends on typetag, so fails with miri +#[cfg_attr(miri, doc = "```ignore")] /// use serde::{Serialize,Deserialize}; /// use hugr::{ /// types::Type,ops::constant::{OpaqueValue, ValueName, CustomConst, CustomSerialized}, diff --git a/hugr/src/ops/constant/custom.rs b/hugr/src/ops/constant/custom.rs index f9ffcc83b..54a9af514 100644 --- a/hugr/src/ops/constant/custom.rs +++ b/hugr/src/ops/constant/custom.rs @@ -29,7 +29,8 @@ use super::ValueName; /// be serialized with two attributes, `"c"` the tag and `"v"` the /// `CustomConst`: /// -/// ```rust +#[cfg_attr(not(miri), doc = "```")] // this doctest depends on typetag, so fails with miri +#[cfg_attr(miri, doc = "```ignore")] /// use serde::{Serialize,Deserialize}; /// use hugr::{ /// types::Type,ops::constant::{OpaqueValue, ValueName, CustomConst}, @@ -51,7 +52,7 @@ use super::ValueName; /// "c": "CC", /// "v": 2 /// })); -/// ```` +/// ``` #[typetag::serde(tag = "c", content = "v")] pub trait CustomConst: Send + Sync + std::fmt::Debug + CustomConstBoxClone + Any + Downcast @@ -312,7 +313,8 @@ pub fn get_pair_of_input_values( Some((c0.get_custom_value()?, c1.get_custom_value()?)) } -#[cfg(test)] +// these tests depend on the `typetag` crate. +#[cfg(all(test, not(miri)))] mod test { use rstest::rstest;