Skip to content

Commit 90a189c

Browse files
committed
Update compiletest to only accept //@ directives
1 parent 0840502 commit 90a189c

File tree

3 files changed

+13
-30
lines changed

3 files changed

+13
-30
lines changed

src/tools/compiletest/src/header.rs

+7-14
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ struct HeaderLine<'ln> {
869869

870870
fn iter_header(
871871
mode: Mode,
872-
suite: &str,
872+
_suite: &str,
873873
poisoned: &mut bool,
874874
testfile: &Path,
875875
rdr: impl Read,
@@ -900,11 +900,7 @@ fn iter_header(
900900
}
901901
}
902902

903-
let comment = if testfile.extension().is_some_and(|e| e == "rs") {
904-
if mode == Mode::Ui && suite == "ui" { "//@" } else { "//" }
905-
} else {
906-
"#"
907-
};
903+
let comment = if testfile.extension().is_some_and(|e| e == "rs") { "//@" } else { "#" };
908904

909905
let mut rdr = BufReader::with_capacity(1024, rdr);
910906
let mut ln = String::new();
@@ -931,7 +927,7 @@ fn iter_header(
931927
// First try to accept `ui_test` style comments
932928
} else if let Some((header_revision, directive)) = line_directive(comment, ln) {
933929
it(HeaderLine { line_number, original_line, header_revision, directive });
934-
} else if mode == Mode::Ui && suite == "ui" && !REVISION_MAGIC_COMMENT_RE.is_match(ln) {
930+
} else if !REVISION_MAGIC_COMMENT_RE.is_match(ln) {
935931
let Some((_, rest)) = line_directive("//", ln) else {
936932
continue;
937933
};
@@ -951,7 +947,7 @@ fn iter_header(
951947
// directive. We emit an error here to warn the user.
952948
*poisoned = true;
953949
eprintln!(
954-
"error: detected legacy-style directives in ui test: {}:{}, please use `ui_test`-style directives `//@` instead:{:#?}",
950+
"error: detected legacy-style directives in compiletest test: {}:{}, please use `ui_test`-style directives `//@` instead:{:#?}",
955951
testfile.display(),
956952
line_number,
957953
line_directive("//", ln),
@@ -964,7 +960,7 @@ fn iter_header(
964960
// directive. We emit an error here to warn the user.
965961
*poisoned = true;
966962
eprintln!(
967-
"error: detected legacy-style directives in ui test: {}:{}, please use `ui_test`-style directives `//@` instead:{:#?}",
963+
"error: detected legacy-style directives in compiletest test: {}:{}, please use `ui_test`-style directives `//@` instead:{:#?}",
968964
testfile.display(),
969965
line_number,
970966
line_directive("//", ln),
@@ -1265,11 +1261,8 @@ pub fn make_test_description<R: Read>(
12651261

12661262
if let Some((_, post)) = original_line.trim_start().split_once("//") {
12671263
let post = post.trim_start();
1268-
if post.starts_with("ignore-tidy")
1269-
&& config.mode == Mode::Ui
1270-
&& config.suite == "ui"
1271-
{
1272-
// not handled by compiletest under the ui test mode and ui test suite.
1264+
if post.starts_with("ignore-tidy") {
1265+
// Not handled by compiletest.
12731266
} else {
12741267
decision!(cfg::handle_ignore(config, ln));
12751268
}

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

+2-7
Original file line numberDiff line numberDiff line change
@@ -578,12 +578,7 @@ fn ignore_mode() {
578578
assert_eq!(config.mode, Mode::from_str(mode).unwrap());
579579
assert_ne!(config.mode, Mode::from_str(other).unwrap());
580580

581-
if mode == "ui" {
582-
assert!(check_ignore(&config, &format!("//@ ignore-mode-{mode}")));
583-
assert!(!check_ignore(&config, &format!("//@ ignore-mode-{other}")));
584-
} else {
585-
assert!(check_ignore(&config, &format!("// ignore-mode-{mode}")));
586-
assert!(!check_ignore(&config, &format!("// ignore-mode-{other}")));
587-
}
581+
assert!(check_ignore(&config, &format!("//@ ignore-mode-{mode}")));
582+
assert!(!check_ignore(&config, &format!("//@ ignore-mode-{other}")));
588583
}
589584
}

src/tools/compiletest/src/runtest.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -3938,15 +3938,10 @@ impl<'test> TestCx<'test> {
39383938
self.props.compare_output_lines_by_subset,
39393939
);
39403940
} else if !expected_fixed.is_empty() {
3941-
if self.config.suite == "ui" {
3942-
panic!(
3943-
"the `//@ run-rustfix` directive wasn't found but a `*.fixed` file was found"
3944-
);
3945-
} else {
3946-
panic!(
3947-
"the `// run-rustfix` directive wasn't found but a `*.fixed` file was found"
3948-
);
3949-
}
3941+
panic!(
3942+
"the `//@ run-rustfix` directive wasn't found but a `*.fixed` \
3943+
file was found"
3944+
);
39503945
}
39513946

39523947
if errors > 0 {

0 commit comments

Comments
 (0)