Small improvements to the test runner (#4838)

This commit is contained in:
Laurenz 2024-08-26 13:40:37 +02:00 committed by GitHub
parent 88325d7d01
commit cf05284a0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 3 deletions

View File

@ -46,6 +46,9 @@ pub struct CliArguments {
/// Displays the syntax tree. /// Displays the syntax tree.
#[arg(long)] #[arg(long)]
pub syntax: bool, pub syntax: bool,
/// Displays only one line per test, hiding details about failures.
#[arg(short, long)]
pub compact: bool,
/// Prevents the terminal from being cleared of test names. /// Prevents the terminal from being cleared of test names.
#[arg(short, long)] #[arg(short, long)]
pub verbose: bool, pub verbose: bool,

View File

@ -70,8 +70,10 @@ impl<'a> Logger<'a> {
self.print(move |out| { self.print(move |out| {
if !result.errors.is_empty() { if !result.errors.is_empty() {
writeln!(out, "❌ {test}")?; writeln!(out, "❌ {test}")?;
for line in result.errors.lines() { if !crate::ARGS.compact {
writeln!(out, " {line}")?; for line in result.errors.lines() {
writeln!(out, " {line}")?;
}
} }
} else if crate::ARGS.verbose || !result.infos.is_empty() { } else if crate::ARGS.verbose || !result.infos.is_empty() {
writeln!(out, "✅ {test}")?; writeln!(out, "✅ {test}")?;

View File

@ -157,6 +157,10 @@ impl<'a> Runner<'a> {
}; };
let skippable = match document.pages.as_slice() { let skippable = match document.pages.as_slice() {
[] => {
log!(self, "document has zero pages");
return;
}
[page] => skippable(page), [page] => skippable(page),
_ => false, _ => false,
}; };
@ -231,7 +235,7 @@ impl<'a> Runner<'a> {
std::fs::write(&ref_path, &ref_data).unwrap(); std::fs::write(&ref_path, &ref_data).unwrap();
log!( log!(
into: self.result.infos, into: self.result.infos,
"Updated reference image ({ref_path}, {})", "updated reference image ({ref_path}, {})",
FileSize(ref_data.len()), FileSize(ref_data.len()),
); );
} }
@ -414,6 +418,7 @@ fn render_links(canvas: &mut sk::Pixmap, ts: sk::Transform, frame: &Frame) {
fn skippable(page: &Page) -> bool { fn skippable(page: &Page) -> bool {
page.frame.width().approx_eq(Abs::pt(120.0)) page.frame.width().approx_eq(Abs::pt(120.0))
&& page.frame.height().approx_eq(Abs::pt(20.0)) && page.frame.height().approx_eq(Abs::pt(20.0))
&& page.fill.is_auto()
&& skippable_frame(&page.frame) && skippable_frame(&page.frame)
} }