about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/tools/compiletest/src/header.rs4
-rw-r--r--src/tools/compiletest/src/header/tests.rs18
-rw-r--r--src/tools/compiletest/src/main.rs19
3 files changed, 36 insertions, 5 deletions
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs
index 8d2fd881d26..a83cf33589f 100644
--- a/src/tools/compiletest/src/header.rs
+++ b/src/tools/compiletest/src/header.rs
@@ -851,6 +851,7 @@ pub fn make_test_description<R: Read>(
     path: &Path,
     src: R,
     cfg: Option<&str>,
+    poisoned: &mut bool,
 ) -> test::TestDesc {
     let mut ignore = false;
     let mut ignore_message = None;
@@ -875,7 +876,8 @@ pub fn make_test_description<R: Read>(
                     }
                     IgnoreDecision::Error { message } => {
                         eprintln!("error: {}: {message}", path.display());
-                        panic!();
+                        *poisoned = true;
+                        return;
                     }
                     IgnoreDecision::Continue => {}
                 }
diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs
index acd588d7fee..8ee8aa14401 100644
--- a/src/tools/compiletest/src/header/tests.rs
+++ b/src/tools/compiletest/src/header/tests.rs
@@ -1,7 +1,23 @@
+use std::io::Read;
 use std::path::Path;
 
 use crate::common::{Config, Debugger};
-use crate::header::{make_test_description, parse_normalization_string, EarlyProps};
+use crate::header::{parse_normalization_string, EarlyProps};
+
+fn make_test_description<R: Read>(
+    config: &Config,
+    name: test::TestName,
+    path: &Path,
+    src: R,
+    cfg: Option<&str>,
+) -> test::TestDesc {
+    let mut poisoned = false;
+    let test = crate::header::make_test_description(config, name, path, src, cfg, &mut poisoned);
+    if poisoned {
+        panic!("poisoned!");
+    }
+    test
+}
 
 #[test]
 fn test_parse_normalization_string() {
diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs
index cfb1ee34f67..5bffd05dbd5 100644
--- a/src/tools/compiletest/src/main.rs
+++ b/src/tools/compiletest/src/main.rs
@@ -555,6 +555,8 @@ pub fn make_tests(
     let modified_tests = modified_tests(&config, &config.src_base).unwrap_or_else(|err| {
         panic!("modified_tests got error from dir: {}, error: {}", config.src_base.display(), err)
     });
+
+    let mut poisoned = false;
     collect_tests_from_dir(
         config.clone(),
         &config.src_base,
@@ -563,8 +565,14 @@ pub fn make_tests(
         tests,
         found_paths,
         &modified_tests,
+        &mut poisoned,
     )
     .unwrap_or_else(|_| panic!("Could not read tests from {}", config.src_base.display()));
+
+    if poisoned {
+        eprintln!();
+        panic!("there are errors in tests");
+    }
 }
 
 /// Returns a stamp constructed from input files common to all test cases.
@@ -634,6 +642,7 @@ fn collect_tests_from_dir(
     tests: &mut Vec<test::TestDescAndFn>,
     found_paths: &mut BTreeSet<PathBuf>,
     modified_tests: &Vec<PathBuf>,
+    poisoned: &mut bool,
 ) -> io::Result<()> {
     // Ignore directories that contain a file named `compiletest-ignore-dir`.
     if dir.join("compiletest-ignore-dir").exists() {
@@ -645,7 +654,7 @@ fn collect_tests_from_dir(
             file: dir.to_path_buf(),
             relative_dir: relative_dir_path.parent().unwrap().to_path_buf(),
         };
-        tests.extend(make_test(config, &paths, inputs));
+        tests.extend(make_test(config, &paths, inputs, poisoned));
         return Ok(());
     }
 
@@ -671,7 +680,7 @@ fn collect_tests_from_dir(
             let paths =
                 TestPaths { file: file_path, relative_dir: relative_dir_path.to_path_buf() };
 
-            tests.extend(make_test(config.clone(), &paths, inputs))
+            tests.extend(make_test(config.clone(), &paths, inputs, poisoned))
         } else if file_path.is_dir() {
             let relative_file_path = relative_dir_path.join(file.file_name());
             if &file_name != "auxiliary" {
@@ -684,6 +693,7 @@ fn collect_tests_from_dir(
                     tests,
                     found_paths,
                     modified_tests,
+                    poisoned,
                 )?;
             }
         } else {
@@ -710,6 +720,7 @@ fn make_test(
     config: Arc<Config>,
     testpaths: &TestPaths,
     inputs: &Stamp,
+    poisoned: &mut bool,
 ) -> Vec<test::TestDescAndFn> {
     let test_path = if config.mode == Mode::RunMake {
         // Parse directives in the Makefile
@@ -726,6 +737,7 @@ fn make_test(
     } else {
         early_props.revisions.iter().map(Some).collect()
     };
+
     revisions
         .into_iter()
         .map(|revision| {
@@ -733,7 +745,8 @@ fn make_test(
                 std::fs::File::open(&test_path).expect("open test file to parse ignores");
             let cfg = revision.map(|v| &**v);
             let test_name = crate::make_test_name(&config, testpaths, revision);
-            let mut desc = make_test_description(&config, test_name, &test_path, src_file, cfg);
+            let mut desc =
+                make_test_description(&config, test_name, &test_path, src_file, cfg, poisoned);
             // Ignore tests that already run and are up to date with respect to inputs.
             if !config.force_rerun {
                 desc.ignore |= is_up_to_date(