From c5393d1fe34839ef5eff672727b601eaefb7908c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Mar 2026 12:30:35 +0000 Subject: [PATCH 1/6] Initial plan From eb81dff695a9f63e0f5d681b429223e3262a837f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Mar 2026 12:36:13 +0000 Subject: [PATCH 2/6] fix: add coverage(off) outer attribute on mod test_util declaration Co-authored-by: psandana <1194304+psandana@users.noreply.github.com> --- codecov.yml | 2 -- crates/ohno/src/lib.rs | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/codecov.yml b/codecov.yml index f669938f1..8fb7fa500 100644 --- a/codecov.yml +++ b/codecov.yml @@ -10,5 +10,3 @@ coverage: base: auto ignore: - "crates/testing_aids/**/*" -# this is a temporary fix, for some reason codecov ignores cfg option in the file itself -- "crates/ohno/src/test_util.rs" diff --git a/crates/ohno/src/lib.rs b/crates/ohno/src/lib.rs index cac54b714..6b2c84c98 100644 --- a/crates/ohno/src/lib.rs +++ b/crates/ohno/src/lib.rs @@ -262,6 +262,7 @@ mod enrichment_entry; mod error_ext; mod source; +#[cfg_attr(coverage_nightly, coverage(off))] #[cfg(any(feature = "test-util", test))] pub mod test_util; From 940e7cbe60d792a8a58c7c0f118f6dfff671af8c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Mar 2026 13:54:06 +0000 Subject: [PATCH 3/6] fix: remove redundant inner coverage(off) and add it to mod tests in test_util.rs Co-authored-by: psandana <1194304+psandana@users.noreply.github.com> --- crates/ohno/src/test_util.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/ohno/src/test_util.rs b/crates/ohno/src/test_util.rs index 4ee14e9b0..73526101e 100644 --- a/crates/ohno/src/test_util.rs +++ b/crates/ohno/src/test_util.rs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -#![cfg_attr(coverage_nightly, coverage(off))] // coverage doesn't handle panics well - //! Test utilities for the ohno crate. //! //! This module is only available when the `test-util` feature is enabled. @@ -50,6 +48,7 @@ macro_rules! assert_error_message { }}; } +#[cfg_attr(coverage_nightly, coverage(off))] #[cfg(test)] mod tests { use crate::OhnoCore; From af1b45bf5d249347c09fd9843af842de1af3e14f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Mar 2026 15:02:39 +0000 Subject: [PATCH 4/6] fix: extract assert_error_message logic to coverage(off) function to fix LLVM macro expansion attribution Co-authored-by: psandana <1194304+psandana@users.noreply.github.com> --- crates/ohno/src/test_util.rs | 39 ++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/crates/ohno/src/test_util.rs b/crates/ohno/src/test_util.rs index 73526101e..a7e45384a 100644 --- a/crates/ohno/src/test_util.rs +++ b/crates/ohno/src/test_util.rs @@ -28,24 +28,29 @@ /// ``` #[macro_export] macro_rules! assert_error_message { - ($error:expr, $expected:expr) => {{ - let error_string = $error.to_string(); - let expected: &str = $expected; + ($error:expr, $expected:expr) => { + $crate::test_util::assert_error_message_impl($error.to_string(), $expected) + }; +} - let test = move || { - if error_string == expected { - return (); - } - if let Some(remainder) = error_string.strip_prefix(expected) { - // backtrace, caused by, or error trace indicators - if remainder.starts_with("\n\nBacktrace:\n") || remainder.starts_with("\ncaused by: ") || remainder.starts_with("\n> ") { - return (); - } - } - panic!("left : {expected}\nright: {error_string}"); - }; - test(); - }}; +/// Implementation helper for [`assert_error_message!`]. +/// +/// # Note +/// +/// This is an implementation detail of the [`assert_error_message!`] macro. Do not call directly. +#[doc(hidden)] +#[cfg_attr(coverage_nightly, coverage(off))] +pub fn assert_error_message_impl(error_string: String, expected: &str) { + if error_string == expected { + return; + } + if let Some(remainder) = error_string.strip_prefix(expected) { + // backtrace, caused by, or error trace indicators + if remainder.starts_with("\n\nBacktrace:\n") || remainder.starts_with("\ncaused by: ") || remainder.starts_with("\n> ") { + return; + } + } + panic!("left : {expected}\nright: {error_string}"); } #[cfg_attr(coverage_nightly, coverage(off))] From 96583f1143667dd98588b32588d8f6122cd497c3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Mar 2026 16:14:29 +0000 Subject: [PATCH 5/6] fix: clippy errors in assert_error_message_impl and incorporate main rollback (#321) Co-authored-by: psandana <1194304+psandana@users.noreply.github.com> --- crates/ohno/src/test_util.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/ohno/src/test_util.rs b/crates/ohno/src/test_util.rs index a7e45384a..26ecfae51 100644 --- a/crates/ohno/src/test_util.rs +++ b/crates/ohno/src/test_util.rs @@ -29,7 +29,7 @@ #[macro_export] macro_rules! assert_error_message { ($error:expr, $expected:expr) => { - $crate::test_util::assert_error_message_impl($error.to_string(), $expected) + $crate::test_util::assert_error_message_impl(&$error.to_string(), $expected) }; } @@ -40,7 +40,8 @@ macro_rules! assert_error_message { /// This is an implementation detail of the [`assert_error_message!`] macro. Do not call directly. #[doc(hidden)] #[cfg_attr(coverage_nightly, coverage(off))] -pub fn assert_error_message_impl(error_string: String, expected: &str) { +#[expect(clippy::panic, reason = "test assertion helper — panicking is the intended behavior")] +pub fn assert_error_message_impl(error_string: &str, expected: &str) { if error_string == expected { return; } From 38d7c54b07e43920813f1e7922200d04c3c3649e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pato=20Sanda=C3=B1a?= Date: Wed, 11 Mar 2026 15:39:27 -0300 Subject: [PATCH 6/6] undo some copilot changes --- crates/ohno/src/lib.rs | 1 - crates/ohno/src/test_util.rs | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ohno/src/lib.rs b/crates/ohno/src/lib.rs index 6b2c84c98..cac54b714 100644 --- a/crates/ohno/src/lib.rs +++ b/crates/ohno/src/lib.rs @@ -262,7 +262,6 @@ mod enrichment_entry; mod error_ext; mod source; -#[cfg_attr(coverage_nightly, coverage(off))] #[cfg(any(feature = "test-util", test))] pub mod test_util; diff --git a/crates/ohno/src/test_util.rs b/crates/ohno/src/test_util.rs index 26ecfae51..1bfb38387 100644 --- a/crates/ohno/src/test_util.rs +++ b/crates/ohno/src/test_util.rs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +#![cfg_attr(coverage_nightly, coverage(off))] // coverage doesn't handle panics well + //! Test utilities for the ohno crate. //! //! This module is only available when the `test-util` feature is enabled. @@ -54,7 +56,6 @@ pub fn assert_error_message_impl(error_string: &str, expected: &str) { panic!("left : {expected}\nright: {error_string}"); } -#[cfg_attr(coverage_nightly, coverage(off))] #[cfg(test)] mod tests { use crate::OhnoCore;