test: Make curr_dir work in/out of workspace#10658
Merged
bors merged 1 commit intorust-lang:masterfrom May 12, 2022
Merged
Conversation
|
r? @ehuss (rust-highfive has picked a reviewer for you, use r? to override) |
ehuss
reviewed
May 11, 2022
Contributor
ehuss
left a comment
There was a problem hiding this comment.
Oh my, that's a really unfortunate interaction with the file! macro.
When running tests in the `rust-lang/cargo` repo, `file!` is relative to the crate root and tests are run relative to the crate root and everything is fine. When running tests in the `rust-lang/rust` repo, `file!` is relative to the workspace root and tests are run relative to the crate root and there is much sadness. If we are compiling relative to the crate root, we could make the path absolute and everything would be dandy but this needs to happen at compile time. Didn't see a way to do this. We could stop using `curr_dir` but that makes the tests a bit noisier with more overhead for creating a new tests from an existing case. Since we can reasonly know what all roots will be used for `file!`, we can just hard code-in support for those two roots. Much happiness ensues as everything works with this surgical hack.
Contributor
|
Thanks! It's a bit unfortunate to hard-code the path, but I can't think of a much better solution. There are some reports at #3946 (comment) about also having this problem. Might be worthwhile at some point trying to come up with a solution. @bors r+ |
Contributor
|
📌 Commit dde4a1c has been approved by |
Contributor
Contributor
|
☀️ Test successful - checks-actions |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
May 12, 2022
Update cargo 20 commits in a44758ac805600edbb6ba51e7e6fb81a6077c0cd..3f052d8eed98c6a24f8b332fb2e6e6249d12d8c1 2022-05-04 02:29:34 +0000 to 2022-05-12 15:19:04 +0000 - pre-stabilization documentation for workspace inheritance (rust-lang/cargo#10659) - test: Make curr_dir work in/out of workspace (rust-lang/cargo#10658) - Fix no_cross_doctests race condition. (rust-lang/cargo#10660) - Fix typo (rust-lang/cargo#10657) - feat(install): Support `foo@version` like cargo-add (rust-lang/cargo#10650) - fix typos found by the `typos-cli` crate (rust-lang/cargo#10649) - feat(yank): Support foo@version like cargo-add (rust-lang/cargo#10597) - add `cargo-features` to unstable docs for workspace inheritance (rust-lang/cargo#10648) - Use the traits added to the Rust 2021 Edition prelude (rust-lang/cargo#10646) - Pass `--target` to `rustdoc` for `cargo test` if specified with host target. (rust-lang/cargo#10594) - Fix use of .. in dep-info-basedir (rust-lang/cargo#10281) - fix some typos (rust-lang/cargo#10639) - Move snapshot tests into testsuite (rust-lang/cargo#10638) - Improve support of condition compilation checking (rust-lang/cargo#10566) - When documenting private items in a binary, ignore warnings about links to private items (rust-lang/cargo#10142) - Extend pkgid syntax with ``@`` support (rust-lang/cargo#10582) - move one `snapshot/add` test into `testsuite/cargo_add/` (rust-lang/cargo#10631) - Add caveat for covering features (rust-lang/cargo#10605) - Improve CARGO_ENCODED_RUSTFLAGS and CARGO_ENCODED_RUSTDOCFLAGS variables docs (rust-lang/cargo#10633) - reorganize `snapshot` tests to better work in contexts that sort by extension (rust-lang/cargo#10629)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR try to resolve?
Get snapbox tests passing when testing
cargoas part of therust-lang/rustworkspace via a git submodule.rust-lang/cargorepo,file!is relative tothe crate root and tests are run relative to the crate root and
everything is fine.
rust-lang/rustrepo,file!is relative tothe workspace root and tests are run relative to the crate root and
there is much sadness.
If we are compiling relative to the crate root, we could make the path
absolute and everything would be dandy but this needs to happen at
compile time. Didn't see a way to do this.
We could stop using
curr_dirbut that makes the tests a bit noisierwith more overhead for creating a new tests from an existing case.
Since we can reasonly know what all roots will be used for
file!, wecan just hard code-in support for those two roots. Much happiness
ensues as everything works with this surgical hack.
How should we test and review this PR?
I ran the tests in both the
cargoandrustrepos. You can as well.Additional information