-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit-id:f6098cdc
- Loading branch information
Showing
12 changed files
with
213 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
crates/cairo-coverage/tests/data/coverage_ignore/Scarb.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[package] | ||
name = "coverage_ignore" | ||
version = "0.1.0" | ||
edition = "2024_07" | ||
|
||
# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html | ||
[dependencies] | ||
starknet = ">=2.8.0" | ||
|
||
[dev-dependencies] | ||
snforge_std = "0.30.0" | ||
|
||
[[target.starknet-contract]] | ||
sierra = true | ||
|
||
[scripts] | ||
test = "snforge test" | ||
|
||
[profile.dev.cairo] | ||
unstable-add-statements-functions-debug-info = true | ||
unstable-add-statements-code-locations-debug-info = true | ||
inlining-strategy= "avoid" |
2 changes: 2 additions & 0 deletions
2
crates/cairo-coverage/tests/data/coverage_ignore/src/lib.cairo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mod simple; | ||
mod multiply; |
13 changes: 13 additions & 0 deletions
13
crates/cairo-coverage/tests/data/coverage_ignore/src/multiply.cairo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
pub fn multiply(a: i32, b: i32) -> i32 { | ||
a * b | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::multiply; | ||
|
||
#[test] | ||
fn it_works() { | ||
assert(multiply(2, 1) == 2, ''); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
crates/cairo-coverage/tests/data/coverage_ignore/src/simple.cairo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mod simple_add; | ||
mod simple_subtract; |
15 changes: 15 additions & 0 deletions
15
crates/cairo-coverage/tests/data/coverage_ignore/src/simple/simple_add.cairo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
pub fn add(a: i32, b: i32) -> i32 { | ||
a + b | ||
} | ||
|
||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::add; | ||
|
||
#[test] | ||
fn it_works() { | ||
assert(add(1, 2) == 3, ''); | ||
} | ||
} | ||
|
14 changes: 14 additions & 0 deletions
14
crates/cairo-coverage/tests/data/coverage_ignore/src/simple/simple_subtract.cairo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
pub fn subtract(a: i32, b: i32) -> i32 { | ||
a - b | ||
} | ||
|
||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::subtract; | ||
|
||
#[test] | ||
fn it_works() { | ||
assert(subtract(2, 1) == 1, ''); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use crate::helpers::TestProject; | ||
|
||
#[test] | ||
fn coverage_ignore_dir() { | ||
TestProject::new("coverage_ignore") | ||
.create_cairo_coverage_ignore("*/simple/*") | ||
.run() | ||
.output_same_as_in_file("coverage_ignore_dir.lcov"); | ||
} | ||
|
||
#[test] | ||
fn coverage_ignore_files2() { | ||
TestProject::new("coverage_ignore") | ||
.create_cairo_coverage_ignore("simple_*.cairo") | ||
.run() | ||
.output_same_as_in_file("coverage_ignore_dir.lcov"); | ||
} | ||
|
||
#[test] | ||
fn coverage_ignore_files() { | ||
TestProject::new("coverage_ignore") | ||
.create_cairo_coverage_ignore("multiply.cairo\nsimple_add.cairo") | ||
.run() | ||
.output_same_as_in_file("coverage_ignore_file.lcov"); | ||
} | ||
|
||
#[test] | ||
fn coverage_ignore_file_does_not_exists() { | ||
TestProject::new("coverage_ignore") | ||
.create_cairo_coverage_ignore("multiply.cairo\nsimple_add.cairo\nnot_existing.cairo") | ||
.run() | ||
.output_same_as_in_file("coverage_ignore_file.lcov"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
mod cairo_coverage_ignore; | ||
mod general; |
10 changes: 10 additions & 0 deletions
10
crates/cairo-coverage/tests/expected_output/coverage_ignore_dir.lcov
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
TN: | ||
SF:{dir}/src/multiply.cairo | ||
FN:2,coverage_ignore::multiply::multiply | ||
FNDA:1,coverage_ignore::multiply::multiply | ||
FNF:1 | ||
FNH:1 | ||
DA:2,1 | ||
LF:1 | ||
LH:1 | ||
end_of_record |
10 changes: 10 additions & 0 deletions
10
crates/cairo-coverage/tests/expected_output/coverage_ignore_file.lcov
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
TN: | ||
SF:{dir}/src/simple/simple_subtract.cairo | ||
FN:2,coverage_ignore::simple::simple_subtract::subtract | ||
FNDA:1,coverage_ignore::simple::simple_subtract::subtract | ||
FNF:1 | ||
FNH:1 | ||
DA:2,1 | ||
LF:1 | ||
LH:1 | ||
end_of_record |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters