11use clap:: Parser ;
2- use forge :: TestFilter ;
2+ use foundry_common :: TestFilter ;
33use foundry_compilers:: { FileFilter , ProjectPathsConfig } ;
44use foundry_config:: { filter:: GlobMatcher , Config } ;
55use std:: { fmt, path:: Path } ;
@@ -38,6 +38,10 @@ pub struct FilterArgs {
3838 value_name = "GLOB"
3939 ) ]
4040 pub path_pattern_inverse : Option < GlobMatcher > ,
41+
42+ /// Only show coverage for files that do not match the specified regex pattern.
43+ #[ arg( long = "no-match-coverage" , visible_alias = "nmco" , value_name = "REGEX" ) ]
44+ pub coverage_pattern_inverse : Option < regex:: Regex > ,
4145}
4246
4347impl FilterArgs {
@@ -71,6 +75,9 @@ impl FilterArgs {
7175 if self . path_pattern_inverse . is_none ( ) {
7276 self . path_pattern_inverse = config. path_pattern_inverse . clone ( ) . map ( Into :: into) ;
7377 }
78+ if self . coverage_pattern_inverse . is_none ( ) {
79+ self . coverage_pattern_inverse = config. coverage_pattern_inverse . clone ( ) . map ( Into :: into) ;
80+ }
7481 ProjectPathsAwareFilter { args_filter : self , paths : config. project_paths ( ) }
7582 }
7683}
@@ -84,6 +91,7 @@ impl fmt::Debug for FilterArgs {
8491 . field ( "no-match-contract" , & self . contract_pattern_inverse . as_ref ( ) . map ( |r| r. as_str ( ) ) )
8592 . field ( "match-path" , & self . path_pattern . as_ref ( ) . map ( |g| g. as_str ( ) ) )
8693 . field ( "no-match-path" , & self . path_pattern_inverse . as_ref ( ) . map ( |g| g. as_str ( ) ) )
94+ . field ( "no-match-coverage" , & self . coverage_pattern_inverse . as_ref ( ) . map ( |g| g. as_str ( ) ) )
8795 . finish_non_exhaustive ( )
8896 }
8997}
@@ -152,6 +160,9 @@ impl fmt::Display for FilterArgs {
152160 if let Some ( p) = & self . path_pattern_inverse {
153161 writeln ! ( f, "\t no-match-path: `{}`" , p. as_str( ) ) ?;
154162 }
163+ if let Some ( p) = & self . coverage_pattern_inverse {
164+ writeln ! ( f, "\t no-match-coverage: `{}`" , p. as_str( ) ) ?;
165+ }
155166 Ok ( ( ) )
156167 }
157168}
@@ -178,6 +189,11 @@ impl ProjectPathsAwareFilter {
178189 pub fn args_mut ( & mut self ) -> & mut FilterArgs {
179190 & mut self . args_filter
180191 }
192+
193+ /// Returns the project paths.
194+ pub fn paths ( & self ) -> & ProjectPathsConfig {
195+ & self . paths
196+ }
181197}
182198
183199impl FileFilter for ProjectPathsAwareFilter {
0 commit comments