fix: codecov ignoring coverage(off) for test_util module#319
fix: codecov ignoring coverage(off) for test_util module#319
coverage(off) for test_util module#319Conversation
coverage(off) for test_util module
|
@copilot fix your fix |
Fixed in df0b762. The inner |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #319 +/- ##
=======================================
Coverage 100.0% 100.0%
=======================================
Files 152 152
Lines 9337 9337
=======================================
Hits 9337 9337 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@copilot your fix is still not working. Check if we need to add this: before using the coverage attribute |
... No change needed here. The current fix (commit |
@copilot the CI run is passing, but codecov is not. |
... Fixed in aef6ccf. The root cause was LLVM macro expansion attribution: when a The fix extracts the macro logic into a |
|
@copilot rebase this branch and fix static analysis |
Fixed in 5f06265. Two clippy errors were causing static-analysis failures:
Also incorporated all changes from the main rollback of #312 ( |
Co-authored-by: psandana <1194304+psandana@users.noreply.github.com>
…test_util.rs Co-authored-by: psandana <1194304+psandana@users.noreply.github.com>
…fix LLVM macro expansion attribution Co-authored-by: psandana <1194304+psandana@users.noreply.github.com>
…rollback (#321) Co-authored-by: psandana <1194304+psandana@users.noreply.github.com>
5f06265 to
96583f1
Compare
coverage(off) for test_util modulecoverage(off) for test_util module
There was a problem hiding this comment.
Pull request overview
Adjusts ohno’s test-utility coverage handling so Codecov stops flagging test_util while keeping the helper usable via a macro.
Changes:
- Refactors
assert_error_message!to delegate to a#[doc(hidden)]helper function (with targeted lint/coverage attributes). - Removes the
crates/ohno/src/test_util.rsignore entry fromcodecov.yml.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/ohno/src/test_util.rs | Refactors the assertion macro into a thin wrapper over a helper function and adds per-item coverage/lint attributes. |
| codecov.yml | Drops the temporary ignore rule for crates/ohno/src/test_util.rs. |
Comments suppressed due to low confidence (1)
codecov.yml:13
- Removing the Codecov ignore for
crates/ohno/src/test_util.rslooks premature: in the current branch,crates/ohno/src/lib.rsstill declarespub mod test_util;without an outer#[cfg_attr(coverage_nightly, coverage(off))], so Codecov/LLVM will continue to count this file and likely reintroduce the low-coverage warning (given the repo’s 100% target). Either add the outercoverage(off)on themod test_utilitem (preferred), or keep this ignore rule until that’s in place and verified in CI.
ignore:
- "crates/testing_aids/**/*"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
Is test_util a module strictly used by ohno tests, or can it be used by customers of ohno as well? |
| #[doc(hidden)] | ||
| #[cfg_attr(coverage_nightly, coverage(off))] | ||
| #[expect(clippy::panic, reason = "test assertion helper — panicking is the intended behavior")] | ||
| pub fn assert_error_message_impl(error_string: &str, expected: &str) { |
There was a problem hiding this comment.
this code was intentionally a part of a macro so when a test fails, it will point you to the caller
also, making hidden pub function is not the best choice if we can avoid it
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| #![cfg_attr(coverage_nightly, coverage(off))] // coverage doesn't handle panics well |
There was a problem hiding this comment.
this pr doesn't fix the core issue where #![cfg_attr(coverage_nightly, coverage(off))] is ignored
There was a problem hiding this comment.
there is another place where we get the same problem: #316 , this time it's not a macro
There was a problem hiding this comment.
I think focusing on ohno is the wrong approach, it seems like the issue is with codecov setup
There was a problem hiding this comment.
The problem seems to be the macro, as the macro is expanded on each file. But let me see which other options do we have.
it can be used by customers as well for validating their errors |
|
So if it can be used by customers, then disabling code coverage seems wrong. |
#[cfg_attr(coverage_nightly, coverage(off))]outer attribute tomod test_utildeclaration incrates/ohno/src/lib.rsassert_error_message!macro logic into apub fn assert_error_message_implwith#[doc(hidden)]and#[cfg_attr(coverage_nightly, coverage(off))], and make the macro a thin wrapper that delegates to itclippy::needless_pass_by_value: changeerror_string: Stringtoerror_string: &strand update macro call site to&$error.to_string()clippy::panic: use#[expect(clippy::panic, reason = "test assertion helper — panicking is the intended behavior")](satisfies bothallow_attributesandallow_attributes_without_reasonworkspace lints)#[cfg_attr(coverage_nightly, coverage(off))]to themod testsblock insidetest_util.rs, consistent with codebase conventioncrates/ohno/src/test_util.rsfromcodecov.ymlBox<dyn Error>and make them transparent #312):core.rs,Cargo.toml,Cargo.lock,ohno/Cargo.toml,.spelling, and remove#![forbid(unsafe_code)]fromlib.rsOriginal prompt
coverage(off)#318✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.