Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicated test results in src when modules are added to lib.cairo #173

Closed
cptartur opened this issue Jul 14, 2023 · 2 comments · Fixed by #245
Closed

Duplicated test results in src when modules are added to lib.cairo #173

cptartur opened this issue Jul 14, 2023 · 2 comments · Fixed by #245
Assignees
Labels
bug Something isn't working

Comments

@cptartur
Copy link
Member

cptartur commented Jul 14, 2023

With the project structure like

/src/fib.rs

fn fib(a: felt252, b: felt252, n: felt252) -> felt252 {
    match n {
        0 => a,
        _ => fib(b, a + b, n - 1),
    }
}

#[test]
fn test_fib() {
    assert(fib(0, 1, 10) == 55, fib(0, 1, 10));
}

/src/lib.rs

mod fib;

Test results are duplicated in the output

Collected 2 test(s) and 2 test file(s)
Running 1 test(s) from src/fib.cairo
[PASS] fib::fib::test_fib
Running 1 test(s) from src/lib.cairo
[PASS] src::fib::test_fib
Tests: 2 passed, 0 failed, 0 skipped

Most likely the tests from fib.rs get collected when running collect_tests on lib.rs since they are reachable from there. Then we collect them again from fib.rs directly, causing the duplication. This should be fixed, so we do not collect test duplicates.

@cptartur cptartur added this to the Forge milestone Jul 14, 2023
@cptartur cptartur added the bug Something isn't working label Jul 14, 2023
@cptartur cptartur changed the title Only search for tests in src/ in lib.cairo Duplicated test results in src when modules are added to lib.cairo Jul 14, 2023
@MaksymilianDemitraszek
Copy link
Member

This actually sounds like a pretty important problem. Maybe worth moving it up to backlog?

@cptartur
Copy link
Member Author

cptartur commented Jul 17, 2023

We can discuss tomorrow, when exactly we want to resolve it. I agree it's a problem, though it's not breaking any runner functionality, "just" duplicating tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants