Skip to content

Commit 2c48622

Browse files
committed
Validate error patterns and error annotation in ui tests when present
Previously, when compilation succeeded, neither error patterns nor error annotation would be validated. Additionally, when compilation failed, only error patterns would be validated if both error patterns and error annotation were present. Now both error patterns and error annotation are validated when present, regardless of compilation status. Furthermore, for test that should run, the error patterns are matched against executable output, which is what some of tests already expect to happen, and when #65506 is merged even more ui tests will.
1 parent f6c2c4d commit 2c48622

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/tools/compiletest/src/runtest.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -3137,21 +3137,24 @@ impl<'test> TestCx<'test> {
31373137
self.fatal_proc_rec("test run succeeded!", &proc_res);
31383138
}
31393139
}
3140+
if !self.props.error_patterns.is_empty() {
3141+
// "// error-pattern" comments
3142+
self.check_error_patterns(&proc_res.stderr, &proc_res);
3143+
}
31403144
}
31413145

31423146
debug!("run_ui_test: explicit={:?} config.compare_mode={:?} expected_errors={:?} \
31433147
proc_res.status={:?} props.error_patterns={:?}",
31443148
explicit, self.config.compare_mode, expected_errors, proc_res.status,
31453149
self.props.error_patterns);
31463150
if !explicit && self.config.compare_mode.is_none() {
3147-
if !proc_res.status.success() {
3148-
if !self.props.error_patterns.is_empty() {
3149-
// "// error-pattern" comments
3150-
self.check_error_patterns(&proc_res.stderr, &proc_res);
3151-
} else {
3152-
// "//~ERROR comments"
3153-
self.check_expected_errors(expected_errors, &proc_res);
3154-
}
3151+
if !self.should_run() && !self.props.error_patterns.is_empty() {
3152+
// "// error-pattern" comments
3153+
self.check_error_patterns(&proc_res.stderr, &proc_res);
3154+
}
3155+
if !expected_errors.is_empty() {
3156+
// "//~ERROR comments"
3157+
self.check_expected_errors(expected_errors, &proc_res);
31553158
}
31563159
}
31573160

0 commit comments

Comments
 (0)