diff options
author | Evan Benn <evanbenn@chromium.org> | 2022-11-07 16:48:14 +1100 |
---|---|---|
committer | Edward O'Callaghan <quasisec@chromium.org> | 2022-11-17 04:28:20 +0000 |
commit | 4df64d93a063ddbfbf9d05f7059fe8386385132a (patch) | |
tree | 5cd0add9eef87af488bdff5079acfd5ee0466560 /util/flashrom_tester/src/tester.rs | |
parent | 065366dd278d5a2e220c9aa2667296580d414cab (diff) | |
download | flashrom-4df64d93a063ddbfbf9d05f7059fe8386385132a.tar.gz flashrom-4df64d93a063ddbfbf9d05f7059fe8386385132a.tar.bz2 flashrom-4df64d93a063ddbfbf9d05f7059fe8386385132a.zip |
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>
Diffstat (limited to 'util/flashrom_tester/src/tester.rs')
-rw-r--r-- | util/flashrom_tester/src/tester.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/util/flashrom_tester/src/tester.rs b/util/flashrom_tester/src/tester.rs index 6ce3889e..323b5365 100644 --- a/util/flashrom_tester/src/tester.rs +++ b/util/flashrom_tester/src/tester.rs @@ -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) ); } } |