diff --git a/src/main.rs b/src/main.rs index 74abb8f..8338576 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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)); diff --git a/src/masterlog.rs b/src/masterlog.rs index 8052778..6db76d8 100644 --- a/src/masterlog.rs +++ b/src/masterlog.rs @@ -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 {