-
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
check --tests
always succeeds if you have test = false
in Cargo.toml
#9536
Comments
When passing a target selection flag, that tells cargo to check the specified targets instead of the default set of targets. With I think, perhaps, cargo could print a warning if using |
If we do |
I think for now it should just be a warning. It might otherwise break legitimate use cases. An example is the rust build system, which here blindly passes a bunch of flags to different packages which may or may not contain all those targets. We probably don't want a bunch of noisy warnings in that case. I also think this warning should only appear if no targets were found in total. That is, It is totally OK to claim, and let me know if you need any help. There's a guide here for writing and running tests. |
The formatting looks good, feel free to post a PR and we can go over it in more detail. I wouldn't bother with special-casing if something like |
Warn if an "all" target is specified, but we don't match anything If a combination of --bins, --benches, --examples, --tests flags have been specified, but we didn't match on anything after resolving the unit-list, we emit a warning to make it clear that cargo didn't do anything and that the code is unchecked. This is my first PR and there are a couple things that I'm unsure about * The integration test covers only one case (ideally it should cover every combination of the above mentioned flags the user can pass). I figured since the warning function is so simple, it'd best not to clog the testsuite with unnecessary `p.cargo().runs()` and whatnot. If I should make the test more comprehensive I can do that, it's also very easy to write unit tests so i can do that as well if needed. * I figure we don't actually have to check the `--all-targets`, but i'm doing so for consistency. I also didn't check for the `--lib` flag at all because (I'm assuming) if the user passes `--lib` and there are no libraries, we error. Edit: I notice (among other things) we sometimes silently skip certain units that have incompatible feature flags (see [here](https://github.com/rust-lang/cargo/blob/ed0c8c6d66e36fafbce4f78907a110838797ae39/src/cargo/ops/cargo_compile.rs#L1140)) so maybe we should be checking the `--lib` flag after all, in the event that a library was silently skipped and we no-opped 🤔 And thanks to `@ehuss` for taking the time to answer my questions and helping me through the contribution process, much appreciated Closes #9536
Problem
If a crate has
in its Cargo.toml and you run
cargo check --tests
the crate always compiles regardless of what errors might actually be there.I would expect
--tests
to still fail to compile or at least emit a clear warning.Steps
git clone https://github.com/davidpdrsn/cargo-bug
cd cargo-bug
cargo check --tests
compilescargo check
does not compileNotes
Output of
cargo version
:cargo 1.52.0 (69767412a 2021-04-21)
The text was updated successfully, but these errors were encountered: