1
Fork 0

Merge commit '8830dccd1d' into sync_cg_clif-2023-06-15

This commit is contained in:
bjorn3 2023-06-15 17:56:01 +00:00
commit 82b497286d
56 changed files with 2511 additions and 592 deletions

View file

@ -1,13 +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::SysrootKind;
use super::{CodegenBackend, SysrootKind};
use std::env;
use std::ffi::OsStr;
use std::fs;
use std::path::Path;
use std::path::PathBuf;
use std::process::Command;
static BUILD_EXAMPLE_OUT_DIR: RelPath = RelPath::BUILD.join("example");
@ -18,7 +19,7 @@ struct TestCase {
}
enum TestCaseCmd {
Custom { func: &'static dyn Fn(&TestRunner) },
Custom { func: &'static dyn Fn(&TestRunner<'_>) },
BuildLib { source: &'static str, crate_types: &'static str },
BuildBinAndRun { source: &'static str, args: &'static [&'static str] },
JitBin { source: &'static str, args: &'static str },
@ -26,7 +27,7 @@ enum TestCaseCmd {
impl TestCase {
// FIXME reduce usage of custom test case commands
const fn custom(config: &'static str, func: &'static dyn Fn(&TestRunner)) -> Self {
const fn custom(config: &'static str, func: &'static dyn Fn(&TestRunner<'_>)) -> Self {
Self { config, cmd: TestCaseCmd::Custom { func } }
}
@ -95,32 +96,45 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
// FIXME(rust-random/rand#1293): Newer rand versions fail to test on Windows. Update once this is
// fixed.
pub(crate) static RAND_REPO: GitRepo =
GitRepo::github("rust-random", "rand", "50b9a447410860af8d6db9a208c3576886955874", "rand");
pub(crate) static RAND_REPO: GitRepo = GitRepo::github(
"rust-random",
"rand",
"50b9a447410860af8d6db9a208c3576886955874",
"446203b96054891e",
"rand",
);
pub(crate) static RAND: CargoProject = CargoProject::new(&RAND_REPO.source_dir(), "rand");
pub(crate) static RAND: CargoProject = CargoProject::new(&RAND_REPO.source_dir(), "rand_target");
pub(crate) static REGEX_REPO: GitRepo =
GitRepo::github("rust-lang", "regex", "32fed9429eafba0ae92a64b01796a0c5a75b88c8", "regex");
pub(crate) static REGEX_REPO: GitRepo = GitRepo::github(
"rust-lang",
"regex",
"32fed9429eafba0ae92a64b01796a0c5a75b88c8",
"fcc4df7c5b902633",
"regex",
);
pub(crate) static REGEX: CargoProject = CargoProject::new(&REGEX_REPO.source_dir(), "regex");
pub(crate) static REGEX: CargoProject = CargoProject::new(&REGEX_REPO.source_dir(), "regex_target");
pub(crate) static PORTABLE_SIMD_REPO: GitRepo = GitRepo::github(
"rust-lang",
"portable-simd",
"ad8afa8c81273b3b49acbea38cd3bcf17a34cf2b",
"800548f8000e31bd",
"portable-simd",
);
pub(crate) static PORTABLE_SIMD: CargoProject =
CargoProject::new(&PORTABLE_SIMD_REPO.source_dir(), "portable_simd");
CargoProject::new(&PORTABLE_SIMD_REPO.source_dir(), "portable-simd_target");
pub(crate) static LIBCORE_TESTS_SRC: RelPath = RelPath::DOWNLOAD.join("coretests_src");
static LIBCORE_TESTS_SRC: RelPath = RelPath::BUILD.join("coretests");
pub(crate) static LIBCORE_TESTS: CargoProject = CargoProject::new(&LIBCORE_TESTS_SRC, "core_tests");
static LIBCORE_TESTS: CargoProject = CargoProject::new(&LIBCORE_TESTS_SRC, "coretests_target");
const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
TestCase::custom("test.rust-random/rand", &|runner| {
RAND_REPO.patch(&runner.dirs);
RAND.clean(&runner.dirs);
if runner.is_native {
@ -135,6 +149,17 @@ 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),
);
let source_lockfile = RelPath::PATCHES.to_path(&runner.dirs).join("coretests-lock.toml");
let target_lockfile = LIBCORE_TESTS_SRC.to_path(&runner.dirs).join("Cargo.lock");
fs::copy(source_lockfile, target_lockfile).unwrap();
LIBCORE_TESTS.clean(&runner.dirs);
if runner.is_native {
@ -149,6 +174,8 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
}
}),
TestCase::custom("test.regex-shootout-regex-dna", &|runner| {
REGEX_REPO.patch(&runner.dirs);
REGEX.clean(&runner.dirs);
let mut build_cmd = REGEX.build(&runner.target_compiler, &runner.dirs);
@ -181,6 +208,8 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
}
}),
TestCase::custom("test.regex", &|runner| {
REGEX_REPO.patch(&runner.dirs);
REGEX.clean(&runner.dirs);
if runner.is_native {
@ -197,6 +226,8 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
}
}),
TestCase::custom("test.portable-simd", &|runner| {
PORTABLE_SIMD_REPO.patch(&runner.dirs);
PORTABLE_SIMD.clean(&runner.dirs);
let mut build_cmd = PORTABLE_SIMD.build(&runner.target_compiler, &runner.dirs);
@ -215,24 +246,35 @@ pub(crate) fn run_tests(
dirs: &Dirs,
channel: &str,
sysroot_kind: SysrootKind,
cg_clif_dylib: &Path,
use_unstable_features: bool,
skip_tests: &[&str],
cg_clif_dylib: &CodegenBackend,
bootstrap_host_compiler: &Compiler,
rustup_toolchain_name: Option<&str>,
target_triple: String,
) {
if config::get_bool("testsuite.no_sysroot") {
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") && !skip_tests.contains(&"testsuite.no_sysroot") {
let target_compiler = build_sysroot::build_sysroot(
dirs,
channel,
SysrootKind::None,
cg_clif_dylib,
bootstrap_host_compiler,
rustup_toolchain_name,
target_triple.clone(),
);
let runner = TestRunner::new(
dirs.clone(),
target_compiler,
use_unstable_features,
skip_tests,
bootstrap_host_compiler.triple == target_triple,
stdlib_source.clone(),
);
BUILD_EXAMPLE_OUT_DIR.ensure_fresh(dirs);
@ -241,23 +283,32 @@ pub(crate) fn run_tests(
eprintln!("[SKIP] no_sysroot tests");
}
let run_base_sysroot = config::get_bool("testsuite.base_sysroot");
let run_extended_sysroot = config::get_bool("testsuite.extended_sysroot");
let run_base_sysroot = config::get_bool("testsuite.base_sysroot")
&& !skip_tests.contains(&"testsuite.base_sysroot");
let run_extended_sysroot = config::get_bool("testsuite.extended_sysroot")
&& !skip_tests.contains(&"testsuite.extended_sysroot");
if run_base_sysroot || run_extended_sysroot {
let target_compiler = build_sysroot::build_sysroot(
let mut target_compiler = build_sysroot::build_sysroot(
dirs,
channel,
sysroot_kind,
cg_clif_dylib,
bootstrap_host_compiler,
rustup_toolchain_name,
target_triple.clone(),
);
// Rust's build system denies a couple of lints that trigger on several of the test
// projects. Changing the code to fix them is not worth it, so just silence all lints.
target_compiler.rustflags += " --cap-lints=allow";
let runner = TestRunner::new(
dirs.clone(),
target_compiler,
use_unstable_features,
skip_tests,
bootstrap_host_compiler.triple == target_triple,
stdlib_source,
);
if run_base_sysroot {
@ -274,15 +325,25 @@ pub(crate) fn run_tests(
}
}
struct TestRunner {
struct TestRunner<'a> {
is_native: bool,
jit_supported: bool,
use_unstable_features: bool,
skip_tests: &'a [&'a str],
dirs: Dirs,
target_compiler: Compiler,
stdlib_source: PathBuf,
}
impl TestRunner {
fn new(dirs: Dirs, mut target_compiler: Compiler, is_native: bool) -> Self {
impl<'a> TestRunner<'a> {
fn new(
dirs: Dirs,
mut target_compiler: Compiler,
use_unstable_features: bool,
skip_tests: &'a [&'a str],
is_native: bool,
stdlib_source: PathBuf,
) -> Self {
if let Ok(rustflags) = env::var("RUSTFLAGS") {
target_compiler.rustflags.push(' ');
target_compiler.rustflags.push_str(&rustflags);
@ -297,11 +358,20 @@ impl TestRunner {
target_compiler.rustflags.push_str(" -Clink-arg=-undefined -Clink-arg=dynamic_lookup");
}
let jit_supported = is_native
let jit_supported = use_unstable_features
&& is_native
&& target_compiler.triple.contains("x86_64")
&& !target_compiler.triple.contains("windows");
Self { is_native, jit_supported, dirs, target_compiler }
Self {
is_native,
jit_supported,
use_unstable_features,
skip_tests,
dirs,
target_compiler,
stdlib_source,
}
}
fn run_testsuite(&self, tests: &[TestCase]) {
@ -310,7 +380,10 @@ impl TestRunner {
let tag = tag.to_uppercase();
let is_jit_test = tag == "JIT";
if !config::get_bool(config) || (is_jit_test && !self.jit_supported) {
if !config::get_bool(config)
|| (is_jit_test && !self.jit_supported)
|| self.skip_tests.contains(&config)
{
eprintln!("[{tag}] {testname} (skipped)");
continue;
} else {
@ -320,10 +393,24 @@ impl TestRunner {
match *cmd {
TestCaseCmd::Custom { func } => func(self),
TestCaseCmd::BuildLib { source, crate_types } => {
self.run_rustc([source, "--crate-type", crate_types]);
if self.use_unstable_features {
self.run_rustc([source, "--crate-type", crate_types]);
} else {
self.run_rustc([
source,
"--crate-type",
crate_types,
"--cfg",
"no_unstable_features",
]);
}
}
TestCaseCmd::BuildBinAndRun { source, args } => {
self.run_rustc([source]);
if self.use_unstable_features {
self.run_rustc([source]);
} else {
self.run_rustc([source, "--cfg", "no_unstable_features"]);
}
self.run_out_command(
source.split('/').last().unwrap().split('.').next().unwrap(),
args,