Skip to content

Commit 81dc91e

Browse files
Support build-pass in codegen tests
1 parent 571aac9 commit 81dc91e

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/tools/compiletest/src/header.rs

+9-12
Original file line numberDiff line numberDiff line change
@@ -541,16 +541,15 @@ impl TestProps {
541541
}
542542

543543
fn update_pass_mode(&mut self, ln: &str, revision: Option<&str>, config: &Config) {
544-
let check_no_run = |s| {
545-
if config.mode != Mode::Ui && config.mode != Mode::Incremental {
546-
panic!("`{}` header is only supported in UI and incremental tests", s);
547-
}
548-
if config.mode == Mode::Incremental
549-
&& !revision.map_or(false, |r| r.starts_with("cfail"))
550-
&& !self.revisions.iter().all(|r| r.starts_with("cfail"))
551-
{
552-
panic!("`{}` header is only supported in `cfail` incremental tests", s);
544+
let check_no_run = |s| match (config.mode, s) {
545+
(Mode::Ui, _) => (),
546+
(Mode::Codegen, "build-pass") => (),
547+
(Mode::Incremental, _) => {
548+
if revision.is_some() && !self.revisions.iter().all(|r| r.starts_with("cfail")) {
549+
panic!("`{s}` header is only supported in `cfail` incremental tests")
550+
}
553551
}
552+
(mode, _) => panic!("`{s}` header is not supported in `{mode}` tests"),
554553
};
555554
let pass_mode = if config.parse_name_directive(ln, "check-pass") {
556555
check_no_run("check-pass");
@@ -559,9 +558,7 @@ impl TestProps {
559558
check_no_run("build-pass");
560559
Some(PassMode::Build)
561560
} else if config.parse_name_directive(ln, "run-pass") {
562-
if config.mode != Mode::Ui {
563-
panic!("`run-pass` header is only supported in UI tests")
564-
}
561+
check_no_run("run-pass");
565562
Some(PassMode::Run)
566563
} else {
567564
None

src/tools/compiletest/src/runtest.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2752,6 +2752,10 @@ impl<'test> TestCx<'test> {
27522752
self.fatal_proc_rec("compilation failed!", &proc_res);
27532753
}
27542754

2755+
if let Some(PassMode::Build) = self.pass_mode() {
2756+
return;
2757+
}
2758+
27552759
let output_path = self.output_base_name().with_extension("ll");
27562760
let proc_res = self.verify_with_filecheck(&output_path);
27572761
if !proc_res.status.success() {

0 commit comments

Comments
 (0)