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

cargo test gives bad advice when given invalid target #68238

Closed
xobs opened this issue Jan 14, 2020 · 2 comments · Fixed by #83711
Closed

cargo test gives bad advice when given invalid target #68238

xobs opened this issue Jan 14, 2020 · 2 comments · Fixed by #83711
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. D-confusing Diagnostics: Confusing error or lint that should be reworked. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@xobs
Copy link
Contributor

xobs commented Jan 14, 2020

Problem

It is possible to run tests for various targets using cargo test --target [triple]. When given an invalid triple, cargo indicates the user should run --print target-list for help. However, this is not valid advice.

Steps

  1. Run cargo test --target invalid-target
  2. Run the suggested cargo test --print target-list

Possible Solution(s)

cargo should implement --print target-list, or the advice should be removed.

Notes

Output of cargo version: cargo 1.40.0 (bc8e4c8be 2019-11-22)

$ cargo test --target invalid-target
error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `rustc - --crate-name ___ --print=file-names --target invalid-target --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=cfg` (exit code: 1)
--- stderr
error: Error loading target specification: Could not find specification for target "invalid-target"
  |
  = help: Use `--print target-list` for a list of built-in targets


$ cargo test --print target-list
error: Found argument '--print' which wasn't expected, or isn't valid in this context

USAGE:
    cargo.exe test [OPTIONS] [TESTNAME] [-- <args>...]

For more information try --help
$
...
@lukaslueg
Copy link
Contributor

This can be confusing but cctually cargo just prints what rustc is saying via stderr: run rustc --print target-list

@ehuss ehuss transferred this issue from rust-lang/cargo Jan 15, 2020
@ehuss
Copy link
Contributor

ehuss commented Jan 15, 2020

Yea, this message is printed by rustc, so I have moved this to the rust issue tracker.

It seems reasonable to me that it should include rustc before the --print flag, though maybe the diagnostic people have further thoughts.

@Alexendoo Alexendoo added A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. D-confusing Diagnostics: Confusing error or lint that should be reworked. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 15, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Mar 31, 2021
…get-error, r=davidtwco

Clarify `--print target-list` is a rustc's option

Fixes rust-lang#68238
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Mar 31, 2021
…get-error, r=davidtwco

Clarify `--print target-list` is a rustc's option

Fixes rust-lang#68238
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Mar 31, 2021
…get-error, r=davidtwco

Clarify `--print target-list` is a rustc's option

Fixes rust-lang#68238
@bors bors closed this as completed in 1ef52ac Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. D-confusing Diagnostics: Confusing error or lint that should be reworked. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants