Skip to content

Commit cf9b6a4

Browse files
committed
Categorize to stable and unstable
commit-id:cc497b8f
1 parent 93105df commit cf9b6a4

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
#### Added
1111
- warning if the current scarb version doesn't support not including macros in the coverage report
12+
- `--unstable` flag to enable unstable features. Read more about it [here](./README.md#coverage-across-different-scarb-versions)
1213

1314
#### Changed
1415
- macros are now by default included in the coverage report. If you want to exclude them, use the `--include` without the

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,19 @@ Using the `--help` flag with any command will display additional information abo
6969
cairo-coverage clean --help
7070
```
7171

72+
### Coverage Across Different Scarb Versions
73+
74+
`cairo-coverage` relies heavily on `scarb` and the internal workings of the `cairo` compiler, which can lead to variations in behavior depending on the `scarb` version used.
75+
76+
To ensure consistency in coverage reports across different versions of `scarb`, we have categorized features into **stable** and **unstable**:
77+
78+
- **Stable features** provide consistent results across all versions of `scarb`.
79+
- **Unstable features** may produce different results depending on the `scarb` version.
80+
81+
A feature is considered **stable** if it produces the same results across all minor versions of `scarb` from `2.8.*` onward, using the latest patch version.
82+
83+
To enable unstable features, use the `--unstable` flag.
84+
7285
### `.cairo-coverage-ignore` File
7386

7487
You can create a `.cairo-coverage-ignore` file in the root of your project to specify the files or directories that you

crates/cairo-coverage/src/args/run.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@ pub struct RunArgs {
1414
pub output_path: Utf8PathBuf,
1515

1616
/// Include additional components in the coverage report.
17-
#[arg(long, short, num_args = 0.., default_value = "macros")]
17+
#[arg(long, short, num_args = 0.., default_value = "macros", requires = "unstable")]
1818
pub include: Vec<IncludedComponent>,
1919

2020
/// If set, the hit count of the lines will not be truncated to 1.
21-
#[arg(long)]
21+
#[arg(long, requires = "unstable")]
2222
pub no_truncation: bool,
2323

24+
/// If set, the unstable features are enabled.
25+
#[arg(long)]
26+
pub unstable: bool,
27+
2428
/// Path to the project directory. If not provided, the project directory is inferred using `scarb metadata`.
2529
#[arg(value_parser = parse_project_path, long)]
2630
pub project_path: Option<Utf8PathBuf>,

crates/cairo-coverage/src/commands/run.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub fn run(
1515
output_path,
1616
trace_files,
1717
no_truncation,
18+
unstable: _,
1819
}: RunArgs,
1920
) -> Result<()> {
2021
let metadata = scarb_metadata()?;

crates/cairo-coverage/tests/e2e/general.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn simple() {
1212
#[cfg(feature = "allows-excluding-macros")]
1313
fn simple_with_tests() {
1414
TestProject::new("simple")
15-
.coverage_args(&["--include", "test-functions"])
15+
.coverage_args(&["--unstable", "--include", "test-functions"])
1616
.run()
1717
.output_same_as_in_file("simple_with_tests.lcov");
1818
}
@@ -63,7 +63,7 @@ fn macros() {
6363
#[cfg(feature = "allows-excluding-macros")]
6464
fn macros_not_included() {
6565
TestProject::new("macros")
66-
.coverage_args(&["--include"])
66+
.coverage_args(&["--unstable", "--include"])
6767
.run_without_genhtml()
6868
.assert_empty_output();
6969
}
@@ -79,7 +79,7 @@ fn snforge_template() {
7979
#[cfg(feature = "allows-excluding-macros")]
8080
fn snforge_template_macros_not_included() {
8181
TestProject::new("snforge_template")
82-
.coverage_args(&["--include"])
82+
.coverage_args(&["--unstable", "--include"])
8383
.run()
8484
.output_same_as_in_file("snforge_template_macros_not_included.lcov");
8585
}

0 commit comments

Comments
 (0)