Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 6, 2025

Adds an explicit --cargo-test-arg command-line option for passing arguments to cargo test, complementing the existing -- args format.

Background

Previously, the only way to pass arguments to cargo test was using the trailing arguments format:

cargo mutants -- --all-targets --no-fail-fast

While this works, it's not as explicit and discoverable as a named option.

Changes

This PR adds a new --cargo-test-arg option that can be repeated:

cargo mutants --cargo-test-arg=--all-targets --cargo-test-arg=--no-fail-fast

Both formats continue to work and can even be combined:

cargo mutants --cargo-test-arg=--all-targets -- --nocapture

When multiple sources provide test arguments (new option, --, and config file), they are combined in the following order:

  1. Arguments from --cargo-test-arg
  2. Arguments after --
  3. Arguments from additional_cargo_test_args in .cargo/mutants.toml

Testing

  • Added 6 unit tests covering all combinations of the three argument sources
  • Added 3 integration tests verifying command-line behavior
  • All existing tests continue to pass
  • Verified backward compatibility with the -- args format

Documentation

Updated book/src/cargo-args.md with examples of the new option and explanation of how arguments are combined.

Fixes #505

Original prompt

This section details on the original issue you should resolve

<issue_title>Explicit option for test args</issue_title>
<issue_description>Split from #505:

Today you can pass arguments to the test runner with cargo mutants -- --extra-test-args.

It might be nice to also have an explicit option for this, e.g. cargo mutants --cargo-test-arg=--max-fail=2.

    /// Pass remaining arguments to cargo test after all options and after `--`.
    #[arg(last = true, help_heading = "Execution")]
    cargo_test_args: Vec<String>,
```</issue_description>

<agent_instructions>
Add tests for this in options.md.

This should go into both the config and command-line options. Test that the current format is still supported.
</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>
Fixes #536

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] Explicit option for test args Add explicit --cargo-test-arg option for test arguments Oct 6, 2025
Copilot AI requested a review from sourcefrog October 6, 2025 15:01
@sourcefrog sourcefrog marked this pull request as ready for review October 12, 2025 00:58
@sourcefrog sourcefrog merged commit d98caaa into main Oct 13, 2025
28 checks passed
@sourcefrog sourcefrog deleted the copilot/fix-a3efe39a-d717-4010-9198-1381e7c7af3a branch October 13, 2025 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Explicit option for test args Nextest profile to use

2 participants