@@ -3,17 +3,10 @@ use crate::build::filter::ignore_matcher::CairoCoverageIgnoreMatcher;
3
3
use crate :: build:: filter:: libfuncs;
4
4
use crate :: build:: filter:: libfuncs:: NOT_RELIABLE_LIBFUNCS ;
5
5
use crate :: loading:: enriched_program:: EnrichedProgram ;
6
- use cairo_annotations:: annotations:: coverage:: SourceFileFullPath ;
7
6
use cairo_annotations:: annotations:: profiler:: FunctionName ;
8
7
use cairo_lang_sierra:: program:: StatementIdx ;
9
8
use camino:: Utf8PathBuf ;
10
- use regex:: Regex ;
11
9
use std:: collections:: { HashMap , HashSet } ;
12
- use std:: sync:: LazyLock ;
13
-
14
- /// Regex to match virtual files like `/path/to/project/lib.cairo[array_inline_macro][assert_macro]`
15
- /// where `array_inline_macro` and `assert_macro` is a virtual file.
16
- pub static VIRTUAL_FILE_REGEX : LazyLock < Regex > = LazyLock :: new ( || Regex :: new ( r"\[.*?]" ) . unwrap ( ) ) ;
17
10
18
11
/// Statement category filter that is used to filter out statements that should not be included in the coverage report.
19
12
/// `included_components` and `ignore_matcher` are references to reduce the amount of data that needs to be copied.
@@ -57,32 +50,29 @@ impl StatementCategoryFilter<'_> {
57
50
& self ,
58
51
idx : StatementIdx ,
59
52
function_name : & FunctionName ,
60
- source_file_full_path : & SourceFileFullPath ,
53
+ source_file_full_path : & str ,
54
+ is_macro : bool ,
61
55
) -> bool {
62
- self . is_allowed_macro ( function_name, source_file_full_path )
56
+ self . is_allowed_macro ( function_name, is_macro )
63
57
&& self . is_user_function ( source_file_full_path)
64
58
&& self . is_reliable_libfunc ( idx)
65
59
&& self . is_not_ignored ( source_file_full_path)
66
60
}
67
61
68
- fn is_allowed_macro (
69
- & self ,
70
- function_name : & FunctionName ,
71
- source_file_full_path : & SourceFileFullPath ,
72
- ) -> bool {
62
+ fn is_allowed_macro ( & self , function_name : & FunctionName , is_macro : bool ) -> bool {
73
63
if self . test_functions . contains ( function_name) {
74
64
self . included_components
75
65
. contains ( & IncludedComponent :: TestFunctions )
76
- } else if VIRTUAL_FILE_REGEX . is_match ( & source_file_full_path . 0 ) {
66
+ } else if is_macro {
77
67
self . included_components
78
68
. contains ( & IncludedComponent :: Macros )
79
69
} else {
80
70
true
81
71
}
82
72
}
83
73
84
- fn is_user_function ( & self , source_file_full_path : & SourceFileFullPath ) -> bool {
85
- source_file_full_path. 0 . contains ( & self . user_project_path )
74
+ fn is_user_function ( & self , source_file_full_path : & str ) -> bool {
75
+ source_file_full_path. contains ( & self . user_project_path )
86
76
}
87
77
88
78
fn is_reliable_libfunc ( & self , idx : StatementIdx ) -> bool {
@@ -92,7 +82,7 @@ impl StatementCategoryFilter<'_> {
92
82
. is_some_and ( |libfunc_name| NOT_RELIABLE_LIBFUNCS . contains ( libfunc_name) )
93
83
}
94
84
95
- fn is_not_ignored ( & self , source_file_full_path : & SourceFileFullPath ) -> bool {
96
- !self . ignore_matcher . is_ignored ( & source_file_full_path. 0 )
85
+ fn is_not_ignored ( & self , source_file_full_path : & str ) -> bool {
86
+ !self . ignore_matcher . is_ignored ( source_file_full_path)
97
87
}
98
88
}
0 commit comments