-
Notifications
You must be signed in to change notification settings - Fork 952
Warn about CARGO
environment variable in cargo proxy
#4175
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
Conversation
CARGO
environment variable in cargo proxyCARGO
environment variable in cargo proxy
The issue was resolved in the Cargo repository, making this PR moot. However, I humbly consider some of the PR's changes to be improvements to the testing infrastructure. For example, I think 6059cb1 (Do not append EXE_SUFFIX in Config::cmd) is a genuine bugfix Should I submit any of the commits as separate PRs? |
Yes, please! |
@smoelius Thanks for the work! I'm interested in extracted PRs as well. PS: Following the previous discussion, I'm now converting this PR to draft to prevent accidental merges. |
Previously, `Config::cmd` would always append an `EXE_SUFFIX`. However, this would produce an invalid path if the suffix was already present. Extracted from rust-lang#4175
`SanitizedOutput`s have `String` `stdout` and `stderr` fields. This makes `SanitizedOutput`s easier to display than `Output`s. This commit adds a `TryFrom<Output>` implementation for `SanitizedOutput`. In this way, a test can run a command to produce an `Output, and from that `Output` produce a `SanitizedOutput`. Extracted from rust-lang#4175
The function `Config::run_subprocess` takes a program name and a list of arguments, constructs a command from them, and then runs the command. The function this commit adds is similar, but it accepts an already constructed command. Extracted from rust-lang#4175
Currently, when the mocked cargo command is passed `--recursive-cargo-subcommand`, it runs: ``` cargo-foo --recursive-cargo ``` However, cargo subcommands are normally passed their subcommand name as the first argument. Thus, one would expect the following to be run: ``` cargo-foo foo --recursive-cargo ``` This commit changes the mocked cargo command to do the latter. It also adds a check to ensure that the "subcommand name as first argument" behavior is respected. This is, admittedly, a rather pedantic change. Extracted from rust-lang#4175
`SanitizedOutput`s have `String` `stdout` and `stderr` fields. This makes `SanitizedOutput`s easier to display than `Output`s. This commit adds a `TryFrom<Output>` implementation for `SanitizedOutput`. In this way, a test can run a command to produce an `Output`, and from that `Output` produce a `SanitizedOutput`. Extracted from rust-lang#4175
`SanitizedOutput`s have `String` `stdout` and `stderr` fields. This makes `SanitizedOutput`s easier to display than `Output`s. This commit adds a `TryFrom<Output>` implementation for `SanitizedOutput`. In this way, a test can run a command to produce an `Output`, and from that `Output` produce a `SanitizedOutput`. Extracted from #4175
Currently, when the mocked cargo command is passed `--recursive-cargo-subcommand`, it runs: ``` cargo-foo --recursive-cargo ``` However, cargo subcommands are normally passed their subcommand name as the first argument. Thus, one would expect the following to be run: ``` cargo-foo foo --recursive-cargo ``` This commit changes the mocked cargo command to do the latter. It also adds a check to ensure that the "subcommand name as first argument" behavior is respected. This is, admittedly, a rather pedantic change. Extracted from #4175
Previously, `Config::cmd` would always append an `EXE_SUFFIX`. However, this would produce an invalid path if the suffix was already present. Extracted from #4175
Currently, when the mocked cargo command is passed `--recursive-cargo-subcommand`, it runs: ``` cargo-foo --recursive-cargo ``` However, cargo subcommands are normally passed their subcommand name as the first argument. Thus, one would expect the following to be run: ``` cargo-foo foo --recursive-cargo ``` This commit changes the mocked cargo command to do the latter. It also adds a check to ensure that the "subcommand name as first argument" behavior is respected. This is, admittedly, a rather pedantic change. Extracted from #4175
Addresses rust-lang/clippy#15099
To recount the problem (copied from rust-lang/cargo#15099 (comment)):
cargo
proxy runs, selects the defaultcargo
, and sets theCARGO
environment variable to default toolchain'scargo
.cargo
invocations runs some other code, which invokescargo +<toolchain> <subcommand>
.<subcommand>
reads theCARGO
environment variable and runs the default toolchain'scargo
rather than<toolchain>
'scargo
.This PR addresses the problem by warning when the
CARGO
environment variable does not match whatcargo +<toolchain> <subcommand>
will run.This PR is currently organized as eight commits:
$CARGO
passed to external subcommands can point to the wrongcargo
if already set cargo#15099 (comment).Config::cmd
.$CARGO
passed to external subcommands can point to the wrongcargo
if already set cargo#15099 (comment) and onward.Nits are welcome.