Skip to content

Rework cargo-test-support & testsuite to use CARGO_BIN_EXE_* for Cargo #15692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ranger-ross
Copy link
Contributor

What does this PR try to resolve?

This PR reworks cargo-test-support and testsuite to use Snapbox's cargo_bin!() instead of cargo_bin() which makes assumptions about the structure of Cargo's build directory.
cargo_bin!() uses CARGO_BIN_EXE_* for locating the cargo binary which should be more resilient to directory/layout changes.

Linking a relevant Zulip discussion here#t-cargo > cargo_bin_exe and tests

Implementation Notes

cargo_bin!() only works when being called from the testsuite as it's only set when executing integration tests and cargo-test-support is a regular crate.
To make this change, I introduced an extension trait CargoProjectExt in testsuite for running .cargo() and implemented it on Project.

In cargo-test-support other functionality relies on .cargo() so these also needed to be moved to testsuite

  • src/tools.rs
  • Parts src/cross_compile
    • I had to split this up unfortunately, as disabled() requires running Cargo to check if we should disable cross compile tests.
    • Other fns in cross_compile are used in cargo-test-support so moving everything to testsuite would have ended up requiring moving many things to test suite.

How to test and review this PR?

I'd definitely recommend reviewing commit by commit.
There are a lot of diffs due to the nature of reorganizing things.
I did my best to split things things into smaller PRs but they still contain a lot of use statement diffs.

r? @epage

@rustbot rustbot added A-testing-cargo-itself Area: cargo's tests S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testing-cargo-itself Area: cargo's tests S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants