mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-05 15:50:41 +02:00
flashrom_tester: Only print color when stdout isatty
Add the atty crate as a dependency. Print log and report in color only when isatty is true. BUG=b:246250254 BRANCH=None TEST=ssh dut flashrom_tester # no color TEST=ssh -t dut flashrom_tester # color Change-Id: Ia3cc527fb98e53eda6773622340cf10764df2cba Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/69270 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
This commit is contained in:

committed by
Edward O'Callaghan

parent
065366dd27
commit
4df64d93a0
@ -573,6 +573,11 @@ pub fn collate_all_test_runs(
|
||||
) {
|
||||
match format {
|
||||
OutputFormat::Pretty => {
|
||||
let color = if atty::is(atty::Stream::Stdout) {
|
||||
types::COLOR
|
||||
} else {
|
||||
types::NOCOLOR
|
||||
};
|
||||
println!();
|
||||
println!(" =============================");
|
||||
println!(" ===== AVL qual RESULTS ====");
|
||||
@ -591,8 +596,8 @@ pub fn collate_all_test_runs(
|
||||
if *result != TestConclusion::Pass {
|
||||
println!(
|
||||
" {} {}",
|
||||
style!(format!(" <+> {} test:", name), types::BOLD),
|
||||
style_dbg!(result, types::RED)
|
||||
style!(format!(" <+> {} test:", name), color.bold, color),
|
||||
style_dbg!(result, color.red, color)
|
||||
);
|
||||
match error {
|
||||
None => {}
|
||||
@ -601,8 +606,8 @@ pub fn collate_all_test_runs(
|
||||
} else {
|
||||
println!(
|
||||
" {} {}",
|
||||
style!(format!(" <+> {} test:", name), types::BOLD),
|
||||
style_dbg!(result, types::GREEN)
|
||||
style!(format!(" <+> {} test:", name), color.bold, color),
|
||||
style_dbg!(result, color.green, color)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user