about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-06-05 15:15:48 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-06-13 16:39:59 +0000
commita691b14aeeea6de133c23050e33732b5fe620a7b (patch)
tree3e73720217921c6461976c35202ee44673f593e5
parent8c1c84d79e26e5250d3ad1ee894843c01785787a (diff)
downloadrust-a691b14aeeea6de133c23050e33732b5fe620a7b.tar.gz
rust-a691b14aeeea6de133c23050e33732b5fe620a7b.zip
Allow skipping tests from the commandline
-rw-r--r--build_system/main.rs8
-rw-r--r--build_system/tests.rs27
-rw-r--r--build_system/usage.txt5
3 files changed, 31 insertions, 9 deletions
diff --git a/build_system/main.rs b/build_system/main.rs
index d51e5027cf3..41d0d6f2319 100644
--- a/build_system/main.rs
+++ b/build_system/main.rs
@@ -90,6 +90,7 @@ fn main() {
     let mut sysroot_kind = SysrootKind::Clif;
     let mut use_unstable_features = true;
     let mut frozen = false;
+    let mut skip_tests = vec![];
     let mut use_backend = None;
     while let Some(arg) = args.next().as_deref() {
         match arg {
@@ -115,6 +116,12 @@ fn main() {
             }
             "--no-unstable-features" => use_unstable_features = false,
             "--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 = Some(match args.next() {
                     Some(name) => name,
@@ -218,6 +225,7 @@ fn main() {
                 channel,
                 sysroot_kind,
                 use_unstable_features,
+                &skip_tests.iter().map(|test| &**test).collect::<Vec<_>>(),
                 &cg_clif_dylib,
                 &bootstrap_host_compiler,
                 rustup_toolchain_name.as_deref(),
diff --git a/build_system/tests.rs b/build_system/tests.rs
index 733a572400b..08d8f708c7d 100644
--- a/build_system/tests.rs
+++ b/build_system/tests.rs
@@ -19,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 },
@@ -27,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 } }
     }
 
@@ -247,6 +247,7 @@ pub(crate) fn run_tests(
     channel: &str,
     sysroot_kind: SysrootKind,
     use_unstable_features: bool,
+    skip_tests: &[&str],
     cg_clif_dylib: &CodegenBackend,
     bootstrap_host_compiler: &Compiler,
     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");
     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(
             dirs,
             channel,
@@ -271,6 +272,7 @@ pub(crate) fn run_tests(
             dirs.clone(),
             target_compiler,
             use_unstable_features,
+            skip_tests,
             bootstrap_host_compiler.triple == target_triple,
             stdlib_source.clone(),
         );
@@ -281,8 +283,10 @@ 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 mut target_compiler = build_sysroot::build_sysroot(
@@ -302,6 +306,7 @@ pub(crate) fn run_tests(
             dirs.clone(),
             target_compiler,
             use_unstable_features,
+            skip_tests,
             bootstrap_host_compiler.triple == target_triple,
             stdlib_source,
         );
@@ -320,20 +325,22 @@ 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 {
+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 {
@@ -360,6 +367,7 @@ impl TestRunner {
             is_native,
             jit_supported,
             use_unstable_features,
+            skip_tests,
             dirs,
             target_compiler,
             stdlib_source,
@@ -372,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 {
diff --git a/build_system/usage.txt b/build_system/usage.txt
index 9d20cdca6a7..6d3b3a13d6e 100644
--- a/build_system/usage.txt
+++ b/build_system/usage.txt
@@ -3,7 +3,7 @@ The build system of cg_clif.
 USAGE:
     ./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 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 bench [--debug] [--sysroot none|clif|llvm] [--out-dir DIR] [--download-dir DIR] [--no-unstable-features] [--frozen]
 
@@ -32,6 +32,9 @@ OPTIONS:
     --frozen
             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 the existing Cranelift (or other) backend of the rustc with which we built.
             Warning: This is meant for use in rust's CI only!