Fix "test" subcommand's pass-through arguments #12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
cargo-zigbuild
"test" subcommand has an optional, trailing positional TESTNAME argument. This arg sometimes contains a test name filter and sometimes just another flag that should be passed through to the underlying test binary.For example these work fine (even if
args
has unexpected contents):cargo-zigbuild test
orcargo-zigbuild test --
: test_name: None args: []cargo-zigbuild test foo
orcargo-zigbuild test -- foo
: test_name: Some("foo") args: []cargo-zigbuild test foo bar baz
,cargo-zigbuild test -- foo bar baz
, orcargo-zigbuild test foo -- bar baz
: test_name: Some("foo") args: ["bar", "baz"]However this does not work (as a result of an unexpected
test_name
):4.
cargo-zigbuild test -- --nocapture
: test_name: Some("--nocapture") args: []This is becaue
cargo-zigbuild test
will pass--nocapture
through tocargo test
without prefixing it with a--
separator (since it mistakenly treats it as a test name filter, not an additional argument).Likewise the following fails for similar reasons:
5.
cargo-zigbuild test -- --nocapture --include-ignored
: test_name: Some("--nocapture") args: ["--include-ignored"]But the following works (since it includes a non-arg test_name):
6.
cargo-zigbuild test -- foo --nocapture --include-ignored
orcargo-zigbuild test foo -- --nocapture --include-ignored
: test_name: Some("foo") args: ["--nocapture", "--include-ignored"]In all of the above, the
cargo
"test" subcommand will do the right thing if a--
separator is placed before any test name and/or additional arguments (and also if neither are present). So always pass the separator before either of those.Fixes: rust-cross/cargo-zigbuild#240