mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-03 12:13:43 +00:00
Lazily patch coretests
This commit is contained in:
parent
2c38effe28
commit
fc23a8a7e0
@ -6,7 +6,6 @@ use std::process::Command;
|
||||
use super::build_sysroot::{BUILD_SYSROOT, ORIG_BUILD_SYSROOT, SYSROOT_RUSTC_VERSION, SYSROOT_SRC};
|
||||
use super::path::{Dirs, RelPath};
|
||||
use super::rustc_info::{get_default_sysroot, get_rustc_version};
|
||||
use super::tests::LIBCORE_TESTS_SRC;
|
||||
use super::utils::{
|
||||
copy_dir_recursively, git_command, remove_dir_if_exists, retry_spawn_and_wait, spawn_and_wait,
|
||||
};
|
||||
@ -19,7 +18,6 @@ pub(crate) fn prepare(dirs: &Dirs, rustc: &Path) {
|
||||
|
||||
// FIXME do this on the fly?
|
||||
prepare_stdlib(dirs, rustc);
|
||||
prepare_coretests(dirs, rustc);
|
||||
|
||||
super::tests::RAND_REPO.patch(dirs);
|
||||
super::tests::REGEX_REPO.patch(dirs);
|
||||
@ -44,19 +42,6 @@ fn prepare_stdlib(dirs: &Dirs, rustc: &Path) {
|
||||
fs::write(SYSROOT_RUSTC_VERSION.to_path(dirs), &rustc_version).unwrap();
|
||||
}
|
||||
|
||||
fn prepare_coretests(dirs: &Dirs, rustc: &Path) {
|
||||
let sysroot_src_orig = get_default_sysroot(rustc).join("lib/rustlib/src/rust");
|
||||
assert!(sysroot_src_orig.exists());
|
||||
|
||||
// FIXME ensure builds error out or update the copy if any of the files copied here change
|
||||
apply_patches(
|
||||
dirs,
|
||||
"coretests",
|
||||
&sysroot_src_orig.join("library/core/tests"),
|
||||
&LIBCORE_TESTS_SRC.to_path(dirs),
|
||||
);
|
||||
}
|
||||
|
||||
pub(crate) struct GitRepo {
|
||||
url: GitRepoUrl,
|
||||
rev: &'static str,
|
||||
@ -263,7 +248,7 @@ fn get_patches(dirs: &Dirs, crate_name: &str) -> Vec<PathBuf> {
|
||||
patches
|
||||
}
|
||||
|
||||
fn apply_patches(dirs: &Dirs, crate_name: &str, source_dir: &Path, target_dir: &Path) {
|
||||
pub(crate) fn apply_patches(dirs: &Dirs, crate_name: &str, source_dir: &Path, target_dir: &Path) {
|
||||
// FIXME avoid copy and patch if src, patches and target are unchanged
|
||||
|
||||
remove_dir_if_exists(target_dir);
|
||||
|
@ -1,12 +1,14 @@
|
||||
use super::build_sysroot;
|
||||
use super::config;
|
||||
use super::path::{Dirs, RelPath};
|
||||
use super::prepare::GitRepo;
|
||||
use super::prepare::{apply_patches, GitRepo};
|
||||
use super::rustc_info::get_default_sysroot;
|
||||
use super::utils::{spawn_and_wait, spawn_and_wait_with_input, CargoProject, Compiler};
|
||||
use super::{CodegenBackend, SysrootKind};
|
||||
use std::env;
|
||||
use std::ffi::OsStr;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
|
||||
static BUILD_EXAMPLE_OUT_DIR: RelPath = RelPath::BUILD.join("example");
|
||||
@ -125,9 +127,9 @@ pub(crate) static PORTABLE_SIMD_REPO: GitRepo = GitRepo::github(
|
||||
pub(crate) static PORTABLE_SIMD: CargoProject =
|
||||
CargoProject::new(&PORTABLE_SIMD_REPO.source_dir(), "portable_simd_target");
|
||||
|
||||
pub(crate) static LIBCORE_TESTS_SRC: RelPath = RelPath::BUILD.join("coretests_src");
|
||||
static LIBCORE_TESTS_SRC: RelPath = RelPath::BUILD.join("coretests_src");
|
||||
|
||||
pub(crate) static LIBCORE_TESTS: CargoProject = CargoProject::new(&LIBCORE_TESTS_SRC, "core_tests");
|
||||
static LIBCORE_TESTS: CargoProject = CargoProject::new(&LIBCORE_TESTS_SRC, "core_tests");
|
||||
|
||||
const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
|
||||
TestCase::custom("test.rust-random/rand", &|runner| {
|
||||
@ -145,6 +147,13 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
|
||||
}
|
||||
}),
|
||||
TestCase::custom("test.libcore", &|runner| {
|
||||
apply_patches(
|
||||
&runner.dirs,
|
||||
"coretests",
|
||||
&runner.stdlib_source.join("library/core/tests"),
|
||||
&LIBCORE_TESTS_SRC.to_path(&runner.dirs),
|
||||
);
|
||||
|
||||
LIBCORE_TESTS.clean(&runner.dirs);
|
||||
|
||||
if runner.is_native {
|
||||
@ -231,6 +240,10 @@ pub(crate) fn run_tests(
|
||||
rustup_toolchain_name: Option<&str>,
|
||||
target_triple: String,
|
||||
) {
|
||||
let stdlib_source =
|
||||
get_default_sysroot(&bootstrap_host_compiler.rustc).join("lib/rustlib/src/rust");
|
||||
assert!(stdlib_source.exists());
|
||||
|
||||
if config::get_bool("testsuite.no_sysroot") {
|
||||
let target_compiler = build_sysroot::build_sysroot(
|
||||
dirs,
|
||||
@ -247,6 +260,7 @@ pub(crate) fn run_tests(
|
||||
target_compiler,
|
||||
use_unstable_features,
|
||||
bootstrap_host_compiler.triple == target_triple,
|
||||
stdlib_source.clone(),
|
||||
);
|
||||
|
||||
BUILD_EXAMPLE_OUT_DIR.ensure_fresh(dirs);
|
||||
@ -277,6 +291,7 @@ pub(crate) fn run_tests(
|
||||
target_compiler,
|
||||
use_unstable_features,
|
||||
bootstrap_host_compiler.triple == target_triple,
|
||||
stdlib_source,
|
||||
);
|
||||
|
||||
if run_base_sysroot {
|
||||
@ -299,6 +314,7 @@ struct TestRunner {
|
||||
use_unstable_features: bool,
|
||||
dirs: Dirs,
|
||||
target_compiler: Compiler,
|
||||
stdlib_source: PathBuf,
|
||||
}
|
||||
|
||||
impl TestRunner {
|
||||
@ -307,6 +323,7 @@ impl TestRunner {
|
||||
mut target_compiler: Compiler,
|
||||
use_unstable_features: bool,
|
||||
is_native: bool,
|
||||
stdlib_source: PathBuf,
|
||||
) -> Self {
|
||||
if let Ok(rustflags) = env::var("RUSTFLAGS") {
|
||||
target_compiler.rustflags.push(' ');
|
||||
@ -327,7 +344,14 @@ impl TestRunner {
|
||||
&& target_compiler.triple.contains("x86_64")
|
||||
&& !target_compiler.triple.contains("windows");
|
||||
|
||||
Self { is_native, jit_supported, use_unstable_features, dirs, target_compiler }
|
||||
Self {
|
||||
is_native,
|
||||
jit_supported,
|
||||
use_unstable_features,
|
||||
dirs,
|
||||
target_compiler,
|
||||
stdlib_source,
|
||||
}
|
||||
}
|
||||
|
||||
fn run_testsuite(&self, tests: &[TestCase]) {
|
||||
|
Loading…
Reference in New Issue
Block a user