refactor: split func for printing boards for retest

This commit is contained in:
Wataru Otsubo 2024-09-10 21:07:50 +09:00
parent b80c4902ca
commit 9e93a085fd
2 changed files with 21 additions and 10 deletions

View file

@ -2,7 +2,7 @@ use core::str;
use std::{
fmt::Display,
fs::File,
io::{BufRead, BufReader},
io::{self, BufRead, BufReader},
path::{self, PathBuf},
str::FromStr,
};
@ -369,14 +369,7 @@ fn main() -> Result<()> {
debug!("{:?}", result);
// Print boards to retest
for (pos, boardresult) in &result.board_results {
if let Some(reason) = boardresult.is_need_retest() {
println!(
"Board {} at {} need retest for {}",
boardresult.id.id, pos, reason
);
}
}
result.print_boards_to_retest(io::stdout())?;
let outfile = outfile.unwrap_or(get_output_filename(&result));

View file

@ -1,4 +1,9 @@
use std::{collections::BTreeMap, io::BufRead, path::PathBuf, str::FromStr};
use std::{
collections::BTreeMap,
io::{BufRead, Write},
path::PathBuf,
str::FromStr,
};
use anyhow::{anyhow, Context, Result};
use chrono::{DateTime, Utc};
@ -301,6 +306,19 @@ impl MasterLogResult {
filename,
})
}
pub fn print_boards_to_retest(&self, mut wtr: impl Write) -> Result<()> {
for (pos, boardresult) in &self.board_results {
if let Some(reason) = boardresult.is_need_retest() {
writeln!(
wtr,
"Board {} at {} need retest for {}",
boardresult.id.id, pos, reason
)?;
}
}
Ok(())
}
}
pub fn get_output_filename(result: &MasterLogResult) -> PathBuf {