Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 19, 2025

The assert_cmd::cargo::cargo_bin() function relies on Cargo's internal directory structure to locate test binaries. This breaks when CARGO_BUILD_BUILD_DIR is set, and will fail with upcoming Cargo changes (rust-lang/cargo#16147, rust-lang/cargo#15010).

Changes

Separated integration test utilities from shared test utilities

  • Created tests/integration_util.rs containing run() and main_binary() using cargo_bin!() macro
  • Removed these functions from tests/util/mod.rs (shared by integration and unit tests)
  • Updated tests/main.rs imports

Why the separation?
The cargo_bin!() macro expands to env!("CARGO_BIN_EXE_cargo-mutants"), which is only available at compile-time for integration test binaries. The shared tests/util/mod.rs is included in unit tests via src/main.rs, where this environment variable doesn't exist. Separating the modules allows cargo check --all-targets to succeed while using the stable CARGO_BIN_EXE_* API.

// Before: relies on target dir inference
cargo_bin("cargo-mutants")

// After: uses stable environment variable
cargo_bin!("cargo-mutants")
Original prompt

This section details on the original issue you should resolve

<issue_title>Tests rely on deprecated assert_cmd::cargo_bin which will break on future Cargo versions</issue_title>
<issue_description>

pub static ref MAIN_BINARY: PathBuf = assert_cmd::cargo::cargo_bin("cargo-mutants");

cargo_bin relies on implementation details of cargo that will soon break (rust-lang/cargo#16147, rust-lang/cargo#15010).

You can test this by running:

CARGO_BUILD_BUILD_DIR="{cargo-cache-home}/build/{workspace-path-hash}" cargo test

The replacement is assert_cmd::cargo_bin! </issue_description>

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

@sourcefrog Thanks for letting me know!

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Dec 19, 2025
Copilot AI and others added 2 commits December 19, 2025 01:37
Co-authored-by: sourcefrog <346355+sourcefrog@users.noreply.github.com>
Co-authored-by: sourcefrog <346355+sourcefrog@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix tests to use assert_cmd::cargo_bin! Replace deprecated cargo_bin with cargo_bin! macro Dec 19, 2025
Copilot AI requested a review from sourcefrog December 19, 2025 02:07
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.

Tests rely on deprecated assert_cmd::cargo_bin which will break on future Cargo versions

2 participants