Skip to content

Support --target-dir - #627

Open
ychampion wants to merge 2 commits into
sourcefrog:mainfrom
ychampion:support-target-dir
Open

ychampion wants to merge 2 commits into
sourcefrog:mainfrom
ychampion:support-target-dir

Conversation

@ychampion

@ychampion ychampion commented Jul 10, 2026 •

Copy link
Copy Markdown

Fixes #407.

Problem

cargo mutants --target-dir ... is rejected even though Cargo accepts it. Supporting the option lets scripts keep the same build-directory argument when invoking cargo-mutants.

Change

Accept --target-dir <DIRECTORY> and pass it unchanged to every Cargo check, build, and test command. The documentation explains that relative paths are inside each scratch workspace (or the source workspace with --in-place); an absolute path keeps artifacts outside scratch directories. --leak-dirs retains the scratch copy when requested.

Validation

  • Verified relative, --in-place, and absolute target locations with the CLI.
  • Full workspace/all-feature suite: 291 unit tests, 138 active integration tests, and two attribute doctests passed; two existing integration ignores remain. Root DAC bypass was removed for permission fixtures, and NO_COLOR was unset for color tests.
  • Strict all-target/all-feature Clippy, formatting, and diff checks pass.

Written by an agent (Codex, gpt-6-astra).

Expose the documented cargo-arg workaround as a first-class CLI option and preserve Cargo's path semantics across check, build, and test phases.

Constraint: Keep the configuration schema unchanged; additional_cargo_args remains the config-file equivalent.

Rejected: Add a target_dir config key | issue sourcefrog#407 requests drop-in CLI compatibility and the existing passthrough already covers configuration.

Confidence: high

Scope-risk: narrow

Tested: all-feature unit/integration suite excluding two root-invalid permission tests; all-target/all-feature Clippy; cargo fmt; end-to-end target-directory smoke

Not-tested: build_dir permission-denial tests cannot exercise EACCES while running as root.
@mcunha

mcunha commented Sep 9, 2026

Copy link
Copy Markdown

Where does a relative --target-dir target/mutants actually put the artifacts, given cargo resolves it against its cwd — and cargo-mutants (IIRC) runs cargo with cwd set to a temporary scratch copy of the tree?

@ychampion

Copy link
Copy Markdown
Author

Cargo runs from each scratch workspace, so a relative target/mutants is inside that copy and disappears with it unless --leak-dirs retains the copy. With --in-place, the path is relative to the source workspace; an absolute path keeps artifacts outside scratch directories. I verified all three locations through the CLI and clarified the documentation in 081908e.


Written by an agent (Codex, gpt-6-astra).

This branch has not been deployed

No deployments
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.

Support --target-dir

2 participants