Skip to content

Commit bb07767

Browse files
committed
Bump deps including cairo annotations
commit-id:a7276965
1 parent cf9b6a4 commit bb07767

File tree

5 files changed

+53
-82
lines changed

5 files changed

+53
-82
lines changed

Diff for: Cargo.lock

+27-27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ edition = "2024"
1414
cairo-lang-sierra = "2.10.1"
1515
cairo-lang-sierra-to-casm = "2.10.1"
1616
cairo-lang-starknet-classes = "2.10.1"
17-
cairo-annotations = "0.2.2"
17+
cairo-annotations = "0.3.0"
1818

1919
anyhow = "1.0.96"
2020
assert_fs = "1.1.2"
2121
camino = "1.1.9"
22-
clap = { version = "4.5.30", features = ["derive"] }
22+
clap = { version = "4.5.31", features = ["derive"] }
2323
criterion = "0.5"
24-
console = "0.15.10"
24+
console = "0.15.11"
2525
itertools = "0.14.0"
2626
ignore = "0.4.23"
2727
serde = "1.0.218"
2828
serde_json = "1.0.139"
29-
scarb-metadata = "1.13.0"
29+
scarb-metadata = "1.14.0"
3030
snapbox = "0.6.21"
3131
semver = "1.0.25"
3232
indoc = "2.0.5"

Diff for: crates/cairo-coverage-core/src/build/filter/ignore_matcher.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::build::filter::statement_category_filter::VIRTUAL_FILE_REGEX;
21
use anyhow::{Error, Result};
32
use camino::{Utf8Path, Utf8PathBuf};
43
use ignore::Match;
@@ -34,7 +33,7 @@ pub struct CairoCoverageIgnoreMatcher(Gitignore);
3433
impl CairoCoverageIgnoreMatcher {
3534
/// Check if the given path is ignored by the [`CAIRO_COVERAGE_IGNORE`] file.
3635
pub fn is_ignored(&self, path: &str) -> bool {
37-
let path: Utf8PathBuf = VIRTUAL_FILE_REGEX.replace_all(path, "").to_string().into();
36+
let path: Utf8PathBuf = path.to_string().into();
3837
let result = self.0.matched(&path, path.is_dir());
3938
matches!(result, Match::Ignore(_))
4039
}

Diff for: crates/cairo-coverage-core/src/build/filter/statement_category_filter.rs

+9-19
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,10 @@ use crate::build::filter::ignore_matcher::CairoCoverageIgnoreMatcher;
33
use crate::build::filter::libfuncs;
44
use crate::build::filter::libfuncs::NOT_RELIABLE_LIBFUNCS;
55
use crate::loading::enriched_program::EnrichedProgram;
6-
use cairo_annotations::annotations::coverage::SourceFileFullPath;
76
use cairo_annotations::annotations::profiler::FunctionName;
87
use cairo_lang_sierra::program::StatementIdx;
98
use camino::Utf8PathBuf;
10-
use regex::Regex;
119
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());
1710

1811
/// Statement category filter that is used to filter out statements that should not be included in the coverage report.
1912
/// `included_components` and `ignore_matcher` are references to reduce the amount of data that needs to be copied.
@@ -57,32 +50,29 @@ impl StatementCategoryFilter<'_> {
5750
&self,
5851
idx: StatementIdx,
5952
function_name: &FunctionName,
60-
source_file_full_path: &SourceFileFullPath,
53+
source_file_full_path: &str,
54+
is_macro: bool,
6155
) -> bool {
62-
self.is_allowed_macro(function_name, source_file_full_path)
56+
self.is_allowed_macro(function_name, is_macro)
6357
&& self.is_user_function(source_file_full_path)
6458
&& self.is_reliable_libfunc(idx)
6559
&& self.is_not_ignored(source_file_full_path)
6660
}
6761

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 {
7363
if self.test_functions.contains(function_name) {
7464
self.included_components
7565
.contains(&IncludedComponent::TestFunctions)
76-
} else if VIRTUAL_FILE_REGEX.is_match(&source_file_full_path.0) {
66+
} else if is_macro {
7767
self.included_components
7868
.contains(&IncludedComponent::Macros)
7969
} else {
8070
true
8171
}
8272
}
8373

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)
8676
}
8777

8878
fn is_reliable_libfunc(&self, idx: StatementIdx) -> bool {
@@ -92,7 +82,7 @@ impl StatementCategoryFilter<'_> {
9282
.is_some_and(|libfunc_name| NOT_RELIABLE_LIBFUNCS.contains(libfunc_name))
9383
}
9484

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)
9787
}
9888
}

Diff for: crates/cairo-coverage-core/src/build/statement_information.rs

+12-30
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use crate::build::filter::statement_category_filter::{
2-
StatementCategoryFilter, VIRTUAL_FILE_REGEX,
3-
};
1+
use crate::build::filter::statement_category_filter::StatementCategoryFilter;
42
use cairo_annotations::annotations::coverage::{
53
CodeLocation, CoverageAnnotationsV1, LineNumber, SourceCodeSpan, SourceFileFullPath,
64
VersionedCoverageAnnotations,
@@ -26,16 +24,6 @@ pub struct StatementInformation {
2624
pub line_range: LineRange,
2725
}
2826

29-
impl StatementInformation {
30-
pub fn remove_virtual_file_prefix(&mut self) {
31-
self.source_file_full_path = SourceFileFullPath(
32-
VIRTUAL_FILE_REGEX
33-
.replace_all(&self.source_file_full_path.0, "")
34-
.to_string(),
35-
);
36-
}
37-
}
38-
3927
#[derive(Deserialize, Clone, Eq, PartialEq)]
4028
pub struct LineRange {
4129
/// Line number is 1-based
@@ -93,24 +81,18 @@ fn get_statement_information(
9381
function_names: Vec<FunctionName>,
9482
filter: &StatementCategoryFilter,
9583
) -> Option<StatementInformation> {
96-
code_locations
97-
.into_iter()
98-
.zip(function_names)
99-
.find(|(CodeLocation(source_file_full_path, _), function_name)| {
100-
filter.should_include(idx, function_name, source_file_full_path)
101-
})
102-
.map(
103-
|(CodeLocation(source_file_full_path, line_range), function_name)| {
104-
StatementInformation {
84+
code_locations.into_iter().zip(function_names).find_map(
85+
|(CodeLocation(source_file_full_path, line_range, is_macro), function_name)| {
86+
let (path, marking) = source_file_full_path.remove_virtual_file_markings();
87+
let is_macro = is_macro.unwrap_or(!marking.is_empty());
88+
filter
89+
.should_include(idx, &function_name, path, is_macro)
90+
.then(|| StatementInformation {
10591
function_name,
106-
source_file_full_path,
92+
source_file_full_path: SourceFileFullPath(path.to_string()),
10793
line_range: line_range.into(),
10894
idx,
109-
}
110-
},
111-
)
112-
.map(|mut statement_origin| {
113-
statement_origin.remove_virtual_file_prefix();
114-
statement_origin
115-
})
95+
})
96+
},
97+
)
11698
}

0 commit comments

Comments
 (0)