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

fix: Allow embedded manifests in all commands #12289

Merged
merged 8 commits into from
Jun 21, 2023
Merged

Conversation

epage
Copy link
Contributor

@epage epage commented Jun 20, 2023

What does this PR try to resolve?

This is a part of #12207.

One of the goals is for embedded manifests to be a first class citizen. If you have a script, you should be able to run tests on it, for example.

This expands the error check from just Cargo.toml to also single-file packages so you can use it in --manifest-path.

This, however, does mean that these can be used in places that likely won't work yet, like cargo publish.

How should we test and review this PR?

By commit. We introduce tests for basic commands and then implement and refine the support for this.

Additional information

Other information you want to mention in this PR, such as prior arts,
future extensions, an unresolved problem, or a TODO list.

I originally centralized the error reporting until I realized it likely
is intentionally not centralized so we report errors in terms of the
arguments the user provided.
@rustbot
Copy link
Collaborator

rustbot commented Jun 20, 2023

r? @ehuss

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added A-cli Area: Command-line interface, option parsing, etc. A-manifest Area: Cargo.toml issues Command-run S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 20, 2023
There should be a later check when parsing but just in case, let's have
a check here as well.
@epage epage marked this pull request as ready for review June 20, 2023 02:27
epage added a commit to epage/typos that referenced this pull request Jun 20, 2023
In 3a29410, we switched to anstream
which doesn't seem to be locking properly (rust-lang/cargo#12289).  For
now, we are working around it.

Fixes crate-ci#749
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.

Looks good. Just wanting more tests to cover these error paths.

let ext = path.extension();
ext.is_none() || ext == Some(OsStr::new("rs"))
ext == Some(OsStr::new("rs")) ||
Copy link
Member

Choose a reason for hiding this comment

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

  • Should we always verify that embedded manifest is a file?
  • Can we have some tests around this? Like failure when script.rs is a directory.
  • (Not a blocker) Is it worth having a better error message for each failed case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we always verify that embedded manifest is a file?

We have a separate, more specific error check for that.

(Not a blocker) Is it worth having a better error message for each failed case?

What do you have in mind?

Copy link
Member

Choose a reason for hiding this comment

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

  • When missing file at manifest-path, it shows
    error: the manifest-path must be a path to a Cargo.toml file
    
  • When script.rs is a directory, it shows
    error: failed to read `/projects/cargo/test.rs`
    
    Caused by:
      Is a directory (os error 21)
    

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When script.rs is a directory, it shows

This is true for Cargo.toml as well. We can more generally improve it though that is unrelated to this PR

src/cargo/util/command_prelude.rs Outdated Show resolved Hide resolved
@weihanglo
Copy link
Member

Thanks for the update!

@bors r+

@bors
Copy link
Contributor

bors commented Jun 21, 2023

📌 Commit d8583f4 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 Jun 21, 2023
@bors
Copy link
Contributor

bors commented Jun 21, 2023

⌛ Testing commit d8583f4 with merge 4cebd13...

@bors
Copy link
Contributor

bors commented Jun 21, 2023

☀️ Test successful - checks-actions
Approved by: weihanglo
Pushing 4cebd13 to master...

@bors bors merged commit 4cebd13 into rust-lang:master Jun 21, 2023
@epage epage deleted the basic branch June 21, 2023 19:49
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 22, 2023
Update cargo

2 commits in dead4b8740c4b6a8ed5211e37c99cf81d01c3b1c..4cebd130ebca3bc219180a54f3e26cc1b14a91de
2023-06-20 20:07:17 +0000 to 2023-06-21 18:59:29 +0000
- fix: Allow embedded manifests in all commands (rust-lang/cargo#12289)
- feat(cli): Support `cargo Cargo.toml` (rust-lang/cargo#12281)

r? `@ghost`
@ehuss ehuss added this to the 1.72.0 milestone Jun 22, 2023
phip1611 pushed a commit to phip1611/typos that referenced this pull request Dec 5, 2023
In 3a29410, we switched to anstream
which doesn't seem to be locking properly (rust-lang/cargo#12289).  For
now, we are working around it.

Fixes crate-ci#749
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cli Area: Command-line interface, option parsing, etc. A-manifest Area: Cargo.toml issues Command-run 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.

5 participants