-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Multiple #[test]
attributes run the test multiple times.
#90979
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I think we should emit a warning in such case, that shouldn't be too complicated. @Ethiraric said they would be interested into working on it so I'll assign them and help them implementing it. |
@GuillaumeGomez can i work on this one?. |
No, as indicated in my message, @Ethiraric is already working on it. EDIT: It was a bit rough I think so let me extend my initial message a bit: if you want to contribute, there are other |
FYI, PR #88681 is open to check for duplicate attributes. It doesn't handle test/bench because those are proc-macros, and it can be tricky to detect duplicates on those (see #88681 (comment)). So just a heads up this may not be particularly easy. I'm curious why it doesn't fail this check during subsequent passes. |
…rochenkov Warn when a `#[test]`-like built-in attribute macro is present multiple times. Fixes rust-lang#90979.
#[ip_test] and #[fuchsia::test] both emit #[test], rust allows that and creates 2 tests with the same name: rust-lang/rust#90979. Skip emitting #[test] for #[ip_test] so we correctly only run each test once. Change-Id: I6a6a6964d1712721e364051f7af20589c50098e6 Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1284549 Fuchsia-Auto-Submit: Zeling Feng <zeling@google.com> Reviewed-by: Bruno Dal Bo <brunodalbo@google.com> Commit-Queue: Auto-Submit <auto-submit-builder@fuchsia-internal-service-accts.iam.gserviceaccount.com>
If a function has multiple
#[test]
attributes, the test is run as many times as the attribute is repeated withcargo test
.The following code runs
doing_the_thing
8 times:I expected to see this happen: The compiler errors
Instead, this happened: It compiles fine and the test is run 8 times
Meta
rustc --version --verbose
:Happens on nightly as well:
cc @GuillaumeGomez
The text was updated successfully, but these errors were encountered: