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

test-env-log used with test-case creates test duplicates #101

Open
luke-biel opened this issue Jun 29, 2022 · 0 comments · May be fixed by #143
Open

test-env-log used with test-case creates test duplicates #101

luke-biel opened this issue Jun 29, 2022 · 0 comments · May be fixed by #143
Labels
bug Something isn't working

Comments

@luke-biel
Copy link
Collaborator

When I use the latest test-case and test-log (new name of test-env-log) together, I get duplicate copies of each test generated.
I also tried it with what I think were the versions from when this issue was created and have the same problem.

Full example in this gist

#[cfg(test)]
mod tests {
    use test_case::test_case;

    #[test_case(0, 0 ; "the same")]
    #[test_case(0, 1 ; "different")]
    #[test_log::test]
    // #[test_env_log::test]
    fn equality(a: usize, b: usize) {
        log::info!("a: {}", a);
        log::info!("b: {}", b);
        assert_eq!(a, b)
    }
}
Output
running 4 tests
test tests::equality::the_same ... ok
test tests::equality::the_same ... ok
test tests::equality::different ... FAILED
test tests::equality::different ... FAILED

failures:

---- tests::equality::different stdout ----
thread 'tests::equality::different' panicked at 'assertion failed: `(left == right)`
  left: `0`,
 right: `1`', main.rs:18:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- tests::equality::different stdout ----
thread 'tests::equality::different' panicked at 'assertion failed: `(left == right)`
  left: `0`,
 right: `1`', main.rs:18:9


failures:
    tests::equality::different
    tests::equality::different

test result: FAILED. 2 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

error: test failed, to rerun pass '--bin main'

Originally posted by @newsch in #69 (comment)

@luke-biel luke-biel added the bug Something isn't working label Jun 29, 2022
yuvalsw added a commit to starkware-libs/cairo that referenced this issue Nov 21, 2022
Macro for logging with test_case. Might be needed once this bug is fixed:
frondeus/test-case#101
See here:
https://docs.google.com/document/d/1zAbVqlSNeM5zaOqt4b-hFISlKy6ua9bh0mm99SHrb4E/edit#
kezhuw added a commit to kezhuw/test-case that referenced this issue Apr 17, 2024
This pr proposes a generic mechanism among different test proc macros to
avoid to generate multiple `[::core::prelude::v1::test]` on test method.

`proc_macro_attribute` function is fed with tokens after its attribute
and no tokens before it.

Give the above, this pr proposes test proc macros to append newly
generated macros after existing ones. This way, proc macros processed
later can read all macros including generated and handwritten and make
further decisions. Specifically, proc macros can append
`#[::core::prelude::v1::test]` only if it does not exist.

Macros that transform test method signature can append
`#[::core::prelude::v1::test]` directly without checking its existence
once they generate valid signature for test method.

Closes frondeus#101.
@kezhuw kezhuw linked a pull request Apr 17, 2024 that will close this issue
kezhuw added a commit to kezhuw/test-case that referenced this issue Apr 19, 2024
This pr proposes a generic mechanism among different test proc macros to
avoid to generate multiple `[::core::prelude::v1::test]` on test method.

`proc_macro_attribute` function is fed with tokens after its attribute
and no tokens before it.

Give the above, this pr proposes test proc macros to append newly
generated macros after existing ones. This way, proc macros processed
later can read all macros including generated and handwritten and make
further decisions. Specifically, proc macros can append
`#[::core::prelude::v1::test]` only if it does not exist.

Closes frondeus#101.
kezhuw added a commit to kezhuw/test-log that referenced this issue Apr 19, 2024
This way if preceding test macros add `#[::core::prelude::v1::test]` by
appending, then we can avoid duplicated test runs.

See also frondeus/test-case#101, frondeus/test-case#143

Closes d-e-s-o#35.
kezhuw added a commit to kezhuw/test-case that referenced this issue Nov 19, 2024
This pr proposes a generic mechanism among different test proc macros to
avoid to generate multiple `[::core::prelude::v1::test]` on test method.

`proc_macro_attribute` function is fed with tokens after its attribute
and no tokens before it.

Give the above, this pr proposes test proc macros to append newly
generated macros after existing ones. This way, proc macros processed
later can read all macros including generated and handwritten and make
further decisions. Specifically, proc macros can append
`#[::core::prelude::v1::test]` only if it does not exist.

Macros that transform test method signature can append
`#[::core::prelude::v1::test]` directly without checking its existence
once they generate valid signature for test method.

Closes frondeus#101, frondeus#146.
kezhuw added a commit to kezhuw/test-case that referenced this issue Nov 20, 2024
This pr proposes a generic mechanism among different test proc macros to
avoid to generate multiple `[::core::prelude::v1::test]` on test method.

`proc_macro_attribute` function is fed with tokens after its attribute
and no tokens before it.

Give the above, this pr proposes test proc macros to append newly
generated macros after existing ones. This way, proc macros processed
later can read all macros including generated and handwritten and make
further decisions. Specifically, proc macros can append
`#[::core::prelude::v1::test]` only if it does not exist.

Macros that transform test method signature can append
`#[::core::prelude::v1::test]` directly without checking its existence
once they generate valid signature for test method.

Closes frondeus#101, frondeus#146.
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
None yet
Development

Successfully merging a pull request may close this issue.

1 participant