Skip to content

Commit 4f0adae

Browse files
committed
Auto merge of #8982 - ehuss:fix-alt-target-tests, r=alexcrichton
Fix tests not working with a different CARGO_TARGET_DIR. Fixes #8980
2 parents 310994c + 0ac41f0 commit 4f0adae

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

tests/testsuite/standard_lib.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use cargo_test_support::registry::{Dependency, Package};
88
use cargo_test_support::ProjectBuilder;
99
use cargo_test_support::{is_nightly, paths, project, rustc_host, Execs};
10-
use std::path::PathBuf;
10+
use std::path::{Path, PathBuf};
1111

1212
struct Setup {
1313
rustc_wrapper: PathBuf,
@@ -131,15 +131,7 @@ fn setup() -> Option<Setup> {
131131
fn enable_build_std(e: &mut Execs, setup: &Setup) {
132132
// First up, force Cargo to use our "mock sysroot" which mimics what
133133
// libstd looks like upstream.
134-
let root = paths::root();
135-
let root = root
136-
.parent() // chop off test name
137-
.unwrap()
138-
.parent() // chop off `citN`
139-
.unwrap()
140-
.parent() // chop off `target`
141-
.unwrap()
142-
.join("tests/testsuite/mock-std");
134+
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/testsuite/mock-std");
143135
e.env("__CARGO_TESTS_ONLY_SRC_ROOT", &root);
144136

145137
e.masquerade_as_nightly_cargo();

0 commit comments

Comments
 (0)