Update compiletest to only accept //@
directives
This commit is contained in:
parent
0840502351
commit
90a189c19b
@ -869,7 +869,7 @@ struct HeaderLine<'ln> {
|
|||||||
|
|
||||||
fn iter_header(
|
fn iter_header(
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
suite: &str,
|
_suite: &str,
|
||||||
poisoned: &mut bool,
|
poisoned: &mut bool,
|
||||||
testfile: &Path,
|
testfile: &Path,
|
||||||
rdr: impl Read,
|
rdr: impl Read,
|
||||||
@ -900,11 +900,7 @@ fn iter_header(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let comment = if testfile.extension().is_some_and(|e| e == "rs") {
|
let comment = if testfile.extension().is_some_and(|e| e == "rs") { "//@" } else { "#" };
|
||||||
if mode == Mode::Ui && suite == "ui" { "//@" } else { "//" }
|
|
||||||
} else {
|
|
||||||
"#"
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut rdr = BufReader::with_capacity(1024, rdr);
|
let mut rdr = BufReader::with_capacity(1024, rdr);
|
||||||
let mut ln = String::new();
|
let mut ln = String::new();
|
||||||
@ -931,7 +927,7 @@ fn iter_header(
|
|||||||
// First try to accept `ui_test` style comments
|
// First try to accept `ui_test` style comments
|
||||||
} else if let Some((header_revision, directive)) = line_directive(comment, ln) {
|
} else if let Some((header_revision, directive)) = line_directive(comment, ln) {
|
||||||
it(HeaderLine { line_number, original_line, header_revision, directive });
|
it(HeaderLine { line_number, original_line, header_revision, directive });
|
||||||
} else if mode == Mode::Ui && suite == "ui" && !REVISION_MAGIC_COMMENT_RE.is_match(ln) {
|
} else if !REVISION_MAGIC_COMMENT_RE.is_match(ln) {
|
||||||
let Some((_, rest)) = line_directive("//", ln) else {
|
let Some((_, rest)) = line_directive("//", ln) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
@ -951,7 +947,7 @@ fn iter_header(
|
|||||||
// directive. We emit an error here to warn the user.
|
// directive. We emit an error here to warn the user.
|
||||||
*poisoned = true;
|
*poisoned = true;
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"error: detected legacy-style directives in ui test: {}:{}, please use `ui_test`-style directives `//@` instead:{:#?}",
|
"error: detected legacy-style directives in compiletest test: {}:{}, please use `ui_test`-style directives `//@` instead:{:#?}",
|
||||||
testfile.display(),
|
testfile.display(),
|
||||||
line_number,
|
line_number,
|
||||||
line_directive("//", ln),
|
line_directive("//", ln),
|
||||||
@ -964,7 +960,7 @@ fn iter_header(
|
|||||||
// directive. We emit an error here to warn the user.
|
// directive. We emit an error here to warn the user.
|
||||||
*poisoned = true;
|
*poisoned = true;
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"error: detected legacy-style directives in ui test: {}:{}, please use `ui_test`-style directives `//@` instead:{:#?}",
|
"error: detected legacy-style directives in compiletest test: {}:{}, please use `ui_test`-style directives `//@` instead:{:#?}",
|
||||||
testfile.display(),
|
testfile.display(),
|
||||||
line_number,
|
line_number,
|
||||||
line_directive("//", ln),
|
line_directive("//", ln),
|
||||||
@ -1265,11 +1261,8 @@ macro_rules! decision {
|
|||||||
|
|
||||||
if let Some((_, post)) = original_line.trim_start().split_once("//") {
|
if let Some((_, post)) = original_line.trim_start().split_once("//") {
|
||||||
let post = post.trim_start();
|
let post = post.trim_start();
|
||||||
if post.starts_with("ignore-tidy")
|
if post.starts_with("ignore-tidy") {
|
||||||
&& config.mode == Mode::Ui
|
// Not handled by compiletest.
|
||||||
&& config.suite == "ui"
|
|
||||||
{
|
|
||||||
// not handled by compiletest under the ui test mode and ui test suite.
|
|
||||||
} else {
|
} else {
|
||||||
decision!(cfg::handle_ignore(config, ln));
|
decision!(cfg::handle_ignore(config, ln));
|
||||||
}
|
}
|
||||||
|
@ -578,12 +578,7 @@ fn ignore_mode() {
|
|||||||
assert_eq!(config.mode, Mode::from_str(mode).unwrap());
|
assert_eq!(config.mode, Mode::from_str(mode).unwrap());
|
||||||
assert_ne!(config.mode, Mode::from_str(other).unwrap());
|
assert_ne!(config.mode, Mode::from_str(other).unwrap());
|
||||||
|
|
||||||
if mode == "ui" {
|
assert!(check_ignore(&config, &format!("//@ ignore-mode-{mode}")));
|
||||||
assert!(check_ignore(&config, &format!("//@ ignore-mode-{mode}")));
|
assert!(!check_ignore(&config, &format!("//@ ignore-mode-{other}")));
|
||||||
assert!(!check_ignore(&config, &format!("//@ ignore-mode-{other}")));
|
|
||||||
} else {
|
|
||||||
assert!(check_ignore(&config, &format!("// ignore-mode-{mode}")));
|
|
||||||
assert!(!check_ignore(&config, &format!("// ignore-mode-{other}")));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3938,15 +3938,10 @@ fn run_ui_test(&self) {
|
|||||||
self.props.compare_output_lines_by_subset,
|
self.props.compare_output_lines_by_subset,
|
||||||
);
|
);
|
||||||
} else if !expected_fixed.is_empty() {
|
} else if !expected_fixed.is_empty() {
|
||||||
if self.config.suite == "ui" {
|
panic!(
|
||||||
panic!(
|
"the `//@ run-rustfix` directive wasn't found but a `*.fixed` \
|
||||||
"the `//@ run-rustfix` directive wasn't found but a `*.fixed` file was found"
|
file was found"
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
panic!(
|
|
||||||
"the `// run-rustfix` directive wasn't found but a `*.fixed` file was found"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if errors > 0 {
|
if errors > 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user