Skip to content

Commit

Permalink
feat(cli): Improve test listing
Browse files Browse the repository at this point in the history
This adds some padding to the identifiers when lisitng tests to ensure mostly
aligned test kinds.
  • Loading branch information
tingerrr committed Jul 31, 2024
1 parent 502b235 commit 82ccf06
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion crates/typst-test-cli/src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ use crate::world::SystemWorld;

pub const ANNOT_PADDING: usize = 8;

const MAX_TEST_PAD: usize = 50;

fn write_with<W: WriteColor + ?Sized>(
w: &mut W,
set: impl FnOnce(&mut ColorSpec) -> &mut ColorSpec,
Expand Down Expand Up @@ -448,9 +450,19 @@ impl Reporter {
write_bold(self, |w| writeln!(w, "Tests"))?;
}

let pad = Ord::min(
project
.matched()
.keys()
.map(|id| id.len())
.max()
.unwrap_or(usize::MAX),
MAX_TEST_PAD,
);

self.with_indent(2, |this| {
for (name, test) in project.matched() {
write!(this, "{name} ")?;
write!(this, "{name: <pad$} ")?;
match test.ref_kind() {
Some(ReferenceKind::Ephemeral) => {
write_bold_colored(this, "ephemeral", Color::Yellow)?
Expand Down

0 comments on commit 82ccf06

Please sign in to comment.