Make test runner more sexy.

Using colors.
This commit is contained in:
KtorZ 2022-12-08 17:16:41 +01:00 committed by rvcas
parent db25ff3817
commit 5770ea2456
No known key found for this signature in database
GPG Key ID: C09B64E263F7D68C
4 changed files with 17 additions and 3 deletions

1
Cargo.lock generated
View File

@ -110,6 +110,7 @@ dependencies = [
"hex",
"ignore",
"miette",
"owo-colors",
"pallas",
"pallas-traverse",
"petgraph",

View File

@ -30,10 +30,10 @@ where
if let Err(err) = build_result {
err.report();
miette::bail!("failed: {} error(s), {warning_count} warning(s)", err.len(),);
miette::bail!("Failed: {} error(s), {warning_count} warning(s)", err.len(),);
};
println!("\nfinished with {warning_count} warning(s)\n");
println!("\nFinished with {warning_count} warning(s)\n");
Ok(())
}

View File

@ -23,3 +23,4 @@ walkdir = "2.3.2"
hex = "0.4.3"
pallas = "0.14.0"
pallas-traverse = "0.14.0"
owo-colors = "3.5.0"

View File

@ -18,6 +18,7 @@ use aiken_lang::{
IdGenerator,
};
use miette::NamedSource;
use owo_colors::OwoColorize;
use pallas::{
codec::minicbor,
ledger::{addresses::Address, primitives::babbage},
@ -490,11 +491,22 @@ impl Project {
cpu: i64::MAX,
};
if !tests.is_empty() {
println!(
"\n{}\n",
"Running tests...".bold().underline().purple().to_string()
);
}
let fmt_tests = |is_passing: bool, test: Script, remaining_budget: ExBudget| -> String {
let ExBudget { mem, cpu } = initial_budget - remaining_budget;
format!(
" [{}] [mem: {}, cpu: {}] {}::{}",
if is_passing { "PASS" } else { "FAIL" },
if is_passing {
"PASS".bold().green().to_string()
} else {
"FAIL".bold().red().to_string()
},
mem,
cpu,
test.module,