compiletest: Move pass mode update into a separate function
This commit is contained in:
parent
932ea64175
commit
0886bc4cbf
@ -526,38 +526,7 @@ fn load_from(&mut self, testfile: &Path, cfg: Option<&str>, config: &Config) {
|
||||
self.check_test_line_numbers_match = config.parse_check_test_line_numbers_match(ln);
|
||||
}
|
||||
|
||||
let check_no_run = |s| {
|
||||
if config.mode != Mode::Ui && config.mode != Mode::Incremental {
|
||||
panic!("`{}` header is only supported in UI and incremental tests", s);
|
||||
}
|
||||
if config.mode == Mode::Incremental &&
|
||||
!cfg.map_or(false, |r| r.starts_with("cfail")) &&
|
||||
!self.revisions.iter().all(|r| r.starts_with("cfail")) {
|
||||
panic!("`{}` header is only supported in `cfail` incremental tests", s);
|
||||
}
|
||||
};
|
||||
let pass_mode = if config.parse_name_directive(ln, "check-pass") {
|
||||
check_no_run("check-pass");
|
||||
Some(PassMode::Check)
|
||||
} else if config.parse_name_directive(ln, "build-pass") {
|
||||
check_no_run("build-pass");
|
||||
Some(PassMode::Build)
|
||||
} else if config.parse_name_directive(ln, "compile-pass") /* compatibility */ {
|
||||
check_no_run("compile-pass");
|
||||
Some(PassMode::Build)
|
||||
} else if config.parse_name_directive(ln, "run-pass") {
|
||||
if config.mode != Mode::Ui && config.mode != Mode::RunPass /* compatibility */ {
|
||||
panic!("`run-pass` header is only supported in UI tests")
|
||||
}
|
||||
Some(PassMode::Run)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
match (self.pass_mode, pass_mode) {
|
||||
(None, Some(_)) => self.pass_mode = pass_mode,
|
||||
(Some(_), Some(_)) => panic!("multiple `*-pass` headers in a single test"),
|
||||
(_, None) => {}
|
||||
}
|
||||
self.update_pass_mode(ln, cfg, config);
|
||||
|
||||
if !self.disable_ui_testing_normalization {
|
||||
self.disable_ui_testing_normalization =
|
||||
@ -604,6 +573,41 @@ fn load_from(&mut self, testfile: &Path, cfg: Option<&str>, config: &Config) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn update_pass_mode(&mut self, ln: &str, revision: Option<&str>, config: &Config) {
|
||||
let check_no_run = |s| {
|
||||
if config.mode != Mode::Ui && config.mode != Mode::Incremental {
|
||||
panic!("`{}` header is only supported in UI and incremental tests", s);
|
||||
}
|
||||
if config.mode == Mode::Incremental &&
|
||||
!revision.map_or(false, |r| r.starts_with("cfail")) &&
|
||||
!self.revisions.iter().all(|r| r.starts_with("cfail")) {
|
||||
panic!("`{}` header is only supported in `cfail` incremental tests", s);
|
||||
}
|
||||
};
|
||||
let pass_mode = if config.parse_name_directive(ln, "check-pass") {
|
||||
check_no_run("check-pass");
|
||||
Some(PassMode::Check)
|
||||
} else if config.parse_name_directive(ln, "build-pass") {
|
||||
check_no_run("build-pass");
|
||||
Some(PassMode::Build)
|
||||
} else if config.parse_name_directive(ln, "compile-pass") /* compatibility */ {
|
||||
check_no_run("compile-pass");
|
||||
Some(PassMode::Build)
|
||||
} else if config.parse_name_directive(ln, "run-pass") {
|
||||
if config.mode != Mode::Ui && config.mode != Mode::RunPass /* compatibility */ {
|
||||
panic!("`run-pass` header is only supported in UI tests")
|
||||
}
|
||||
Some(PassMode::Run)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
match (self.pass_mode, pass_mode) {
|
||||
(None, Some(_)) => self.pass_mode = pass_mode,
|
||||
(Some(_), Some(_)) => panic!("multiple `*-pass` headers in a single test"),
|
||||
(_, None) => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn iter_header(testfile: &Path, cfg: Option<&str>, it: &mut dyn FnMut(&str)) {
|
||||
|
Loading…
Reference in New Issue
Block a user