-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add option to ignore directories from coverage report #7301
feat: add option to ignore directories from coverage report #7301
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you also need to format with cargo +nightly fmt --all
@@ -151,6 +154,30 @@ impl CoverageReport { | |||
} | |||
Ok(()) | |||
} | |||
|
|||
pub fn filter_out_ignored_sources(&mut self, filter: &impl CoverageFilter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
self.items = new_items; | ||
} | ||
|
||
fn get_source_path(&self, version: &Version, source_id: usize) -> String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
crates/forge/bin/cmd/test/filter.rs
Outdated
@@ -40,6 +41,10 @@ pub struct FilterArgs { | |||
value_name = "GLOB" | |||
)] | |||
pub path_pattern_inverse: Option<GlobMatcher>, | |||
|
|||
/// Only show coverage for files that do not match the specified glob pattern. | |||
#[arg(long = "no-coverage-path", visible_alias = "ncp", value_name = "GLOB")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's name it ignore instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed
Hi @dimazhornyk thanks for your PR! Looks like this is almost ready for review, would be great to get this merged To resolve the formatting issue make sure to run: |
sorry about dropping this @dimazhornyk ... if you don't have the capacity for fixing the conflicts, we can take it from here @zerosnacks |
Closing this PR in favor of #8321 I've included the commits of @dimazhornyk |
Motivation
Some files shouldn't be displayed in a coverage report, e.g. utility contracts or dev contracts, and currently there is no way to ignore them from the coverage report. There is a popular issue describing the problem #2988.
Solution
This PR introduces such a possibility using a cli argument
--no-coverage-path
or config keyno_coverage_path
.On the implementation side, it filters out all the ignored files right before the report output. It can't be done earlier because there may be files dependent on the ignored ones, which will not be covered if we remove the ignored files earlier.