Skip to content

Add the known-bug test directive, use it, and do some cleanup #93953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ pub struct TestProps {
// empty before the test starts. Incremental mode tests will reuse the
// incremental directory between passes in the same test.
pub incremental: bool,
// If `true`, this test is a known bug.
//
// When set, some requirements are relaxed. Currently, this only means no
// error annotations are needed, but this may be updated in the future to
// include other relaxations.
pub known_bug: bool,
// How far should the test proceed while still passing.
pass_mode: Option<PassMode>,
// Ignore `--pass` overrides from the command line for this test.
Expand Down Expand Up @@ -176,6 +182,7 @@ impl TestProps {
forbid_output: vec![],
incremental_dir: None,
incremental: false,
known_bug: false,
pass_mode: None,
fail_mode: None,
ignore_pass: false,
Expand Down Expand Up @@ -362,6 +369,10 @@ impl TestProps {
if !self.incremental {
self.incremental = config.parse_incremental(ln);
}

if !self.known_bug {
self.known_bug = config.parse_known_bug(ln);
}
});
}

Expand Down Expand Up @@ -751,6 +762,10 @@ impl Config {
fn parse_incremental(&self, line: &str) -> bool {
self.parse_name_directive(line, "incremental")
}

fn parse_known_bug(&self, line: &str) -> bool {
self.parse_name_directive(line, "known-bug")
}
}

fn expand_variables(mut value: String, config: &Config) -> String {
Expand Down
9 changes: 8 additions & 1 deletion src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,14 @@ impl<'test> TestCx<'test> {
}

None => {
if self.is_unexpected_compiler_message(actual_error, expect_help, expect_note) {
// If the test is a known bug, don't require that the error is annotated
if !self.props.known_bug
&& self.is_unexpected_compiler_message(
actual_error,
expect_help,
expect_note,
)
{
self.error(&format!(
"{}:{}: unexpected {}: '{}'",
file_name,
Expand Down