Allow skipping tests from the commandline

This commit is contained in:
bjorn3 2023-06-05 15:15:48 +00:00
parent 8c1c84d79e
commit a691b14aee
3 changed files with 31 additions and 9 deletions

View File

@ -90,6 +90,7 @@ fn main() {
let mut sysroot_kind = SysrootKind::Clif; let mut sysroot_kind = SysrootKind::Clif;
let mut use_unstable_features = true; let mut use_unstable_features = true;
let mut frozen = false; let mut frozen = false;
let mut skip_tests = vec![];
let mut use_backend = None; let mut use_backend = None;
while let Some(arg) = args.next().as_deref() { while let Some(arg) = args.next().as_deref() {
match arg { match arg {
@ -115,6 +116,12 @@ fn main() {
} }
"--no-unstable-features" => use_unstable_features = false, "--no-unstable-features" => use_unstable_features = false,
"--frozen" => frozen = true, "--frozen" => frozen = true,
"--skip-test" => {
// FIXME check that all passed in tests actually exist
skip_tests.push(args.next().unwrap_or_else(|| {
arg_error!("--skip-test requires argument");
}));
}
"--use-backend" => { "--use-backend" => {
use_backend = Some(match args.next() { use_backend = Some(match args.next() {
Some(name) => name, Some(name) => name,
@ -218,6 +225,7 @@ fn main() {
channel, channel,
sysroot_kind, sysroot_kind,
use_unstable_features, use_unstable_features,
&skip_tests.iter().map(|test| &**test).collect::<Vec<_>>(),
&cg_clif_dylib, &cg_clif_dylib,
&bootstrap_host_compiler, &bootstrap_host_compiler,
rustup_toolchain_name.as_deref(), rustup_toolchain_name.as_deref(),

View File

@ -19,7 +19,7 @@ struct TestCase {
} }
enum TestCaseCmd { enum TestCaseCmd {
Custom { func: &'static dyn Fn(&TestRunner) }, Custom { func: &'static dyn Fn(&TestRunner<'_>) },
BuildLib { source: &'static str, crate_types: &'static str }, BuildLib { source: &'static str, crate_types: &'static str },
BuildBinAndRun { source: &'static str, args: &'static [&'static str] }, BuildBinAndRun { source: &'static str, args: &'static [&'static str] },
JitBin { source: &'static str, args: &'static str }, JitBin { source: &'static str, args: &'static str },
@ -27,7 +27,7 @@ enum TestCaseCmd {
impl TestCase { impl TestCase {
// FIXME reduce usage of custom test case commands // 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 } } Self { config, cmd: TestCaseCmd::Custom { func } }
} }
@ -247,6 +247,7 @@ pub(crate) fn run_tests(
channel: &str, channel: &str,
sysroot_kind: SysrootKind, sysroot_kind: SysrootKind,
use_unstable_features: bool, use_unstable_features: bool,
skip_tests: &[&str],
cg_clif_dylib: &CodegenBackend, cg_clif_dylib: &CodegenBackend,
bootstrap_host_compiler: &Compiler, bootstrap_host_compiler: &Compiler,
rustup_toolchain_name: Option<&str>, rustup_toolchain_name: Option<&str>,
@ -256,7 +257,7 @@ pub(crate) fn run_tests(
get_default_sysroot(&bootstrap_host_compiler.rustc).join("lib/rustlib/src/rust"); get_default_sysroot(&bootstrap_host_compiler.rustc).join("lib/rustlib/src/rust");
assert!(stdlib_source.exists()); assert!(stdlib_source.exists());
if config::get_bool("testsuite.no_sysroot") { if config::get_bool("testsuite.no_sysroot") && !skip_tests.contains(&"testsuite.no_sysroot") {
let target_compiler = build_sysroot::build_sysroot( let target_compiler = build_sysroot::build_sysroot(
dirs, dirs,
channel, channel,
@ -271,6 +272,7 @@ pub(crate) fn run_tests(
dirs.clone(), dirs.clone(),
target_compiler, target_compiler,
use_unstable_features, use_unstable_features,
skip_tests,
bootstrap_host_compiler.triple == target_triple, bootstrap_host_compiler.triple == target_triple,
stdlib_source.clone(), stdlib_source.clone(),
); );
@ -281,8 +283,10 @@ pub(crate) fn run_tests(
eprintln!("[SKIP] no_sysroot tests"); eprintln!("[SKIP] no_sysroot tests");
} }
let run_base_sysroot = config::get_bool("testsuite.base_sysroot"); let run_base_sysroot = config::get_bool("testsuite.base_sysroot")
let run_extended_sysroot = config::get_bool("testsuite.extended_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 { if run_base_sysroot || run_extended_sysroot {
let mut target_compiler = build_sysroot::build_sysroot( let mut target_compiler = build_sysroot::build_sysroot(
@ -302,6 +306,7 @@ pub(crate) fn run_tests(
dirs.clone(), dirs.clone(),
target_compiler, target_compiler,
use_unstable_features, use_unstable_features,
skip_tests,
bootstrap_host_compiler.triple == target_triple, bootstrap_host_compiler.triple == target_triple,
stdlib_source, stdlib_source,
); );
@ -320,20 +325,22 @@ pub(crate) fn run_tests(
} }
} }
struct TestRunner { struct TestRunner<'a> {
is_native: bool, is_native: bool,
jit_supported: bool, jit_supported: bool,
use_unstable_features: bool, use_unstable_features: bool,
skip_tests: &'a [&'a str],
dirs: Dirs, dirs: Dirs,
target_compiler: Compiler, target_compiler: Compiler,
stdlib_source: PathBuf, stdlib_source: PathBuf,
} }
impl TestRunner { impl<'a> TestRunner<'a> {
fn new( fn new(
dirs: Dirs, dirs: Dirs,
mut target_compiler: Compiler, mut target_compiler: Compiler,
use_unstable_features: bool, use_unstable_features: bool,
skip_tests: &'a [&'a str],
is_native: bool, is_native: bool,
stdlib_source: PathBuf, stdlib_source: PathBuf,
) -> Self { ) -> Self {
@ -360,6 +367,7 @@ fn new(
is_native, is_native,
jit_supported, jit_supported,
use_unstable_features, use_unstable_features,
skip_tests,
dirs, dirs,
target_compiler, target_compiler,
stdlib_source, stdlib_source,
@ -372,7 +380,10 @@ fn run_testsuite(&self, tests: &[TestCase]) {
let tag = tag.to_uppercase(); let tag = tag.to_uppercase();
let is_jit_test = tag == "JIT"; 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)"); eprintln!("[{tag}] {testname} (skipped)");
continue; continue;
} else { } else {

View File

@ -3,7 +3,7 @@ The build system of cg_clif.
USAGE: USAGE:
./y.sh prepare [--out-dir DIR] [--download-dir DIR] ./y.sh prepare [--out-dir DIR] [--download-dir DIR]
./y.sh build [--debug] [--sysroot none|clif|llvm] [--out-dir DIR] [--download-dir DIR] [--no-unstable-features] [--frozen] ./y.sh build [--debug] [--sysroot none|clif|llvm] [--out-dir DIR] [--download-dir DIR] [--no-unstable-features] [--frozen]
./y.sh test [--debug] [--sysroot none|clif|llvm] [--out-dir DIR] [--download-dir DIR] [--no-unstable-features] [--frozen] ./y.sh test [--debug] [--sysroot none|clif|llvm] [--out-dir DIR] [--download-dir DIR] [--no-unstable-features] [--frozen] [--skip-test TESTNAME]
./y.sh abi-cafe [--debug] [--sysroot none|clif|llvm] [--out-dir DIR] [--download-dir DIR] [--no-unstable-features] [--frozen] ./y.sh abi-cafe [--debug] [--sysroot none|clif|llvm] [--out-dir DIR] [--download-dir DIR] [--no-unstable-features] [--frozen]
./y.sh bench [--debug] [--sysroot none|clif|llvm] [--out-dir DIR] [--download-dir DIR] [--no-unstable-features] [--frozen] ./y.sh bench [--debug] [--sysroot none|clif|llvm] [--out-dir DIR] [--download-dir DIR] [--no-unstable-features] [--frozen]
@ -32,6 +32,9 @@ OPTIONS:
--frozen --frozen
Require Cargo.lock and cache are up to date Require Cargo.lock and cache are up to date
--skip-test TESTNAME
Skip testing the TESTNAME test. The test name format is the same as config.txt.
--use-backend NAME --use-backend NAME
Use the existing Cranelift (or other) backend of the rustc with which we built. Use the existing Cranelift (or other) backend of the rustc with which we built.
Warning: This is meant for use in rust's CI only! Warning: This is meant for use in rust's CI only!