Skip to content

Commit 741a0ec

Browse files
committed
show all invalid directives errors rather than just the first one
1 parent 55c0767 commit 741a0ec

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

src/tools/compiletest/src/header.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,7 @@ pub fn make_test_description<R: Read>(
851851
path: &Path,
852852
src: R,
853853
cfg: Option<&str>,
854+
poisoned: &mut bool,
854855
) -> test::TestDesc {
855856
let mut ignore = false;
856857
let mut ignore_message = None;
@@ -875,7 +876,8 @@ pub fn make_test_description<R: Read>(
875876
}
876877
IgnoreDecision::Error { message } => {
877878
eprintln!("error: {}: {message}", path.display());
878-
panic!();
879+
*poisoned = true;
880+
return;
879881
}
880882
IgnoreDecision::Continue => {}
881883
}

src/tools/compiletest/src/header/tests.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
1+
use std::io::Read;
12
use std::path::Path;
23

34
use crate::common::{Config, Debugger};
4-
use crate::header::{make_test_description, parse_normalization_string, EarlyProps};
5+
use crate::header::{parse_normalization_string, EarlyProps};
6+
7+
fn make_test_description<R: Read>(
8+
config: &Config,
9+
name: test::TestName,
10+
path: &Path,
11+
src: R,
12+
cfg: Option<&str>,
13+
) -> test::TestDesc {
14+
let mut poisoned = false;
15+
let test = crate::header::make_test_description(config, name, path, src, cfg, &mut poisoned);
16+
if poisoned {
17+
panic!("poisoned!");
18+
}
19+
test
20+
}
521

622
#[test]
723
fn test_parse_normalization_string() {

src/tools/compiletest/src/main.rs

+16-3
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,8 @@ pub fn make_tests(
555555
let modified_tests = modified_tests(&config, &config.src_base).unwrap_or_else(|err| {
556556
panic!("modified_tests got error from dir: {}, error: {}", config.src_base.display(), err)
557557
});
558+
559+
let mut poisoned = false;
558560
collect_tests_from_dir(
559561
config.clone(),
560562
&config.src_base,
@@ -563,8 +565,14 @@ pub fn make_tests(
563565
tests,
564566
found_paths,
565567
&modified_tests,
568+
&mut poisoned,
566569
)
567570
.unwrap_or_else(|_| panic!("Could not read tests from {}", config.src_base.display()));
571+
572+
if poisoned {
573+
eprintln!();
574+
panic!("there are errors in tests");
575+
}
568576
}
569577

570578
/// Returns a stamp constructed from input files common to all test cases.
@@ -634,6 +642,7 @@ fn collect_tests_from_dir(
634642
tests: &mut Vec<test::TestDescAndFn>,
635643
found_paths: &mut BTreeSet<PathBuf>,
636644
modified_tests: &Vec<PathBuf>,
645+
poisoned: &mut bool,
637646
) -> io::Result<()> {
638647
// Ignore directories that contain a file named `compiletest-ignore-dir`.
639648
if dir.join("compiletest-ignore-dir").exists() {
@@ -645,7 +654,7 @@ fn collect_tests_from_dir(
645654
file: dir.to_path_buf(),
646655
relative_dir: relative_dir_path.parent().unwrap().to_path_buf(),
647656
};
648-
tests.extend(make_test(config, &paths, inputs));
657+
tests.extend(make_test(config, &paths, inputs, poisoned));
649658
return Ok(());
650659
}
651660

@@ -671,7 +680,7 @@ fn collect_tests_from_dir(
671680
let paths =
672681
TestPaths { file: file_path, relative_dir: relative_dir_path.to_path_buf() };
673682

674-
tests.extend(make_test(config.clone(), &paths, inputs))
683+
tests.extend(make_test(config.clone(), &paths, inputs, poisoned))
675684
} else if file_path.is_dir() {
676685
let relative_file_path = relative_dir_path.join(file.file_name());
677686
if &file_name != "auxiliary" {
@@ -684,6 +693,7 @@ fn collect_tests_from_dir(
684693
tests,
685694
found_paths,
686695
modified_tests,
696+
poisoned,
687697
)?;
688698
}
689699
} else {
@@ -710,6 +720,7 @@ fn make_test(
710720
config: Arc<Config>,
711721
testpaths: &TestPaths,
712722
inputs: &Stamp,
723+
poisoned: &mut bool,
713724
) -> Vec<test::TestDescAndFn> {
714725
let test_path = if config.mode == Mode::RunMake {
715726
// Parse directives in the Makefile
@@ -726,14 +737,16 @@ fn make_test(
726737
} else {
727738
early_props.revisions.iter().map(Some).collect()
728739
};
740+
729741
revisions
730742
.into_iter()
731743
.map(|revision| {
732744
let src_file =
733745
std::fs::File::open(&test_path).expect("open test file to parse ignores");
734746
let cfg = revision.map(|v| &**v);
735747
let test_name = crate::make_test_name(&config, testpaths, revision);
736-
let mut desc = make_test_description(&config, test_name, &test_path, src_file, cfg);
748+
let mut desc =
749+
make_test_description(&config, test_name, &test_path, src_file, cfg, poisoned);
737750
// Ignore tests that already run and are up to date with respect to inputs.
738751
if !config.force_rerun {
739752
desc.ignore |= is_up_to_date(

0 commit comments

Comments
 (0)