mirror of
https://github.com/rust-lang/cargo
synced 2024-09-17 23:01:51 +00:00
fix(test): Distinguish 'testname' from escaped arguments
When working on clap v4, it appeared that `last` and `trailing_var_arg`
are mutually exclusive, so I called that out in the debug asserts in
clap-rs/clap#4187. Unfortunately, I didn't document my research on this
as my focus was elsewhere.
When updating cargo to use clap v4 in #11159, I found `last` and
`trailing_var_arg` were used together. I figured this was what I was
trying to catch with above and I went off of my intuitive sense of these
commands and assumed `trailing_var_arg` was intended, not knowing about
the `testname` positional that is mostly just a forward to `libtest`,
there for documentation purposes, except for a small optimization.
So it looks like we just need the `last` call and not the
`trailing_var_arg` call.
This restores us to behavior from 531ce1321
which is what I originally
wrote the tests against.
This commit is contained in:
parent
dd6228ebdb
commit
3dd8413f77
|
@ -14,7 +14,7 @@ pub fn cli() -> Command {
|
|||
Arg::new("args")
|
||||
.help("Arguments for the bench binary")
|
||||
.num_args(0..)
|
||||
.trailing_var_arg(true),
|
||||
.last(true),
|
||||
)
|
||||
.arg_targets_all(
|
||||
"Benchmark only this package's library",
|
||||
|
|
|
@ -15,7 +15,7 @@ pub fn cli() -> Command {
|
|||
Arg::new("args")
|
||||
.help("Arguments for the test binary")
|
||||
.num_args(0..)
|
||||
.trailing_var_arg(true),
|
||||
.last(true),
|
||||
)
|
||||
.arg(
|
||||
flag(
|
||||
|
|
|
@ -760,6 +760,7 @@ fn pass_through_escaped() {
|
|||
[COMPILING] foo v0.0.1 ([CWD])
|
||||
[FINISHED] test [unoptimized + debuginfo] target(s) in [..]
|
||||
[RUNNING] [..] (target/debug/deps/foo-[..][EXE])
|
||||
[DOCTEST] foo
|
||||
",
|
||||
)
|
||||
.with_stdout_contains("running 1 test")
|
||||
|
@ -771,6 +772,7 @@ fn pass_through_escaped() {
|
|||
"\
|
||||
[FINISHED] test [unoptimized + debuginfo] target(s) in [..]
|
||||
[RUNNING] [..] (target/debug/deps/foo-[..][EXE])
|
||||
[DOCTEST] foo
|
||||
",
|
||||
)
|
||||
.with_stdout_contains("running 1 test")
|
||||
|
@ -782,6 +784,7 @@ fn pass_through_escaped() {
|
|||
"\
|
||||
[FINISHED] test [unoptimized + debuginfo] target(s) in [..]
|
||||
[RUNNING] [..] (target/debug/deps/foo-[..][EXE])
|
||||
[DOCTEST] foo
|
||||
",
|
||||
)
|
||||
.with_stdout_contains("running 2 tests")
|
||||
|
|
Loading…
Reference in a new issue