Skip to content

Commit

Permalink
multiple reports in same json file
Browse files Browse the repository at this point in the history
Signed-off-by: sagudev <[email protected]>
  • Loading branch information
sagudev committed Jul 30, 2024
1 parent 10d521b commit 282408e
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions moz-webgpu-cts/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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::<ExecutionReport>(&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!(
Expand Down

0 comments on commit 282408e

Please sign in to comment.