about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2020-10-19 11:43:38 -0400
committerAaron Hill <aa1ronham@gmail.com>2020-10-30 20:02:15 -0400
commit2d17597f849fce55aa730edaa8f1bf0e91d64147 (patch)
treed2503337fad87f1761ba1f654e953f1edfe48349 /src
parenta77a65c029fc2543ec753982ff8d6da2bdb1d866 (diff)
downloadrust-2d17597f849fce55aa730edaa8f1bf0e91d64147.tar.gz
rust-2d17597f849fce55aa730edaa8f1bf0e91d64147.zip
Strip out non-diagnostic lines from rustfix input
Diffstat (limited to 'src')
-rw-r--r--src/tools/compiletest/src/json.rs22
-rw-r--r--src/tools/compiletest/src/runtest.rs5
2 files changed, 20 insertions, 7 deletions
diff --git a/src/tools/compiletest/src/json.rs b/src/tools/compiletest/src/json.rs
index 1171a598d8b..8eeaf8b1bb5 100644
--- a/src/tools/compiletest/src/json.rs
+++ b/src/tools/compiletest/src/json.rs
@@ -79,6 +79,12 @@ struct DiagnosticCode {
     explanation: Option<String>,
 }
 
+pub fn rustfix_diagnostics_only(output: &str) -> String {
+    output.lines().filter(|line| {
+        line.starts_with('{') && serde_json::from_str::<Diagnostic>(line).is_ok()
+    }).collect()
+}
+
 pub fn extract_rendered(output: &str) -> String {
     output
         .lines()
@@ -126,11 +132,17 @@ fn parse_line(file_name: &str, line: &str, output: &str, proc_res: &ProcRes) ->
                 expected_errors
             }
             Err(error) => {
-                proc_res.fatal(Some(&format!(
-                    "failed to decode compiler output as json: \
-                     `{}`\nline: {}\noutput: {}",
-                    error, line, output
-                )));
+                // Ignore the future compat report message - this is handled
+                // by `extract_rendered`
+                if serde_json::from_str::<FutureIncompatReport>(line).is_ok() {
+                    vec![]
+                } else {
+                    proc_res.fatal(Some(&format!(
+                        "failed to decode compiler output as json: \
+                         `{}`\nline: {}\noutput: {}",
+                        error, line, output
+                    )));
+                }
             }
         }
     } else {
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index 666e5d402ef..0f2165edacb 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -2978,6 +2978,7 @@ impl<'test> TestCx<'test> {
         self.prune_duplicate_outputs(&modes_to_prune);
 
         let mut errors = self.load_compare_outputs(&proc_res, TestOutput::Compile, explicit);
+        let rustfix_input = json::rustfix_diagnostics_only(&proc_res.stderr);
 
         if self.config.compare_mode.is_some() {
             // don't test rustfix with nll right now
@@ -2988,7 +2989,7 @@ impl<'test> TestCx<'test> {
             // This will return an empty `Vec` in case the executed test file has a
             // `compile-flags: --error-format=xxxx` header with a value other than `json`.
             let suggestions = get_suggestions_from_json(
-                &proc_res.stderr,
+                &rustfix_input,
                 &HashSet::new(),
                 Filter::MachineApplicableOnly,
             )
@@ -3015,7 +3016,7 @@ impl<'test> TestCx<'test> {
             // Apply suggestions from rustc to the code itself
             let unfixed_code = self.load_expected_output_from_path(&self.testpaths.file).unwrap();
             let suggestions = get_suggestions_from_json(
-                &proc_res.stderr,
+                &rustfix_input,
                 &HashSet::new(),
                 if self.props.rustfix_only_machine_applicable {
                     Filter::MachineApplicableOnly