From 69e9a625d66517aa285a025f993cc53b95ca12ad Mon Sep 17 00:00:00 2001 From: Young-Flash Date: Fri, 6 Sep 2024 10:51:19 +0800 Subject: [PATCH] internal: tweak color of showing test result (#265) --- crates/moon/src/cli/test.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/crates/moon/src/cli/test.rs b/crates/moon/src/cli/test.rs index 51dacf9e7..922dbb252 100644 --- a/crates/moon/src/cli/test.rs +++ b/crates/moon/src/cli/test.rs @@ -288,9 +288,21 @@ fn do_run_test( let failed = total - passed; println!( "Total tests: {}, passed: {}, failed: {}.", - total.to_string().blue(), - passed.to_string().green(), - failed.to_string().red() + if total > 0 { + total.to_string().blue().to_string() + } else { + total.to_string() + }, + if passed > 0 { + passed.to_string().green().to_string() + } else { + passed.to_string() + }, + if failed > 0 { + failed.to_string().red().to_string() + } else { + failed.to_string() + } ); if passed == total {