Replace deprecated cargo_bin with cargo_bin! macro#579
Conversation
Co-authored-by: sourcefrog <346355+sourcefrog@users.noreply.github.com>
Co-authored-by: sourcefrog <346355+sourcefrog@users.noreply.github.com>
There was a problem hiding this comment.
Can you please rename this to tests/integration_util/mod.rs so that it does not generate a new test target, following the pattern in https://doc.rust-lang.org/book/ch11-03-test-organization.html#submodules-in-integration-tests.
There was a problem hiding this comment.
Done in commit bc029cc. The file has been moved to tests/integration_util/mod.rs to prevent it from being compiled as a separate test target.
|
@copilot Can you please rename this to tests/integration_util/mod.rs so that it does not generate a new test target, following the pattern in https://doc.rust-lang.org/book/ch11-03-test-organization.html#submodules-in-integration-tests. |
… separate test target Co-authored-by: sourcefrog <346355+sourcefrog@users.noreply.github.com>
Done in commit bc029cc. The file has been moved to |
The
assert_cmd::cargo::cargo_bin()function relies on Cargo's internal directory structure to locate test binaries. This breaks whenCARGO_BUILD_BUILD_DIRis 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
tests/integration_util/mod.rscontainingrun()andmain_binary()usingcargo_bin!()macrotests/util/mod.rs(shared by integration and unit tests)tests/main.rsimportsWhy the separation?
The
cargo_bin!()macro expands toenv!("CARGO_BIN_EXE_cargo-mutants"), which is only available at compile-time for integration test binaries. The sharedtests/util/mod.rsis included in unit tests viasrc/main.rs, where this environment variable doesn't exist. Separating the modules allowscargo check --all-targetsto succeed while using the stableCARGO_BIN_EXE_*API.Why use a subdirectory structure?
The
integration_utilmodule is organized astests/integration_util/mod.rsinstead oftests/integration_util.rsto follow Rust conventions. Files directly in thetests/directory are compiled as separate integration test crates, while subdirectories withmod.rsare not. This prevents creating an unnecessary test target while still making the utilities available to integration tests.Original prompt
assert_cmd::cargo_binwhich will break on future Cargo versions #578💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.