]> git.proxmox.com Git - cargo.git/commit
test: Make curr_dir work in/out of workspace
authorEd Page <eopage@gmail.com>
Wed, 11 May 2022 15:30:41 +0000 (10:30 -0500)
committerEd Page <eopage@gmail.com>
Thu, 12 May 2022 08:28:27 +0000 (03:28 -0500)
commitdde4a1c3816f20d9c586f6e8fcc0aaf568319f5d
tree73af0b59cfffa293bec1ceb190d4e612de66de72
parent23ae8a0a0fa10c8448dc859eea9c075d2e72f8a9
test: Make curr_dir work in/out of workspace

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.
crates/cargo-test-support/src/lib.rs