more test runner niceness: color

This commit is contained in:
Dustin Carlino 2018-11-23 14:59:18 -08:00
parent fcf7ea161c
commit 9f0b2ea756
3 changed files with 8 additions and 3 deletions

View File

@ -8,3 +8,4 @@ dimensioned = { git = "https://github.com/paholg/dimensioned", rev = "0e1076ebfa
gag = "0.1.10" gag = "0.1.10"
geom = { path = "../geom" } geom = { path = "../geom" }
sim = { path = "../sim" } sim = { path = "../sim" }
yansi = "0.4.0"

View File

@ -2,6 +2,7 @@ extern crate dimensioned;
extern crate gag; extern crate gag;
extern crate geom; extern crate geom;
extern crate sim; extern crate sim;
extern crate yansi;
mod physics; mod physics;
mod runner; mod runner;

View File

@ -1,5 +1,8 @@
// https://github.com/rust-lang/rust/issues/50297 would hopefully obsolete this approach.
use gag::Redirect; use gag::Redirect;
use std; use std;
use yansi::Paint;
pub struct TestRunner { pub struct TestRunner {
results: Vec<TestResult>, results: Vec<TestResult>,
@ -56,11 +59,11 @@ impl TestRunner {
for result in self.results.into_iter() { for result in self.results.into_iter() {
if result.pass { if result.pass {
passed += 1; passed += 1;
println!("- {}: PASS", result.test_name); println!("- {}: {}", result.test_name, Paint::green("PASS"));
} else { } else {
failed += 1; failed += 1;
println!("- {}: FAIL", result.test_name); println!("- {}: {}", result.test_name, Paint::red("FAIL"));
println!(" {}", result.output_path); println!(" {}", Paint::cyan(result.output_path));
} }
} }