mirror of
https://github.com/typst/typst
synced 2025-05-14 17:15:28 +08:00
Small improvements to the test runner (#4838)
This commit is contained in:
parent
88325d7d01
commit
cf05284a0c
@ -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,
|
||||||
|
@ -70,9 +70,11 @@ 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}")?;
|
||||||
|
if !crate::ARGS.compact {
|
||||||
for line in result.errors.lines() {
|
for line in result.errors.lines() {
|
||||||
writeln!(out, " {line}")?;
|
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}")?;
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user