-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
cargo test
compiles twice
#851
Comments
Can you provide an example to look at? What's probably happening is that cargo is running If you don't want to build your library with |
Here is a run of
|
Do you have any binaries or integration tests ( |
Here is the code. It's a tiny project at the moment because I can't figure out boxed unboxed closures 😜 but testing it with There are |
Hm, did you mean to include a link in there? |
|
Aha! That definitely shouldn't be compiling twice, thanks @nixpulvis! I'll take a look into this hopefully soon. |
❤️ |
Isn’t the other compile a dependency of running |
I don't think doctests should be opt in. I like that they are part of This might be a bad idea, but maybe it actually might make sense to allow |
I don’t mean making doctest opt-in, only to avoid running zero doctests when Cargo can determine there are indeed zero, if that can be determine quickly. |
But then the moment you add doctests then your back into the same problem. |
I don’t see the problem. When you add doctests you don’t have zero doctests anymore and so Cargo should not detect that you have zero doctests anymore (again, assuming this detection is feasible) and would start running doctests again. This magic "detection" would run every time you run |
The problem is with the original problem of showing two compilations right next to each other with all their warnings and errors. |
Ah, sorry I misunderstood. Yes indeed. I believe the reason for that is that |
Ah yes, @SimonSapin is right, I forgot about doc tests! For now I don't think Cargo will try to detect the presence or non-presence of doc tests as it would involve a dependency on rustdoc itself. If you'd like to just see one set of warnings at a time you can pass |
This is going to be a pain point for adoption and usability. Just my 2 cents. |
I was experiencing this problem, or something similar. When I would run "cargo test" the tests defined in my library are getting run by the main executable as well as in the library, so they ran twice. Adding "test = false" for the library in my manifest fixed it. Thanks Alex! It doesn't matter now, but here is my code: |
I think this is a poor user experience. For quite a while I've been dealing with duplicate output from |
@jimmycuadra You can add |
Yes, that is what I did. It's just totally non-obvious that that's why you see double output by default. |
This is still painful FWIW, getting a lot of unused warnings, and double errors on failed compiles. |
@alexcrichton I understand the technical reason why this happens now, but since it is still a confusing user experience (as noted by duplicates of this issue in various forms continuing to be opened), would you be amenable to either reopening this issue, or me opening a new issue specifically for discussion and tracking of possible ways to address user confusion about the output? |
@jimmycuadra that's tracked by #1854 |
(FWIW, I ignored duplicates for three months in hopes the "bug" would be fixed. If there's a pain points FAQ/wiki I'd be glad to contribute to it). |
@nathanaeljones do you have integration tests ( |
Yes, I do. That makes sense, thanks! |
I'd echo the user experience complaints. As a newcomer, the current behaviour (still the case as of 1.30) is extremely baffling. I don't think it should be considered "fixed". |
I'm adding my voice to the chorus with this. Duplicate messages by default makes an extremely poor and unprofessional user experience. Though a minor issue, the fact that it continues to be pointedly ignored after so many years (now 1.41.0) only exacerbates matters. It reveals an administrative problem that doesn't speak well for Rust as a project. |
Hello, from Jul 2020; 6 years later, and still a thing. As with @lilith, |
@alexcrichton @SimonSapin I realize that this issue thread is kind of messy and apologize for that, but I do not feel like it should be considered closed. Would it be possible to reopen? or create a new issue without the mess for this bad user experience? |
@nixpulvis I don't think this should be reopened because due to the way Rust testing works, the library fundamentally needs to be built twice. However, we have been planning to add some kind of deduplicate support. I realize we never opened an issue to track that, so I have opened #9104. |
@ehuss awesome, thanks for doing that. |
Running
cargo test
compiles the code twice before running the compiled tester binary. This is obviously irritating to look at when there are a bunch of warnings and the like, and is also much slower.The text was updated successfully, but these errors were encountered: