Skip to content

Commit 3dd8413

Browse files
committed
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 531ce13 which is what I originally wrote the tests against.
1 parent dd6228e commit 3dd8413

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/bin/cargo/commands/bench.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub fn cli() -> Command {
1414
Arg::new("args")
1515
.help("Arguments for the bench binary")
1616
.num_args(0..)
17-
.trailing_var_arg(true),
17+
.last(true),
1818
)
1919
.arg_targets_all(
2020
"Benchmark only this package's library",

src/bin/cargo/commands/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn cli() -> Command {
1515
Arg::new("args")
1616
.help("Arguments for the test binary")
1717
.num_args(0..)
18-
.trailing_var_arg(true),
18+
.last(true),
1919
)
2020
.arg(
2121
flag(

tests/testsuite/test.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ fn pass_through_escaped() {
760760
[COMPILING] foo v0.0.1 ([CWD])
761761
[FINISHED] test [unoptimized + debuginfo] target(s) in [..]
762762
[RUNNING] [..] (target/debug/deps/foo-[..][EXE])
763+
[DOCTEST] foo
763764
",
764765
)
765766
.with_stdout_contains("running 1 test")
@@ -771,6 +772,7 @@ fn pass_through_escaped() {
771772
"\
772773
[FINISHED] test [unoptimized + debuginfo] target(s) in [..]
773774
[RUNNING] [..] (target/debug/deps/foo-[..][EXE])
775+
[DOCTEST] foo
774776
",
775777
)
776778
.with_stdout_contains("running 1 test")
@@ -782,6 +784,7 @@ fn pass_through_escaped() {
782784
"\
783785
[FINISHED] test [unoptimized + debuginfo] target(s) in [..]
784786
[RUNNING] [..] (target/debug/deps/foo-[..][EXE])
787+
[DOCTEST] foo
785788
",
786789
)
787790
.with_stdout_contains("running 2 tests")

0 commit comments

Comments
 (0)