Skip to content
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

test: remove the use of CARGO_RUSTC_CURRENT_DIR #14869

Closed
wants to merge 1 commit into from

Conversation

weihanglo
Copy link
Member

@weihanglo weihanglo commented Nov 29, 2024

What does this PR try to resolve?

The environment variable has been removed in #14799.
Switch to plain old CARGO_MANIFEST_DIR
because snapbox's current_rs favors furthest Cargo.toml,
blocking tests running in rust-lang/rust as a submodule.

See also build failures in rust-lang/rust#133533

How should we test and review this PR?

Pull this change into rust-lang/rust and run

./x.py test src/tools/cargo

@rustbot
Copy link
Collaborator

rustbot commented Nov 29, 2024

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc. A-testing-cargo-itself Area: cargo's tests S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 29, 2024
Comment on lines 7 to 10
[env]
# HACK: Until this is stabilized, `snapbox`s polyfill could get confused
# inside of the rust-lang/rust repo because it looks for the furthest-away `Cargo.toml`
CARGO_RUSTC_CURRENT_DIR = { value = "", relative = true }
Copy link
Contributor

Choose a reason for hiding this comment

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

We likely still want this for snapbox which reads CARGO_RUSTC_CURRENT_DIR

Copy link
Member Author

@weihanglo weihanglo Nov 29, 2024

Choose a reason for hiding this comment

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

I've tested SNAPSHOTS=overwrite to update inline snapshots for some tests in

  • tests/build-std/main.rs
  • tests/testsuite/rename_deps.rs
  • crates/cargo-util-schemas/src/manifest/rust_version.rs

And they are all working.

I assume we don't really need that except for people working on Cargo from rust-lang/rust repo. I can keep it there if this is what we want to support.

@epage
Copy link
Contributor

epage commented Nov 29, 2024

Snapbox also uses CARGO_RUSTC_CURRENT_DIR. However, that is only on test failure when SNAPSHOTS=overwrite is specified which is why it isn't a problem.

@epage
Copy link
Contributor

epage commented Nov 29, 2024

Do we know why this doesn't work for bootstrap but it works for everything else? Are they running our tests outside of our repo, making it so the config isn't loaded? Could that change?

@weihanglo
Copy link
Member Author

Do we know why this doesn't work for bootstrap but it works for everything else? Are they running our tests outside of our repo, making it so the config isn't loaded? Could that change?

I believe that is because bootstrap invokes cargo with --manifest-path without cd to the package root.

@bors
Copy link
Contributor

bors commented Nov 29, 2024

☔ The latest upstream changes (presumably 3908f64) made this pull request unmergeable. Please resolve the merge conflicts.

The environment variable has been removed in rust-lang#14799.
Switch to plain old `CARGO_MANIFEST_DIR`
because snapbox's `current_rs` favors furthest Cargo.toml,
blocking tests running in rust-lang/rust as a submodule.

See also build failures in rust-lang/rust#133533
@weihanglo
Copy link
Member Author

[…] Are they running our tests outside of our repo, making it so the config isn't loaded? Could that change?

It might be possible to change, but that requires bootstrap team's involvement. I would suggest we unblock this first, and then discuss with other folks for any further refactors.

@weihanglo
Copy link
Member Author

Suggest a patch to that PR: rust-lang/rust#133533 (comment).

@weihanglo
Copy link
Member Author

Close as this patch works.

@weihanglo weihanglo closed this Nov 30, 2024
@weihanglo weihanglo deleted the bootstrap-beta branch November 30, 2024 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc. 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.

4 participants