Skip to content

Commit 2d353c3

Browse files
authored
Rollup merge of #147429 - chenyukang:yukang-fix-test-tip, r=fmease
Print tip for human error format in runtest When working on #147354, spent some time to figure out that there is `//~ ERROR` left on test file, this PR will give a better error message for this scenario.
2 parents 0072d0c + f8ee9f0 commit 2d353c3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/tools/compiletest/src/runtest.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,21 @@ impl<'test> TestCx<'test> {
878878
prefix = self.error_prefix(),
879879
n = not_found.len(),
880880
);
881+
882+
// FIXME: Ideally, we should check this at the place where we actually parse error annotations.
883+
// it's better to use (negated) heuristic inside normalize_output if possible
884+
if let Some(human_format) = self.props.compile_flags.iter().find(|flag| {
885+
// `human`, `human-unicode`, `short` will not generate JSON output
886+
flag.contains("error-format")
887+
&& (flag.contains("short") || flag.contains("human"))
888+
}) {
889+
let msg = format!(
890+
"tests with compile flag `{}` should not have error annotations such as `//~ ERROR`",
891+
human_format
892+
).color(Color::Red);
893+
writeln!(self.stdout, "{}", msg);
894+
}
895+
881896
for error in &not_found {
882897
print_error(error);
883898
let mut suggestions = Vec::new();

0 commit comments

Comments
 (0)