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

Ensure package IDs are unique when cleaning. #12708

Closed
wants to merge 1 commit into from

Conversation

jfgoog
Copy link

@jfgoog jfgoog commented Sep 19, 2023

get_many will panic if there are duplicate IDs.

@rustbot
Copy link
Collaborator

rustbot commented Sep 19, 2023

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

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added Command-clean S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 19, 2023
src/cargo/ops/cargo_clean.rs Outdated Show resolved Hide resolved
@@ -104,7 +105,7 @@ pub fn clean(ws: &Workspace<'_>, opts: &CleanOptions<'_>) -> CargoResult<()> {
// Doc tests produce no output.

// Get Packages for the specified specs.
let mut pkg_ids = Vec::new();
let mut pkg_ids = BTreeSet::new();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a test for this? Ideally the first commit would have the test with a #[should_panic] and then the second commit would include this with the test updated. Using these two commits will make it easier to ensure the test is testing the right thing and to show to reviewers what the intended behavior change is (especially since this is a PR without an issue)

Copy link
Author

Choose a reason for hiding this comment

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

I took a quick look at this, and adding a test seems fairly complicated. There are not any tests in cargo_clean.rs, and most of it consists of a monolithic clean() function, in which this code change is buried. I would need to construct an appropriate Workspace object, which is fairly complicated.

It looks like there are some cursory integration tests, but adding something would require figuring out exactly how to trigger a duplicate ID, which might be tricky.

Overall, it doesn't look at all straightforward to test. :( I will keep poking at it, though, and see if I can figure anything out.

Copy link
Contributor

Choose a reason for hiding this comment

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

Look in tests/testsuite/clean.rs for tests.

@bors
Copy link
Contributor

bors commented Sep 20, 2023

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

get_many will panic if there are duplicate IDs.
@jfgoog
Copy link
Author

jfgoog commented Sep 20, 2023

After pulling in #12638 I am no longer getting a panic, so I am going to abandon this.

@jfgoog jfgoog closed this Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Command-clean S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants