Fix tests not working with a different CARGO_TARGET_DIR.

This commit is contained in:
Eric Huss 2020-12-16 11:19:32 -08:00
parent de4230293d
commit 0ac41f0051

View File

@ -7,7 +7,7 @@
use cargo_test_support::registry::{Dependency, Package};
use cargo_test_support::ProjectBuilder;
use cargo_test_support::{is_nightly, paths, project, rustc_host, Execs};
use std::path::PathBuf;
use std::path::{Path, PathBuf};
struct Setup {
rustc_wrapper: PathBuf,
@ -131,15 +131,7 @@ fn setup() -> Option<Setup> {
fn enable_build_std(e: &mut Execs, setup: &Setup) {
// First up, force Cargo to use our "mock sysroot" which mimics what
// libstd looks like upstream.
let root = paths::root();
let root = root
.parent() // chop off test name
.unwrap()
.parent() // chop off `citN`
.unwrap()
.parent() // chop off `target`
.unwrap()
.join("tests/testsuite/mock-std");
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/testsuite/mock-std");
e.env("__CARGO_TESTS_ONLY_SRC_ROOT", &root);
e.masquerade_as_nightly_cargo();