Skip to content

Commit 29f5c69

Browse files
committedFeb 27, 2018
Auto merge of #48449 - petrochenkov:uidiff, r=nikomatsakis
Anonymize some line numbers in UI test output New unstable flag `-Z ui-testing` is introduced. This flag changes diagnostic output of the compiler *in some way* making it more suitable for UI testing (this is intentionally vague). At the moment this flag anonymizes line numbers at line starts thus solving the largest issue with UI test diffs. If diffs continue to be too noisy, some other tweaks could be applied (e.g. anonymizing lines/columns in `--> $DIR/file.rs:line:column`), but this needs some time and experience (we shouldn't diverge too much from the actual output in general). If comment `// disable-ui-testing-normalization` is added to an UI test, then `-Z ui-testing` is not passed. Closes #46643
2 parents bedbad6 + 9f9183d commit 29f5c69

File tree

1,230 files changed

+6878
-6708
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,230 files changed

+6878
-6708
lines changed
 

‎src/librustc/session/config.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
13221322
epoch). Crates compiled with different epochs can be linked together."),
13231323
run_dsymutil: Option<bool> = (None, parse_opt_bool, [TRACKED],
13241324
"run `dsymutil` and delete intermediate object files"),
1325+
ui_testing: bool = (false, parse_bool, [UNTRACKED],
1326+
"format compiler diagnostics in a way that's better suitable for UI testing"),
13251327
}
13261328

13271329
pub fn default_lib_output() -> CrateType {

‎src/librustc/session/mod.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -909,21 +909,24 @@ pub fn build_session_with_codemap(sopts: config::Options,
909909

910910
let emitter: Box<Emitter> = match (sopts.error_format, emitter_dest) {
911911
(config::ErrorOutputType::HumanReadable(color_config), None) => {
912-
Box::new(EmitterWriter::stderr(color_config,
913-
Some(codemap.clone()),
914-
false,
915-
sopts.debugging_opts.teach))
912+
Box::new(EmitterWriter::stderr(color_config, Some(codemap.clone()),
913+
false, sopts.debugging_opts.teach)
914+
.ui_testing(sopts.debugging_opts.ui_testing))
916915
}
917916
(config::ErrorOutputType::HumanReadable(_), Some(dst)) => {
918-
Box::new(EmitterWriter::new(dst, Some(codemap.clone()), false, false))
917+
Box::new(EmitterWriter::new(dst, Some(codemap.clone()),
918+
false, false)
919+
.ui_testing(sopts.debugging_opts.ui_testing))
919920
}
920921
(config::ErrorOutputType::Json(pretty), None) => {
921922
Box::new(JsonEmitter::stderr(Some(registry), codemap.clone(),
922-
pretty, sopts.debugging_opts.approximate_suggestions))
923+
pretty, sopts.debugging_opts.approximate_suggestions)
924+
.ui_testing(sopts.debugging_opts.ui_testing))
923925
}
924926
(config::ErrorOutputType::Json(pretty), Some(dst)) => {
925927
Box::new(JsonEmitter::new(dst, Some(registry), codemap.clone(),
926-
pretty, sopts.debugging_opts.approximate_suggestions))
928+
pretty, sopts.debugging_opts.approximate_suggestions)
929+
.ui_testing(sopts.debugging_opts.ui_testing))
927930
}
928931
(config::ErrorOutputType::Short(color_config), None) => {
929932
Box::new(EmitterWriter::stderr(color_config, Some(codemap.clone()), true, false))

0 commit comments

Comments
 (0)