From cdbd8c2f2aa69c4b8fe6f004449440e87c4ab87e Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 23 Feb 2018 03:18:53 +0300 Subject: Support flag `-Z ui-testing` for tweaking diagnostic output for UI tests --- src/libsyntax/json.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/json.rs b/src/libsyntax/json.rs index 98d5fa8f797..57f07ff33f5 100644 --- a/src/libsyntax/json.rs +++ b/src/libsyntax/json.rs @@ -40,6 +40,7 @@ pub struct JsonEmitter { pretty: bool, /// Whether "approximate suggestions" are enabled in the config approximate_suggestions: bool, + ui_testing: bool, } impl JsonEmitter { @@ -53,6 +54,7 @@ impl JsonEmitter { cm: code_map, pretty, approximate_suggestions, + ui_testing: false, } } @@ -73,8 +75,13 @@ impl JsonEmitter { cm: code_map, pretty, approximate_suggestions, + ui_testing: false, } } + + pub fn ui_testing(self, ui_testing: bool) -> Self { + Self { ui_testing, ..self } + } } impl Emitter for JsonEmitter { @@ -199,7 +206,8 @@ impl Diagnostic { } let buf = BufWriter::default(); let output = buf.clone(); - EmitterWriter::new(Box::new(buf), Some(je.cm.clone()), false, false).emit(db); + EmitterWriter::new(Box::new(buf), Some(je.cm.clone()), false, false) + .ui_testing(je.ui_testing).emit(db); let output = Arc::try_unwrap(output.0).unwrap().into_inner().unwrap(); let output = String::from_utf8(output).unwrap(); -- cgit 1.4.1-3-g733a5