report prop test coverage labels on success.

This commit is contained in:
KtorZ 2024-03-09 01:21:13 +01:00
parent 96da70149d
commit bbe7c0bc01
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
2 changed files with 32 additions and 2 deletions

View File

@ -7,7 +7,7 @@
- **aiken-lang**: Data now has a generic argument that can be used to specify the blueprint type. @KtorZ - **aiken-lang**: Data now has a generic argument that can be used to specify the blueprint type. @KtorZ
- **aiken-lang**: New types `PRNG` and `Fuzzer` in the prelude. @KtorZ - **aiken-lang**: New types `PRNG` and `Fuzzer` in the prelude. @KtorZ
- **aiken-lang**: Test definitions now accept an (optional) argument alongside a new keyword `via` to specify fuzzers. @KtorZ - **aiken-lang**: Test definitions now accept an (optional) argument alongside a new keyword `via` to specify fuzzers. @KtorZ
- **aiken-project**: Property-based testing framework with integrated shrinking. @KtorZ - **aiken-project**: Property-based testing framework with integrated shrinking and case labelling. @KtorZ
- **aiken-project**: Unit tests now show assertion operands as Aiken expression instead of raw UPLC . @KtorZ - **aiken-project**: Unit tests now show assertion operands as Aiken expression instead of raw UPLC . @KtorZ
- **aiken**: The `check` command now accept an extra arg `--seed` to provide an initial seed for the pseudo-random generator of properties. @KtorZ - **aiken**: The `check` command now accept an extra arg `--seed` to provide an initial seed for the pseudo-random generator of properties. @KtorZ
- **uplc**: add `integerToByteString` and `byteStringToInteger` builtins. @rvcas @Microproofs - **uplc**: add `integerToByteString` and `byteStringToInteger` builtins. @rvcas @Microproofs

View File

@ -379,8 +379,38 @@ fn fmt_test(
); );
} }
// Labels
if let TestResult::PropertyTestResult(PropertyTestResult { labels, .. }) = result {
if !labels.is_empty() {
test = format!(
"{test}\n{title}",
title = "· with coverage".if_supports_color(Stderr, |s| s.bold())
);
let mut total = 0;
let mut pad = 0;
for (k, v) in labels {
total += v;
if k.len() > pad {
pad = k.len();
}
}
let mut labels = labels.iter().collect::<Vec<_>>();
labels.sort_by(|a, b| b.1.cmp(a.1));
for (k, v) in labels {
test = format!(
"{test}\n| {} {:>5.1}%",
pretty::pad_right(k.to_owned(), pad, " ")
.if_supports_color(Stderr, |s| s.bold()),
100.0 * (*v as f64) / (total as f64),
);
}
}
}
// Traces // Traces
if !result.logs().is_empty() { if !result.logs().is_empty() && result.is_success() {
test = format!( test = format!(
"{test}\n{title}\n{logs}\n", "{test}\n{title}\n{logs}\n",
title = "· with traces".if_supports_color(Stderr, |s| s.bold()), title = "· with traces".if_supports_color(Stderr, |s| s.bold()),