Rollup merge of #67735 - petrochenkov:uibool, r=Mark-Simulacrum
Support `-Z ui-testing=yes/no` `ui-testing` is now a boolean option (`-Z ui-testing=yes/no`) and can be specified multiple times with later values overriding earlier values (`-Z ui-testing=yes -Z ui-testing=no` == `-Z ui-testing=no`), so it can be set in a hierarchical way, e.g. UI testing infra may enable it by default with specific tests being able to opt-out. This way we can remove the special opt-out support from `compiletest`. Inspired by https://github.com/rust-lang/rust/pull/67709.
This commit is contained in:
@@ -593,6 +593,12 @@ impl Options {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl DebuggingOptions {
|
||||||
|
pub fn ui_testing(&self) -> bool {
|
||||||
|
self.ui_testing.unwrap_or(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The type of entry function, so users can have their own entry functions
|
// The type of entry function, so users can have their own entry functions
|
||||||
#[derive(Copy, Clone, PartialEq, Hash, Debug)]
|
#[derive(Copy, Clone, PartialEq, Hash, Debug)]
|
||||||
pub enum EntryFnType {
|
pub enum EntryFnType {
|
||||||
|
|||||||
@@ -904,7 +904,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
|||||||
`mir` (the MIR), or `mir-cfg` (graphviz formatted MIR)"),
|
`mir` (the MIR), or `mir-cfg` (graphviz formatted MIR)"),
|
||||||
run_dsymutil: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
run_dsymutil: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
||||||
"run `dsymutil` and delete intermediate object files"),
|
"run `dsymutil` and delete intermediate object files"),
|
||||||
ui_testing: bool = (false, parse_bool, [UNTRACKED],
|
ui_testing: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
|
||||||
"format compiler diagnostics in a way that's better suitable for UI testing"),
|
"format compiler diagnostics in a way that's better suitable for UI testing"),
|
||||||
embed_bitcode: bool = (false, parse_bool, [TRACKED],
|
embed_bitcode: bool = (false, parse_bool, [TRACKED],
|
||||||
"embed LLVM bitcode in object files"),
|
"embed LLVM bitcode in object files"),
|
||||||
|
|||||||
@@ -869,7 +869,7 @@ fn default_emitter(
|
|||||||
short,
|
short,
|
||||||
external_macro_backtrace,
|
external_macro_backtrace,
|
||||||
);
|
);
|
||||||
Box::new(emitter.ui_testing(sopts.debugging_opts.ui_testing))
|
Box::new(emitter.ui_testing(sopts.debugging_opts.ui_testing()))
|
||||||
} else {
|
} else {
|
||||||
let emitter = match dst {
|
let emitter = match dst {
|
||||||
None => EmitterWriter::stderr(
|
None => EmitterWriter::stderr(
|
||||||
@@ -890,7 +890,7 @@ fn default_emitter(
|
|||||||
external_macro_backtrace,
|
external_macro_backtrace,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
Box::new(emitter.ui_testing(sopts.debugging_opts.ui_testing))
|
Box::new(emitter.ui_testing(sopts.debugging_opts.ui_testing()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(config::ErrorOutputType::Json { pretty, json_rendered }, None) => Box::new(
|
(config::ErrorOutputType::Json { pretty, json_rendered }, None) => Box::new(
|
||||||
@@ -901,7 +901,7 @@ fn default_emitter(
|
|||||||
json_rendered,
|
json_rendered,
|
||||||
external_macro_backtrace,
|
external_macro_backtrace,
|
||||||
)
|
)
|
||||||
.ui_testing(sopts.debugging_opts.ui_testing),
|
.ui_testing(sopts.debugging_opts.ui_testing()),
|
||||||
),
|
),
|
||||||
(config::ErrorOutputType::Json { pretty, json_rendered }, Some(dst)) => Box::new(
|
(config::ErrorOutputType::Json { pretty, json_rendered }, Some(dst)) => Box::new(
|
||||||
JsonEmitter::new(
|
JsonEmitter::new(
|
||||||
@@ -912,7 +912,7 @@ fn default_emitter(
|
|||||||
json_rendered,
|
json_rendered,
|
||||||
external_macro_backtrace,
|
external_macro_backtrace,
|
||||||
)
|
)
|
||||||
.ui_testing(sopts.debugging_opts.ui_testing),
|
.ui_testing(sopts.debugging_opts.ui_testing()),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ impl Options {
|
|||||||
error_format,
|
error_format,
|
||||||
None,
|
None,
|
||||||
debugging_options.treat_err_as_bug,
|
debugging_options.treat_err_as_bug,
|
||||||
debugging_options.ui_testing,
|
debugging_options.ui_testing(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// check for deprecated options
|
// check for deprecated options
|
||||||
|
|||||||
@@ -449,7 +449,7 @@ fn main_options(options: config::Options) -> i32 {
|
|||||||
options.error_format,
|
options.error_format,
|
||||||
None,
|
None,
|
||||||
options.debugging_options.treat_err_as_bug,
|
options.debugging_options.treat_err_as_bug,
|
||||||
options.debugging_options.ui_testing,
|
options.debugging_options.ui_testing(),
|
||||||
);
|
);
|
||||||
|
|
||||||
match (options.should_test, options.markdown_input()) {
|
match (options.should_test, options.markdown_input()) {
|
||||||
@@ -466,7 +466,7 @@ fn main_options(options: config::Options) -> i32 {
|
|||||||
let diag_opts = (
|
let diag_opts = (
|
||||||
options.error_format,
|
options.error_format,
|
||||||
options.debugging_options.treat_err_as_bug,
|
options.debugging_options.treat_err_as_bug,
|
||||||
options.debugging_options.ui_testing,
|
options.debugging_options.ui_testing(),
|
||||||
options.edition,
|
options.edition,
|
||||||
);
|
);
|
||||||
let show_coverage = options.show_coverage;
|
let show_coverage = options.show_coverage;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// disable-ui-testing-normalization
|
// compile-flags: -Z ui-testing=no
|
||||||
|
|
||||||
// Line number < 10
|
// Line number < 10
|
||||||
type A = B; //~ ERROR
|
type A = B; //~ ERROR
|
||||||
|
|||||||
@@ -376,8 +376,6 @@ pub struct TestProps {
|
|||||||
pub fail_mode: Option<FailMode>,
|
pub fail_mode: Option<FailMode>,
|
||||||
// rustdoc will test the output of the `--test` option
|
// rustdoc will test the output of the `--test` option
|
||||||
pub check_test_line_numbers_match: bool,
|
pub check_test_line_numbers_match: bool,
|
||||||
// Do not pass `-Z ui-testing` to UI tests
|
|
||||||
pub disable_ui_testing_normalization: bool,
|
|
||||||
// customized normalization rules
|
// customized normalization rules
|
||||||
pub normalize_stdout: Vec<(String, String)>,
|
pub normalize_stdout: Vec<(String, String)>,
|
||||||
pub normalize_stderr: Vec<(String, String)>,
|
pub normalize_stderr: Vec<(String, String)>,
|
||||||
@@ -422,7 +420,6 @@ impl TestProps {
|
|||||||
fail_mode: None,
|
fail_mode: None,
|
||||||
ignore_pass: false,
|
ignore_pass: false,
|
||||||
check_test_line_numbers_match: false,
|
check_test_line_numbers_match: false,
|
||||||
disable_ui_testing_normalization: false,
|
|
||||||
normalize_stdout: vec![],
|
normalize_stdout: vec![],
|
||||||
normalize_stderr: vec![],
|
normalize_stderr: vec![],
|
||||||
failure_status: -1,
|
failure_status: -1,
|
||||||
@@ -569,11 +566,6 @@ impl TestProps {
|
|||||||
self.ignore_pass = config.parse_ignore_pass(ln);
|
self.ignore_pass = config.parse_ignore_pass(ln);
|
||||||
}
|
}
|
||||||
|
|
||||||
if !self.disable_ui_testing_normalization {
|
|
||||||
self.disable_ui_testing_normalization =
|
|
||||||
config.parse_disable_ui_testing_normalization(ln);
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(rule) = config.parse_custom_normalization(ln, "normalize-stdout") {
|
if let Some(rule) = config.parse_custom_normalization(ln, "normalize-stdout") {
|
||||||
self.normalize_stdout.push(rule);
|
self.normalize_stdout.push(rule);
|
||||||
}
|
}
|
||||||
@@ -826,10 +818,6 @@ impl Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_disable_ui_testing_normalization(&self, line: &str) -> bool {
|
|
||||||
self.parse_name_directive(line, "disable-ui-testing-normalization")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn parse_check_test_line_numbers_match(&self, line: &str) -> bool {
|
fn parse_check_test_line_numbers_match(&self, line: &str) -> bool {
|
||||||
self.parse_name_directive(line, "check-test-line-numbers-match")
|
self.parse_name_directive(line, "check-test-line-numbers-match")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1863,18 +1863,14 @@ impl<'test> TestCx<'test> {
|
|||||||
if self.props.error_patterns.is_empty() {
|
if self.props.error_patterns.is_empty() {
|
||||||
rustc.args(&["--error-format", "json"]);
|
rustc.args(&["--error-format", "json"]);
|
||||||
}
|
}
|
||||||
if !self.props.disable_ui_testing_normalization {
|
|
||||||
rustc.arg("-Zui-testing");
|
rustc.arg("-Zui-testing");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Ui => {
|
Ui => {
|
||||||
if !self.props.compile_flags.iter().any(|s| s.starts_with("--error-format")) {
|
if !self.props.compile_flags.iter().any(|s| s.starts_with("--error-format")) {
|
||||||
rustc.args(&["--error-format", "json"]);
|
rustc.args(&["--error-format", "json"]);
|
||||||
}
|
}
|
||||||
if !self.props.disable_ui_testing_normalization {
|
|
||||||
rustc.arg("-Zui-testing");
|
rustc.arg("-Zui-testing");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
MirOpt => {
|
MirOpt => {
|
||||||
rustc.args(&[
|
rustc.args(&[
|
||||||
"-Zdump-mir=all",
|
"-Zdump-mir=all",
|
||||||
|
|||||||
Reference in New Issue
Block a user