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

Merged
merged 6 commits into from
Jun 26, 2025

Conversation

ranger-ross
Copy link
Contributor

@ranger-ross ranger-ross commented Jun 22, 2025

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

As shown in that link, we could make these variables available at runtime and not need to do this. However, cargo-test-support, as an API, is a bit weird in that it is baking in support for one specific binary. This can be confusing for callers and makes it more annoying for callers provide their own fn cargo, e.g. see crate-ci/cargo-fixit#7

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
@ranger-ross ranger-ross force-pushed the better-bin-handling branch 2 times, most recently from 71f7c4a to 843083d Compare June 24, 2025 14:44
@ranger-ross ranger-ross force-pushed the better-bin-handling branch from 843083d to b553378 Compare June 24, 2025 14:59
@ranger-ross ranger-ross force-pushed the better-bin-handling branch from b553378 to 1d064ab Compare June 25, 2025 14:08
@rustbot rustbot added the A-documenting-cargo-itself Area: Cargo's documentation label Jun 25, 2025
@ranger-ross ranger-ross force-pushed the better-bin-handling branch from 1d064ab to 02b56d4 Compare June 25, 2025 14:22
@ranger-ross
Copy link
Contributor Author

Okay sorry, I cleaned up the commits. (Not quiet sure what happened)

I split out the commits as you suggested in this comment and updated the testing documentation as well

Copy link
Contributor

@epage epage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@epage epage enabled auto-merge June 26, 2025 15:06
@epage epage added this pull request to the merge queue Jun 26, 2025
Merged via the queue into rust-lang:master with commit 4ac865d Jun 26, 2025
48 of 50 checks passed
@ranger-ross ranger-ross deleted the better-bin-handling branch June 27, 2025 14:36
bors added a commit to rust-lang/rust that referenced this pull request Jun 29, 2025
Update cargo

7 commits in 409fed7dc1553d49cb9a8c0637d12d65571346ce..930b4f62cfcd1f0eabdb30a56d91bf6844b739bf
2025-06-23 15:55:04 +0000 to 2025-06-28 14:58:43 +0000
- Use a different lint for the `fix_only_once_for_duplicates` test (rust-lang/cargo#15713)
- chore: bump to 0.91.0; update changelog (rust-lang/cargo#15710)
- Add `http.proxy-cainfo` config for proxy certs (rust-lang/cargo#15374)
- chore(deps): update msrv (3 versions) to v1.86 (rust-lang/cargo#15709)
- chore(deps): update msrv (1 version) to v1.88 (rust-lang/cargo#15706)
- Rework `cargo-test-support` & `testsuite` to use `CARGO_BIN_EXE_*` for Cargo (rust-lang/cargo#15692)
- fix: Expand error messages around path dependency on `cargo package` and `cargo publish` (rust-lang/cargo#15705)
@rustbot rustbot added this to the 1.90.0 milestone Jun 29, 2025
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jun 29, 2025
Update cargo

7 commits in 409fed7dc1553d49cb9a8c0637d12d65571346ce..930b4f62cfcd1f0eabdb30a56d91bf6844b739bf
2025-06-23 15:55:04 +0000 to 2025-06-28 14:58:43 +0000
- Use a different lint for the `fix_only_once_for_duplicates` test (rust-lang/cargo#15713)
- chore: bump to 0.91.0; update changelog (rust-lang/cargo#15710)
- Add `http.proxy-cainfo` config for proxy certs (rust-lang/cargo#15374)
- chore(deps): update msrv (3 versions) to v1.86 (rust-lang/cargo#15709)
- chore(deps): update msrv (1 version) to v1.88 (rust-lang/cargo#15706)
- Rework `cargo-test-support` & `testsuite` to use `CARGO_BIN_EXE_*` for Cargo (rust-lang/cargo#15692)
- fix: Expand error messages around path dependency on `cargo package` and `cargo publish` (rust-lang/cargo#15705)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-documenting-cargo-itself Area: Cargo's documentation 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