summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_codegen_cranelift/build_system/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_codegen_cranelift/build_system/tests.rs')
-rw-r--r--compiler/rustc_codegen_cranelift/build_system/tests.rs59
1 files changed, 36 insertions, 23 deletions
diff --git a/compiler/rustc_codegen_cranelift/build_system/tests.rs b/compiler/rustc_codegen_cranelift/build_system/tests.rs
index 08d8f708c..e7bd8b127 100644
--- a/compiler/rustc_codegen_cranelift/build_system/tests.rs
+++ b/compiler/rustc_codegen_cranelift/build_system/tests.rs
@@ -1,16 +1,17 @@
-use super::build_sysroot;
-use super::config;
-use super::path::{Dirs, RelPath};
-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;
+use crate::build_sysroot;
+use crate::config;
+use crate::path::{Dirs, RelPath};
+use crate::prepare::{apply_patches, GitRepo};
+use crate::rustc_info::get_default_sysroot;
+use crate::shared_utils::rustflags_from_env;
+use crate::utils::{spawn_and_wait, spawn_and_wait_with_input, CargoProject, Compiler, LogGroup};
+use crate::{CodegenBackend, SysrootKind};
+
static BUILD_EXAMPLE_OUT_DIR: RelPath = RelPath::BUILD.join("example");
struct TestCase {
@@ -21,6 +22,7 @@ struct TestCase {
enum TestCaseCmd {
Custom { func: &'static dyn Fn(&TestRunner<'_>) },
BuildLib { source: &'static str, crate_types: &'static str },
+ BuildBin { source: &'static str },
BuildBinAndRun { source: &'static str, args: &'static [&'static str] },
JitBin { source: &'static str, args: &'static str },
}
@@ -39,6 +41,10 @@ impl TestCase {
Self { config, cmd: TestCaseCmd::BuildLib { source, crate_types } }
}
+ const fn build_bin(config: &'static str, source: &'static str) -> Self {
+ Self { config, cmd: TestCaseCmd::BuildBin { source } }
+ }
+
const fn build_bin_and_run(
config: &'static str,
source: &'static str,
@@ -92,6 +98,7 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
TestCase::build_bin_and_run("aot.float-minmax-pass", "example/float-minmax-pass.rs", &[]),
TestCase::build_bin_and_run("aot.mod_bench", "example/mod_bench.rs", &[]),
TestCase::build_bin_and_run("aot.issue-72793", "example/issue-72793.rs", &[]),
+ TestCase::build_bin("aot.issue-59326", "example/issue-59326.rs"),
];
// FIXME(rust-random/rand#1293): Newer rand versions fail to test on Windows. Update once this is
@@ -119,8 +126,8 @@ pub(crate) static REGEX: CargoProject = CargoProject::new(&REGEX_REPO.source_dir
pub(crate) static PORTABLE_SIMD_REPO: GitRepo = GitRepo::github(
"rust-lang",
"portable-simd",
- "ad8afa8c81273b3b49acbea38cd3bcf17a34cf2b",
- "800548f8000e31bd",
+ "7c7dbe0c505ccbc02ff30c1e37381ab1d47bf46f",
+ "5bcc9c544f6fa7bd",
"portable-simd",
);
@@ -300,7 +307,7 @@ pub(crate) fn run_tests(
);
// 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";
+ target_compiler.rustflags.push("--cap-lints=allow".to_owned());
let runner = TestRunner::new(
dirs.clone(),
@@ -344,18 +351,15 @@ impl<'a> TestRunner<'a> {
is_native: bool,
stdlib_source: PathBuf,
) -> Self {
- if let Ok(rustflags) = env::var("RUSTFLAGS") {
- target_compiler.rustflags.push(' ');
- target_compiler.rustflags.push_str(&rustflags);
- }
- if let Ok(rustdocflags) = env::var("RUSTDOCFLAGS") {
- target_compiler.rustdocflags.push(' ');
- target_compiler.rustdocflags.push_str(&rustdocflags);
- }
+ target_compiler.rustflags.extend(rustflags_from_env("RUSTFLAGS"));
+ target_compiler.rustdocflags.extend(rustflags_from_env("RUSTDOCFLAGS"));
// FIXME fix `#[linkage = "extern_weak"]` without this
if target_compiler.triple.contains("darwin") {
- target_compiler.rustflags.push_str(" -Clink-arg=-undefined -Clink-arg=dynamic_lookup");
+ target_compiler.rustflags.extend([
+ "-Clink-arg=-undefined".to_owned(),
+ "-Clink-arg=dynamic_lookup".to_owned(),
+ ]);
}
let jit_supported = use_unstable_features
@@ -380,15 +384,17 @@ impl<'a> TestRunner<'a> {
let tag = tag.to_uppercase();
let is_jit_test = tag == "JIT";
- if !config::get_bool(config)
+ let _guard = if !config::get_bool(config)
|| (is_jit_test && !self.jit_supported)
|| self.skip_tests.contains(&config)
{
eprintln!("[{tag}] {testname} (skipped)");
continue;
} else {
+ let guard = LogGroup::guard(&format!("[{tag}] {testname}"));
eprintln!("[{tag}] {testname}");
- }
+ guard
+ };
match *cmd {
TestCaseCmd::Custom { func } => func(self),
@@ -405,6 +411,13 @@ impl<'a> TestRunner<'a> {
]);
}
}
+ TestCaseCmd::BuildBin { source } => {
+ if self.use_unstable_features {
+ self.run_rustc([source]);
+ } else {
+ self.run_rustc([source, "--cfg", "no_unstable_features"]);
+ }
+ }
TestCaseCmd::BuildBinAndRun { source, args } => {
if self.use_unstable_features {
self.run_rustc([source]);
@@ -455,7 +468,7 @@ impl<'a> TestRunner<'a> {
S: AsRef<OsStr>,
{
let mut cmd = Command::new(&self.target_compiler.rustc);
- cmd.args(self.target_compiler.rustflags.split_whitespace());
+ cmd.args(&self.target_compiler.rustflags);
cmd.arg("-L");
cmd.arg(format!("crate={}", BUILD_EXAMPLE_OUT_DIR.to_path(&self.dirs).display()));
cmd.arg("--out-dir");