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

Checking for binary that is built as an implicit dependency of an integration test. #8020

Merged
merged 2 commits into from
Mar 27, 2020

Conversation

xiongmao86
Copy link
Contributor

@xiongmao86 xiongmao86 commented Mar 19, 2020

When a project containing binary with required-features, the binary will only be built with the given dependency's feature is enabled. But this feature syntax is not checked when the binary is built as an implicit dependency of an integration test. This pr addresses this issue.

More info is in the issue page: this pr fixes #7853.

@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 @alexcrichton (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 Mar 19, 2020
@alexcrichton
Copy link
Member

Oh wow I'm actually a bit surprised we allowed this in required-features! In any case mind leaving a comment in the code explaining what it's doing? Otherwise looks good to me, thanks for the PR!

@ehuss
Copy link
Contributor

ehuss commented Mar 19, 2020

Oh, and just a heads up, resolve_all_features may need to change as part of #7950, so we should be careful with coordinating these two changes at the same time.

@xiongmao86
Copy link
Contributor Author

xiongmao86 commented Mar 20, 2020

@alexcrichton @ehuss, thank you for reviewing the pr.

In any case mind leaving a comment in the code explaining what it's doing?

I'll try to add comment as the last step.

@xiongmao86
Copy link
Contributor Author

Oh, and just a heads up, resolve_all_features may need to change as part of #7950, so we should be careful with coordinating these two changes at the same time.

What do you mean by coordinating these two changes? Can you elaborate?

@aleksator
Copy link
Contributor

What do you mean by coordinating these two changes? Can you elaborate?

I think that the PR which is going to be merged second might have to deal with some conflicts.
Since yours looks almost done, it would have to be me in 7950, so you have nothing to worry about.

@xiongmao86
Copy link
Contributor Author

Oh, right. Thank you for explaining @aleksator.

@bors
Copy link
Collaborator

bors commented Mar 24, 2020

☔ The latest upstream changes (presumably #8028) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just one minor nit!

src/cargo/ops/mod.rs Outdated Show resolved Hide resolved
@ehuss ehuss assigned ehuss and unassigned alexcrichton Mar 26, 2020
@aleksator
Copy link
Contributor

@xiongmao86 Also, don't forget to squash the history ;)

@aleksator
Copy link
Contributor

@xiongmao86 I'd put tests in the same commit as changes they are supposed to test as well.
But I'm not a maintainer here and don't know how the people prefer it in this project, just what I would consider a good practice.

@ehuss
Copy link
Contributor

ehuss commented Mar 27, 2020

Thanks!
@bors r+

@bors
Copy link
Collaborator

bors commented Mar 27, 2020

📌 Commit 8b17895 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 Mar 27, 2020
@bors
Copy link
Collaborator

bors commented Mar 27, 2020

⌛ Testing commit 8b17895 with merge 1e2f8db...

@bors
Copy link
Collaborator

bors commented Mar 27, 2020

☀️ Test successful - checks-azure
Approved by: ehuss
Pushing 1e2f8db to master...

@bors bors merged commit 1e2f8db into rust-lang:master Mar 27, 2020
@aleksator
Copy link
Contributor

Congrats on the first successful PR!

@xiongmao86
Copy link
Contributor Author

@alexcrichton, @ehuss, @aleksator, thank you very much for helping me with this pr.

I'd put tests in the same commit as changes they are supposed to test as well.
But I'm not a maintainer here and don't know how the people prefer it in this project, just what I would consider a good practice.

Perhaps because of the three phase of writing code in agile development: test, implement, refactor. Here refactor is mix with implement because of squash?

@xiongmao86 xiongmao86 deleted the issue7853 branch March 28, 2020 11:50
@Eh2406
Copy link
Contributor

Eh2406 commented Mar 28, 2020

I'd put tests in the same commit as changes they are supposed to test as well.

That does sound like a good ideal, but as a maintainer of this project we do not require a clean history in a PR. If you want to rewrite history so each commit makes sense on its own, in whatever way makes you happy, grate! If you what to record the order you actually made changes, with all of the wrong turns, also grate!

@xiongmao86
Copy link
Contributor Author

Thank you for your tips, @Eh2406, so I am free to choose squash or not. But some repo does need to squash, what is the possible reason, is it possible in some specific situation that one approach is preferable than the other?

@Eh2406
Copy link
Contributor

Eh2406 commented Mar 29, 2020

Some people/projects really value clean historys, or the ability to bisect to an individual commit. There going to tend to want edited historys, or if that is to much work squashing. Other project put there priorities on different things.

@xiongmao86
Copy link
Contributor Author

So it's a delicate tradeoff, and depend on project and people. Thank you @Eh2406.

@aleksator
Copy link
Contributor

aleksator commented Mar 30, 2020

@xiongmao86 In my opinion, it's always good to have, but forcing it requires some amount of work, which for open source project might not be worth it and can turn off contributors if applied too rigidly. That's why cargo chooses not to (I think).

At my workplace we choose to do so, as it has clear benefits and it's easy to have discipline within a small team, but much harder with potentially all of the internet for open source projects.

For me it's easier to understand a feature that way, when the commit is self contained. You don't have to waste time tracking down what is this test supposed to check, when you can just click on a line annotation in an IDE and be shown connected feature right there. And vise versa, when you make changes you know which tests you will need to fix.

Perhaps because of the three phase of writing code in agile development: test, implement, refactor. Here refactor is mix with implement because of squash?

As you are developing a new feature, from the point of project's view refactoring does not exist yet. You should squash it and hide your work in progress, as it is only harmful noise.
It's a good idea to make a local branch with full history backup in case something goes wrong with the rebase, but it's not a master branch material.

That said, when you change the existing code, that is refactoring that's important to show others. It should never be mixed into your new feature commit, but always provided separately.
This way you can easily track down bugs if something is broken: was it due to the refactoring or a new feature addition. If you are in a hurry, you can revert just that one bit with one click.

@xiongmao86
Copy link
Contributor Author

xiongmao86 commented Mar 30, 2020

@aleksator, I see your point, in this case the test is good to commit with the feature. but sometimes the change is too big to squash together, as what the test account for is separate into several commits, then it is hard or sometimes impossible(if what I add is a single test) to separate the test, this is a time I feel a test is stand out as a single commit content. So is it ok to do so in this case, or there is actually a better way to divide the changes?

@xiongmao86
Copy link
Contributor Author

I have read about the concept of incremental development that is we should take small steps to change code base, in this prospect, will large changes inherently bad to show up? Would this be the answer to my doubts above?

@Eh2406
Copy link
Contributor

Eh2406 commented Mar 31, 2020

I have not worked in a "you must squash all PRs" codebase, and it seems a extreme position to me. But to each their own. I have contributed to "commits should be incremental and interpretable" codebase. If a PR comes in that took a lot of commits to do something straightforward, squashing can be an improvement. If a big PR comes in, to big to understand in one sitting, asking that the contributor ( who probably, just having written it, understand it better than anyone ) to split it up into commits/PRs that can be reviewed one at a time, can also be reasonable.

Just like how splitting your code into functions can make it easier to read. Does not mean that more functions is always better. You as a programer need to use functions to communicate what you were trying to do. Git/PRs/commits are the same way. Use the tools you have in moderation and with judgment to make your intent intelligible to others.

@xiongmao86
Copy link
Contributor Author

@aleksator, @Eh2406, I see your point. Thank you very much for explaining.

@aleksator
Copy link
Contributor

@Eh2406 Our views aren't different, actually. I'd do the same in the situation you described.

Centril added a commit to Centril/rust that referenced this pull request Apr 2, 2020
Update cargo

8 commits in 8a0d4d9c9abc74fd670353094387d62028b40ae9..6e07d2dfb7fc87b1c9489de41da4dafa239daf03
2020-03-24 17:57:04 +0000 to 2020-03-31 03:22:39 +0000
- Fix man page typo for "Owner Options". (rust-lang/cargo#8057)
- enable progress bar on all UNIX platforms (rust-lang/cargo#8054)
- Squelch some rustdoc warnings. (rust-lang/cargo#8052)
- Remove clippy tests. (rust-lang/cargo#8053)
- Fix -Zfeatures=itarget with certain host dependencies (rust-lang/cargo#8048)
- Checking for binary that is built as an implicit dependency of an integration test. (rust-lang/cargo#8020)
- Use stabilized version of rustdoc's --crate-version (rust-lang/cargo#8039)
- Remove the `git-checkout` subcommand. (rust-lang/cargo#8040)
Centril added a commit to Centril/rust that referenced this pull request Apr 2, 2020
Update cargo

8 commits in 8a0d4d9c9abc74fd670353094387d62028b40ae9..6e07d2dfb7fc87b1c9489de41da4dafa239daf03
2020-03-24 17:57:04 +0000 to 2020-03-31 03:22:39 +0000
- Fix man page typo for "Owner Options". (rust-lang/cargo#8057)
- enable progress bar on all UNIX platforms (rust-lang/cargo#8054)
- Squelch some rustdoc warnings. (rust-lang/cargo#8052)
- Remove clippy tests. (rust-lang/cargo#8053)
- Fix -Zfeatures=itarget with certain host dependencies (rust-lang/cargo#8048)
- Checking for binary that is built as an implicit dependency of an integration test. (rust-lang/cargo#8020)
- Use stabilized version of rustdoc's --crate-version (rust-lang/cargo#8039)
- Remove the `git-checkout` subcommand. (rust-lang/cargo#8040)
@ehuss ehuss added this to the 1.44.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.

required-features implicit binaries for test does not check for dep syntax
7 participants