diff --git a/moz-webgpu-cts/src/main.rs b/moz-webgpu-cts/src/main.rs index e34a25a..64f8685 100644 --- a/moz-webgpu-cts/src/main.rs +++ b/moz-webgpu-cts/src/main.rs @@ -23,7 +23,7 @@ use std::{ fmt::{self, Debug, Display, Formatter}, fs, hash::Hash, - io::{self, BufReader, BufWriter}, + io::{self, BufRead, BufReader, BufWriter}, iter, path::{Path, PathBuf}, process::ExitCode, @@ -398,18 +398,30 @@ fn run(cli: Cli) -> ExitCode { .map(BufReader::new) .map_err(Report::msg) .wrap_err("failed to open file") - .and_then(|reader| { - serde_json::from_reader::<_, ExecutionReport>(reader) - .map(Some) - .or_else(|e| { - if e.is_eof() && matches!((e.line(), e.column()), (1, 0)) { - Ok(None) - } else { - Err(e) - } - }) + .and_then(|mut reader| { + // Servo has multiple reports in same json file (each in one line) + // First one is from first run, second one run that runs only unexpected results for filtering + // + // TODO(sagudev): merge reports instead of using only first one + let mut first_report = String::new(); + reader + .read_line(&mut first_report) .into_diagnostic() - .wrap_err("failed to parse JSON") + .and_then(|_| { + serde_json::from_str::(&first_report) + .map(Some) + .or_else(|e| { + if e.is_eof() + && matches!((e.line(), e.column()), (1, 0)) + { + Ok(None) + } else { + Err(e) + } + }) + .into_diagnostic() + .wrap_err("failed to parse JSON") + }) }) .wrap_err_with(|| { format!(