Strip out non-diagnostic lines from rustfix input
This commit is contained in:
parent
a77a65c029
commit
2d17597f84
2 changed files with 20 additions and 7 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue