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

Warn if an "all" target is specified, but we don't match anything #9549

Merged
merged 1 commit into from
Jun 9, 2021
Merged

Warn if an "all" target is specified, but we don't match anything #9549

merged 1 commit into from
Jun 9, 2021

Conversation

Bryysen
Copy link
Contributor

@Bryysen Bryysen commented Jun 7, 2021

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) 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

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Eh2406 (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 7, 2021
@Eh2406
Copy link
Contributor

Eh2406 commented Jun 9, 2021

Looks like Eric was helping you design this, so assigning the revue to him.
@bors r? @ehuss

@rust-highfive rust-highfive assigned ehuss and unassigned Eh2406 Jun 9, 2021
@ehuss
Copy link
Contributor

ehuss commented Jun 9, 2021

Thanks, this looks great!

Don't worry too much about testing every situation. I think the test you have as-is looks good.

I don't think --lib needs to be checked, since it doesn't allow required-features, so it can't be silently skipped.

There is a situation where --all-targets can be hit. If you have a bin-only package, and the bin has required-features that are not met, then --all-targets will result in 0 units. If you want to add that check back in, I think that would be fine. Or if not, that's fine, too, since I think that should be extremely rare and I suspect the user can figure out what's going on from the warning.

@Bryysen
Copy link
Contributor Author

Bryysen commented Jun 9, 2021

I'll add it back in, it's a very cheap operation (another if branch). I'll also squash the commits into one.

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.

Closes #9536
@Bryysen
Copy link
Contributor Author

Bryysen commented Jun 9, 2021

Hopefully i'm doing this correctly, still new to the github workflow. Should be good to go.

@ehuss
Copy link
Contributor

ehuss commented Jun 9, 2021

Looks good, thanks!

@bors r+

@bors
Copy link
Contributor

bors commented Jun 9, 2021

📌 Commit da1c2f3 has been approved by ehuss

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 9, 2021
@bors
Copy link
Contributor

bors commented Jun 9, 2021

⌛ Testing commit da1c2f3 with merge 46ba901...

@bors
Copy link
Contributor

bors commented Jun 9, 2021

☀️ Test successful - checks-actions
Approved by: ehuss
Pushing 46ba901 to master...

@bors bors merged commit 46ba901 into rust-lang:master Jun 9, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Jun 11, 2021
Update cargo

10 commits in aa8b09297bb3156b849e73db48af4cd050492fe6..81537ee3f7bd97ff7821b6c86c148764d40d26cd
2021-06-09 00:28:53 +0000 to 2021-06-11 00:00:14 +0000
- Change how the fix_deny_warnings_but_not_others test works (rust-lang/cargo#9571)
- Add mising documentation regarding `cargo doc` (rust-lang/cargo#9565)
- Implement warning for ignored trailing arguments (rust-lang/cargo#9561)
- Make clippy happy (rust-lang/cargo#9569)
- Fix rustc/rustdoc config values to be config-relative. (rust-lang/cargo#9566)
- Update rustfix. (rust-lang/cargo#9567)
- Warn if an "all" target is specified, but we don't match anything (rust-lang/cargo#9549)
- add default_run to SerializedPackage (rust-lang/cargo#9550)
- respect user choice of lib/bin over heuristics (rust-lang/cargo#9522)
- Add a mean to mutably access the members of a workspace (rust-lang/cargo#9547)
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jun 11, 2021
Update cargo

10 commits in aa8b09297bb3156b849e73db48af4cd050492fe6..81537ee3f7bd97ff7821b6c86c148764d40d26cd
2021-06-09 00:28:53 +0000 to 2021-06-11 00:00:14 +0000
- Change how the fix_deny_warnings_but_not_others test works (rust-lang/cargo#9571)
- Add mising documentation regarding `cargo doc` (rust-lang/cargo#9565)
- Implement warning for ignored trailing arguments (rust-lang/cargo#9561)
- Make clippy happy (rust-lang/cargo#9569)
- Fix rustc/rustdoc config values to be config-relative. (rust-lang/cargo#9566)
- Update rustfix. (rust-lang/cargo#9567)
- Warn if an "all" target is specified, but we don't match anything (rust-lang/cargo#9549)
- add default_run to SerializedPackage (rust-lang/cargo#9550)
- respect user choice of lib/bin over heuristics (rust-lang/cargo#9522)
- Add a mean to mutably access the members of a workspace (rust-lang/cargo#9547)
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 12, 2021
Update cargo

11 commits in aa8b09297bb3156b849e73db48af4cd050492fe6..44456677b5d1d82fe981c955dc5c67734b31f340
2021-06-09 00:28:53 +0000 to 2021-06-12 18:00:01 +0000
- Fix package_default_run test. (rust-lang/cargo#9577)
- Change how the fix_deny_warnings_but_not_others test works (rust-lang/cargo#9571)
- Add mising documentation regarding `cargo doc` (rust-lang/cargo#9565)
- Implement warning for ignored trailing arguments (rust-lang/cargo#9561)
- Make clippy happy (rust-lang/cargo#9569)
- Fix rustc/rustdoc config values to be config-relative. (rust-lang/cargo#9566)
- Update rustfix. (rust-lang/cargo#9567)
- Warn if an "all" target is specified, but we don't match anything (rust-lang/cargo#9549)
- add default_run to SerializedPackage (rust-lang/cargo#9550)
- respect user choice of lib/bin over heuristics (rust-lang/cargo#9522)
- Add a mean to mutably access the members of a workspace (rust-lang/cargo#9547)
@ehuss ehuss added this to the 1.55.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

check --tests always succeeds if you have test = false in Cargo.toml
5 participants