mirror of
https://github.com/typst/typst
synced 2025-05-15 09:35:28 +08:00
Use a rotating test progress printer (#2872)
This commit is contained in:
parent
9aadb18186
commit
d1835b418f
@ -4,7 +4,7 @@ use std::cell::{RefCell, RefMut};
|
|||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::fmt::{self, Display, Formatter, Write as _};
|
use std::fmt::{self, Display, Formatter, Write as _};
|
||||||
use std::io::{self, Write};
|
use std::io::{self, IsTerminal, Write};
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::{env, fs};
|
use std::{env, fs};
|
||||||
@ -135,8 +135,10 @@ fn main() {
|
|||||||
|
|
||||||
let len = results.len();
|
let len = results.len();
|
||||||
let ok = results.iter().sum::<usize>();
|
let ok = results.iter().sum::<usize>();
|
||||||
if len > 1 {
|
if len > 0 {
|
||||||
println!("{ok} / {len} tests passed.");
|
println!("{ok} / {len} test{} passed.", if len > 1 { "s" } else { "" });
|
||||||
|
} else {
|
||||||
|
println!("No test ran.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ok != len {
|
if ok != len {
|
||||||
@ -475,6 +477,10 @@ fn test(
|
|||||||
stdout.write_all(name.to_string_lossy().as_bytes()).unwrap();
|
stdout.write_all(name.to_string_lossy().as_bytes()).unwrap();
|
||||||
if ok {
|
if ok {
|
||||||
writeln!(stdout, " ✔").unwrap();
|
writeln!(stdout, " ✔").unwrap();
|
||||||
|
if stdout.is_terminal() {
|
||||||
|
// ANSI escape codes: cursor moves up and clears the line.
|
||||||
|
write!(stdout, "\x1b[1A\x1b[2K").unwrap();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
writeln!(stdout, " ❌").unwrap();
|
writeln!(stdout, " ❌").unwrap();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user