Skip to content

Commit 529a42a

Browse files
authored
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 #67709.
2 parents cf24b6b + 208c1bf commit 529a42a

File tree

8 files changed

+17
-27
lines changed

8 files changed

+17
-27
lines changed

src/librustc_session/config.rs

+6
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,12 @@ impl Options {
593593
}
594594
}
595595

596+
impl DebuggingOptions {
597+
pub fn ui_testing(&self) -> bool {
598+
self.ui_testing.unwrap_or(false)
599+
}
600+
}
601+
596602
// The type of entry function, so users can have their own entry functions
597603
#[derive(Copy, Clone, PartialEq, Hash, Debug)]
598604
pub enum EntryFnType {

src/librustc_session/options.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
904904
`mir` (the MIR), or `mir-cfg` (graphviz formatted MIR)"),
905905
run_dsymutil: Option<bool> = (None, parse_opt_bool, [TRACKED],
906906
"run `dsymutil` and delete intermediate object files"),
907-
ui_testing: bool = (false, parse_bool, [UNTRACKED],
907+
ui_testing: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
908908
"format compiler diagnostics in a way that's better suitable for UI testing"),
909909
embed_bitcode: bool = (false, parse_bool, [TRACKED],
910910
"embed LLVM bitcode in object files"),

src/librustc_session/session.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ fn default_emitter(
869869
short,
870870
external_macro_backtrace,
871871
);
872-
Box::new(emitter.ui_testing(sopts.debugging_opts.ui_testing))
872+
Box::new(emitter.ui_testing(sopts.debugging_opts.ui_testing()))
873873
} else {
874874
let emitter = match dst {
875875
None => EmitterWriter::stderr(
@@ -890,7 +890,7 @@ fn default_emitter(
890890
external_macro_backtrace,
891891
),
892892
};
893-
Box::new(emitter.ui_testing(sopts.debugging_opts.ui_testing))
893+
Box::new(emitter.ui_testing(sopts.debugging_opts.ui_testing()))
894894
}
895895
}
896896
(config::ErrorOutputType::Json { pretty, json_rendered }, None) => Box::new(
@@ -901,7 +901,7 @@ fn default_emitter(
901901
json_rendered,
902902
external_macro_backtrace,
903903
)
904-
.ui_testing(sopts.debugging_opts.ui_testing),
904+
.ui_testing(sopts.debugging_opts.ui_testing()),
905905
),
906906
(config::ErrorOutputType::Json { pretty, json_rendered }, Some(dst)) => Box::new(
907907
JsonEmitter::new(
@@ -912,7 +912,7 @@ fn default_emitter(
912912
json_rendered,
913913
external_macro_backtrace,
914914
)
915-
.ui_testing(sopts.debugging_opts.ui_testing),
915+
.ui_testing(sopts.debugging_opts.ui_testing()),
916916
),
917917
}
918918
}

src/librustdoc/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ impl Options {
273273
error_format,
274274
None,
275275
debugging_options.treat_err_as_bug,
276-
debugging_options.ui_testing,
276+
debugging_options.ui_testing(),
277277
);
278278

279279
// check for deprecated options

src/librustdoc/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ fn main_options(options: config::Options) -> i32 {
449449
options.error_format,
450450
None,
451451
options.debugging_options.treat_err_as_bug,
452-
options.debugging_options.ui_testing,
452+
options.debugging_options.ui_testing(),
453453
);
454454

455455
match (options.should_test, options.markdown_input()) {
@@ -466,7 +466,7 @@ fn main_options(options: config::Options) -> i32 {
466466
let diag_opts = (
467467
options.error_format,
468468
options.debugging_options.treat_err_as_bug,
469-
options.debugging_options.ui_testing,
469+
options.debugging_options.ui_testing(),
470470
options.edition,
471471
);
472472
let show_coverage = options.show_coverage;

src/test/ui/ui-testing-optout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// disable-ui-testing-normalization
1+
// compile-flags: -Z ui-testing=no
22

33
// Line number < 10
44
type A = B; //~ ERROR

src/tools/compiletest/src/header.rs

-12
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,6 @@ pub struct TestProps {
376376
pub fail_mode: Option<FailMode>,
377377
// rustdoc will test the output of the `--test` option
378378
pub check_test_line_numbers_match: bool,
379-
// Do not pass `-Z ui-testing` to UI tests
380-
pub disable_ui_testing_normalization: bool,
381379
// customized normalization rules
382380
pub normalize_stdout: Vec<(String, String)>,
383381
pub normalize_stderr: Vec<(String, String)>,
@@ -422,7 +420,6 @@ impl TestProps {
422420
fail_mode: None,
423421
ignore_pass: false,
424422
check_test_line_numbers_match: false,
425-
disable_ui_testing_normalization: false,
426423
normalize_stdout: vec![],
427424
normalize_stderr: vec![],
428425
failure_status: -1,
@@ -569,11 +566,6 @@ impl TestProps {
569566
self.ignore_pass = config.parse_ignore_pass(ln);
570567
}
571568

572-
if !self.disable_ui_testing_normalization {
573-
self.disable_ui_testing_normalization =
574-
config.parse_disable_ui_testing_normalization(ln);
575-
}
576-
577569
if let Some(rule) = config.parse_custom_normalization(ln, "normalize-stdout") {
578570
self.normalize_stdout.push(rule);
579571
}
@@ -826,10 +818,6 @@ impl Config {
826818
}
827819
}
828820

829-
fn parse_disable_ui_testing_normalization(&self, line: &str) -> bool {
830-
self.parse_name_directive(line, "disable-ui-testing-normalization")
831-
}
832-
833821
fn parse_check_test_line_numbers_match(&self, line: &str) -> bool {
834822
self.parse_name_directive(line, "check-test-line-numbers-match")
835823
}

src/tools/compiletest/src/runtest.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1863,17 +1863,13 @@ impl<'test> TestCx<'test> {
18631863
if self.props.error_patterns.is_empty() {
18641864
rustc.args(&["--error-format", "json"]);
18651865
}
1866-
if !self.props.disable_ui_testing_normalization {
1867-
rustc.arg("-Zui-testing");
1868-
}
1866+
rustc.arg("-Zui-testing");
18691867
}
18701868
Ui => {
18711869
if !self.props.compile_flags.iter().any(|s| s.starts_with("--error-format")) {
18721870
rustc.args(&["--error-format", "json"]);
18731871
}
1874-
if !self.props.disable_ui_testing_normalization {
1875-
rustc.arg("-Zui-testing");
1876-
}
1872+
rustc.arg("-Zui-testing");
18771873
}
18781874
MirOpt => {
18791875
rustc.args(&[

0 commit comments

Comments
 (0)