Skip to content

cargo test gives bad advice when given invalid target #68238

Closed
@xobs

Description

@xobs

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
$
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions