Skip to content

Commit 2aff8d8

Browse files
committed
Accept only //@-style directives in ui tests
1 parent a5d64bb commit 2aff8d8

File tree

1 file changed

+42
-26
lines changed

1 file changed

+42
-26
lines changed

src/tools/compiletest/src/header.rs

+42-26
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl EarlyProps {
4646

4747
pub fn from_reader<R: Read>(config: &Config, testfile: &Path, rdr: R) -> Self {
4848
let mut props = EarlyProps::default();
49-
iter_header(testfile, rdr, &mut |_, ln, _| {
49+
iter_header(config.mode, testfile, rdr, &mut |_, ln, _| {
5050
config.push_name_value_directive(ln, directives::AUX_BUILD, &mut props.aux, |r| {
5151
r.trim().to_string()
5252
});
@@ -306,7 +306,7 @@ impl TestProps {
306306
if !testfile.is_dir() {
307307
let file = File::open(testfile).unwrap();
308308

309-
iter_header(testfile, file, &mut |revision, ln, _| {
309+
iter_header(self.config.mode, testfile, file, &mut |revision, ln, _| {
310310
if revision.is_some() && revision != cfg {
311311
return;
312312
}
@@ -628,11 +628,17 @@ pub fn line_directive<'line>(
628628
}
629629
}
630630

631-
fn iter_header<R: Read>(testfile: &Path, rdr: R, it: &mut dyn FnMut(Option<&str>, &str, usize)) {
632-
iter_header_extra(testfile, rdr, &[], it)
631+
fn iter_header<R: Read>(
632+
mode: Mode,
633+
testfile: &Path,
634+
rdr: R,
635+
it: &mut dyn FnMut(Option<&str>, &str, usize),
636+
) {
637+
iter_header_extra(mode, testfile, rdr, &[], it)
633638
}
634639

635640
fn iter_header_extra(
641+
mode: Mode,
636642
testfile: &Path,
637643
rdr: impl Read,
638644
extra_directives: &[&str],
@@ -648,7 +654,11 @@ fn iter_header_extra(
648654
it(None, directive, 0);
649655
}
650656

651-
let comment = if testfile.extension().is_some_and(|e| e == "rs") { "//" } else { "#" };
657+
let comment = if testfile.extension().is_some_and(|e| e == "rs") {
658+
if mode == Mode::Ui { "//@" } else { "//" }
659+
} else {
660+
"#"
661+
};
652662

653663
let mut rdr = BufReader::new(rdr);
654664
let mut ln = String::new();
@@ -946,12 +956,17 @@ pub fn make_test_description<R: Read>(
946956
_ => &[],
947957
};
948958

949-
iter_header_extra(path, src, extra_directives, &mut |revision, ln, line_number| {
950-
if revision.is_some() && revision != cfg {
951-
return;
952-
}
959+
iter_header_extra(
960+
config.mode,
961+
path,
962+
src,
963+
extra_directives,
964+
&mut |revision, ln, line_number| {
965+
if revision.is_some() && revision != cfg {
966+
return;
967+
}
953968

954-
macro_rules! decision {
969+
macro_rules! decision {
955970
($e:expr) => {
956971
match $e {
957972
IgnoreDecision::Ignore { reason } => {
@@ -971,24 +986,25 @@ pub fn make_test_description<R: Read>(
971986
};
972987
}
973988

974-
decision!(cfg::handle_ignore(config, ln));
975-
decision!(cfg::handle_only(config, ln));
976-
decision!(needs::handle_needs(&cache.needs, config, ln));
977-
decision!(ignore_llvm(config, ln));
978-
decision!(ignore_cdb(config, ln));
979-
decision!(ignore_gdb(config, ln));
980-
decision!(ignore_lldb(config, ln));
981-
982-
if config.target == "wasm32-unknown-unknown" {
983-
if config.parse_name_directive(ln, directives::CHECK_RUN_RESULTS) {
984-
decision!(IgnoreDecision::Ignore {
985-
reason: "ignored when checking the run results on WASM".into(),
986-
});
989+
decision!(cfg::handle_ignore(config, ln));
990+
decision!(cfg::handle_only(config, ln));
991+
decision!(needs::handle_needs(&cache.needs, config, ln));
992+
decision!(ignore_llvm(config, ln));
993+
decision!(ignore_cdb(config, ln));
994+
decision!(ignore_gdb(config, ln));
995+
decision!(ignore_lldb(config, ln));
996+
997+
if config.target == "wasm32-unknown-unknown" {
998+
if config.parse_name_directive(ln, directives::CHECK_RUN_RESULTS) {
999+
decision!(IgnoreDecision::Ignore {
1000+
reason: "ignored when checking the run results on WASM".into(),
1001+
});
1002+
}
9871003
}
988-
}
9891004

990-
should_fail |= config.parse_name_directive(ln, "should-fail");
991-
});
1005+
should_fail |= config.parse_name_directive(ln, "should-fail");
1006+
},
1007+
);
9921008

9931009
// The `should-fail` annotation doesn't apply to pretty tests,
9941010
// since we run the pretty printer across all tests by default.

0 commit comments

Comments
 (0)