From 208c1bff0aae2389c1eb497623da895605d4e2b1 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Mon, 30 Dec 2019 00:23:19 +0300 Subject: [PATCH] Support `-Z ui-testing=yes/no` --- src/librustc_session/config.rs | 6 ++++++ src/librustc_session/options.rs | 2 +- src/librustc_session/session.rs | 8 ++++---- src/librustdoc/config.rs | 2 +- src/librustdoc/lib.rs | 4 ++-- src/test/ui/ui-testing-optout.rs | 2 +- src/tools/compiletest/src/header.rs | 12 ------------ src/tools/compiletest/src/runtest.rs | 8 ++------ 8 files changed, 17 insertions(+), 27 deletions(-) diff --git a/src/librustc_session/config.rs b/src/librustc_session/config.rs index 4fce25cafad88..75bd6babe16ec 100644 --- a/src/librustc_session/config.rs +++ b/src/librustc_session/config.rs @@ -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 #[derive(Copy, Clone, PartialEq, Hash, Debug)] pub enum EntryFnType { diff --git a/src/librustc_session/options.rs b/src/librustc_session/options.rs index 38c17bbbde797..3683daf7a87de 100644 --- a/src/librustc_session/options.rs +++ b/src/librustc_session/options.rs @@ -904,7 +904,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, `mir` (the MIR), or `mir-cfg` (graphviz formatted MIR)"), run_dsymutil: Option = (None, parse_opt_bool, [TRACKED], "run `dsymutil` and delete intermediate object files"), - ui_testing: bool = (false, parse_bool, [UNTRACKED], + ui_testing: Option = (None, parse_opt_bool, [UNTRACKED], "format compiler diagnostics in a way that's better suitable for UI testing"), embed_bitcode: bool = (false, parse_bool, [TRACKED], "embed LLVM bitcode in object files"), diff --git a/src/librustc_session/session.rs b/src/librustc_session/session.rs index 34149c22d2eed..8e9de69539a86 100644 --- a/src/librustc_session/session.rs +++ b/src/librustc_session/session.rs @@ -869,7 +869,7 @@ fn default_emitter( short, external_macro_backtrace, ); - Box::new(emitter.ui_testing(sopts.debugging_opts.ui_testing)) + Box::new(emitter.ui_testing(sopts.debugging_opts.ui_testing())) } else { let emitter = match dst { None => EmitterWriter::stderr( @@ -890,7 +890,7 @@ fn default_emitter( 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( @@ -901,7 +901,7 @@ fn default_emitter( json_rendered, 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( JsonEmitter::new( @@ -912,7 +912,7 @@ fn default_emitter( json_rendered, external_macro_backtrace, ) - .ui_testing(sopts.debugging_opts.ui_testing), + .ui_testing(sopts.debugging_opts.ui_testing()), ), } } diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 7a3cf88f65e21..25a892062fcbb 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -273,7 +273,7 @@ impl Options { error_format, None, debugging_options.treat_err_as_bug, - debugging_options.ui_testing, + debugging_options.ui_testing(), ); // check for deprecated options diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 0b4abe0a22e3b..d5cb17674f7b2 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -449,7 +449,7 @@ fn main_options(options: config::Options) -> i32 { options.error_format, None, options.debugging_options.treat_err_as_bug, - options.debugging_options.ui_testing, + options.debugging_options.ui_testing(), ); match (options.should_test, options.markdown_input()) { @@ -466,7 +466,7 @@ fn main_options(options: config::Options) -> i32 { let diag_opts = ( options.error_format, options.debugging_options.treat_err_as_bug, - options.debugging_options.ui_testing, + options.debugging_options.ui_testing(), options.edition, ); let show_coverage = options.show_coverage; diff --git a/src/test/ui/ui-testing-optout.rs b/src/test/ui/ui-testing-optout.rs index 041c0b0a85af7..901263c5bf8d2 100644 --- a/src/test/ui/ui-testing-optout.rs +++ b/src/test/ui/ui-testing-optout.rs @@ -1,4 +1,4 @@ -// disable-ui-testing-normalization +// compile-flags: -Z ui-testing=no // Line number < 10 type A = B; //~ ERROR diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 093ee662ce446..691b8d3ccfd39 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -376,8 +376,6 @@ pub struct TestProps { pub fail_mode: Option, // rustdoc will test the output of the `--test` option 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 pub normalize_stdout: Vec<(String, String)>, pub normalize_stderr: Vec<(String, String)>, @@ -422,7 +420,6 @@ impl TestProps { fail_mode: None, ignore_pass: false, check_test_line_numbers_match: false, - disable_ui_testing_normalization: false, normalize_stdout: vec![], normalize_stderr: vec![], failure_status: -1, @@ -569,11 +566,6 @@ impl TestProps { 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") { 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 { self.parse_name_directive(line, "check-test-line-numbers-match") } diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 02225d0ea0192..226a12c6734b7 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1863,17 +1863,13 @@ impl<'test> TestCx<'test> { if self.props.error_patterns.is_empty() { rustc.args(&["--error-format", "json"]); } - if !self.props.disable_ui_testing_normalization { - rustc.arg("-Zui-testing"); - } + rustc.arg("-Zui-testing"); } Ui => { if !self.props.compile_flags.iter().any(|s| s.starts_with("--error-format")) { rustc.args(&["--error-format", "json"]); } - if !self.props.disable_ui_testing_normalization { - rustc.arg("-Zui-testing"); - } + rustc.arg("-Zui-testing"); } MirOpt => { rustc.args(&[