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

Add --lockfile-path flag #14326

Merged
merged 12 commits into from
Aug 16, 2024
Merged

Add --lockfile-path flag #14326

merged 12 commits into from
Aug 16, 2024

Conversation

Ifropc
Copy link
Contributor

@Ifropc Ifropc commented Jul 31, 2024

This change implements a new --lockfile-path proposed in #5707 .

Functionality added:

  • Add --lockfile-path <PATH> to all commands that support manifest-path with exception of:
    • locate-project (doesn't use lock file)
    • verify-project (is deprecated)
    • read-manifest (doesn't use lock file)
  • Behind -Zunstable-options and docs
    • The flag's docs / --help has (unstable) in them
  • <PATH> must end with Cargo.lock. If specified path doesn't exist (or parent director(ies), create all the parent directories and the lockfile itself

Implementation TLDR: add requested_lockfile_path into Workspace and set it on workspace(gctx) call (setting from the context)
Update lockfile.lock_root() to respect requested_lockfile_path (if set)
Add test cases covering all affected commands. Tested creating lockfile, reading lockfile, overriding default (./Cargo.lock) lockfile, symlink tests. Extra tests for package to make sure pinned versions from path's lockfile are respected (i.e. double check correct lockfile is used)
I doubt this flag will be used for any command that's not read-only, but I tried to cover all the commands.

- Also add necessary tests for the new flag
- All commands that support `manifest-path` (except `locate-project`, `verify-project` and `read-manifest`)
@rustbot
Copy link
Collaborator

rustbot commented Jul 31, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @epage (or someone else) some time within the next two weeks.

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 S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. labels Aug 14, 2024
bors added a commit that referenced this pull request Aug 14, 2024
doc: convert comments to rustdoc in workspace

Converting workspace comments into docs and adding docs on members that were missing it.
[Original discussion](#14326 (comment))
tests/testsuite/lockfile_path.rs Outdated Show resolved Hide resolved
tests/testsuite/lockfile_path.rs Outdated Show resolved Hide resolved
tests/testsuite/lockfile_path.rs Outdated Show resolved Hide resolved
tests/testsuite/lockfile_path.rs Outdated Show resolved Hide resolved
tests/testsuite/lockfile_path.rs Outdated Show resolved Hide resolved
tests/testsuite/lockfile_path.rs Show resolved Hide resolved
tests/testsuite/lockfile_path.rs Outdated Show resolved Hide resolved
tests/testsuite/lockfile_path.rs Outdated Show resolved Hide resolved
tests/testsuite/lockfile_path.rs Outdated Show resolved Hide resolved
tests/testsuite/lockfile_path.rs Outdated Show resolved Hide resolved
@weihanglo
Copy link
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 15, 2024
@Ifropc
Copy link
Contributor Author

Ifropc commented Aug 16, 2024

Thanks for your patience @weihanglo !
@rustbot review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. labels Aug 16, 2024
Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

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

Thanks @Ifropc for your patience and contribution!

This is in a good state to merge. It is still unstable so if any bug emerges we can always fix later!

@weihanglo
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 16, 2024

📌 Commit 04f9e2d has been approved by weihanglo

It is now in the queue for this repository.

@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 Aug 16, 2024
@bors
Copy link
Collaborator

bors commented Aug 16, 2024

⌛ Testing commit 04f9e2d with merge 3293d22...

@weihanglo
Copy link
Member

weihanglo commented Aug 16, 2024

@Ifropc

Here are some tasks we can do in follow-ups, if you're still interested :)

#5707 (comment)

For feature gated tests, we should have

  • One without -Zunstable-options and fails.
  • One with -Zunstable-options but not with masquerade_as_nightly_cargo.

For reference:

fn chdir_gated() {
let p = project()
.file("Cargo.toml", &basic_bin_manifest("foo"))
.build();
p.cargo("-C foo build")
.cwd(p.root().parent().unwrap())
.with_stderr_data(str![[r#"
[ERROR] the `-C` flag is unstable, pass `-Z unstable-options` on the nightly channel to enable it
"#]])
.with_status(101)
.run();
// No masquerade should also fail.
p.cargo("-C foo -Z unstable-options build")
.cwd(p.root().parent().unwrap())
.with_stderr_data(str![[r#"
[ERROR] the `-C` flag is unstable, pass `-Z unstable-options` on the nightly channel to enable it
"#]])
.with_status(101)
.run();
}

@epage
Copy link
Contributor

epage commented Aug 16, 2024

If we're going back and making changes, please rename make_execs to something that describes what it does, rather than based on its return type. Personally, I would recommend removing it. It adds an extra layer of indirection (opaqueness) for little benefit.

@bors
Copy link
Collaborator

bors commented Aug 16, 2024

☀️ Test successful - checks-actions
Approved by: weihanglo
Pushing 3293d22 to master...

@bors bors merged commit 3293d22 into rust-lang:master Aug 16, 2024
22 checks passed
@Ifropc Ifropc deleted the 5707-lock-path branch August 17, 2024 02:13
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 17, 2024
Update cargo

8 commits in 2f738d617c6ead388f899802dd1a7fd66858a691..ba8b39413c74d08494f94a7542fe79aa636e1661
2024-08-13 10:57:52 +0000 to 2024-08-16 22:48:57 +0000
- feat(update): Report when incompatible-rust-version packages are selected (rust-lang/cargo#14401)
- test: Migrate old_cargos to snapbox (rust-lang/cargo#14410)
- Correct diagnostic for `TomlDebugInfo` (rust-lang/cargo#14413)
- Add `--lockfile-path` flag (rust-lang/cargo#14326)
- test: Migrate some json tests to snapbox (rust-lang/cargo#14402)
- Implement base paths (RFC 3529) 1/n: path dep and patch support (rust-lang/cargo#14360)
- doc: convert comments to rustdoc in workspace (rust-lang/cargo#14397)
- Fix MSRV for workspace .package and .dependencies (rust-lang/cargo#14400)

r? ghost
@rustbot rustbot added this to the 1.82.0 milestone Aug 17, 2024
bors added a commit that referenced this pull request Aug 18, 2024
Lockfile path tests (follow-up)

Addressing comments by [Weihang](#14326 (comment)) and [Ed](#14326 (comment)) from #14326
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants