mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
No more duplicate debug prints due to incremental tests
This commit is contained in:
parent
e4e4c1876f
commit
e915cc4ef0
@ -41,10 +41,11 @@ same-file = { version = "1", optional = true }
|
|||||||
walkdir = { version = "2", optional = true }
|
walkdir = { version = "2", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
walkdir = "2"
|
filedescriptor = "0.8"
|
||||||
|
iai = { git = "https://github.com/reknih/iai" }
|
||||||
tiny-skia = "0.6"
|
tiny-skia = "0.6"
|
||||||
usvg = { version = "0.15", default-features = false }
|
usvg = { version = "0.15", default-features = false }
|
||||||
iai = { git = "https://github.com/reknih/iai" }
|
walkdir = "2"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "typst"
|
name = "typst"
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
use std::env;
|
use std::env;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::fs;
|
use std::fs::{self, File};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
use filedescriptor::{FileDescriptor, StdioDescriptor::*};
|
||||||
use image::{GenericImageView, Rgba};
|
use image::{GenericImageView, Rgba};
|
||||||
use tiny_skia as sk;
|
use tiny_skia as sk;
|
||||||
use ttf_parser::{GlyphId, OutlineBuilder};
|
use ttf_parser::{GlyphId, OutlineBuilder};
|
||||||
@ -298,7 +299,7 @@ fn test_incremental(
|
|||||||
|
|
||||||
ctx.layouts.turnaround();
|
ctx.layouts.turnaround();
|
||||||
|
|
||||||
let cached = layout(ctx, document);
|
let cached = silenced(|| layout(ctx, document));
|
||||||
let misses = ctx
|
let misses = ctx
|
||||||
.layouts
|
.layouts
|
||||||
.entries()
|
.entries()
|
||||||
@ -756,3 +757,18 @@ impl LengthExt for Length {
|
|||||||
self.to_pt() as f32
|
self.to_pt() as f32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Disable stdout and stderr during execution of `f`.
|
||||||
|
fn silenced<F, T>(f: F) -> T
|
||||||
|
where
|
||||||
|
F: FnOnce() -> T,
|
||||||
|
{
|
||||||
|
let path = if cfg!(windows) { "NUL" } else { "/dev/null" };
|
||||||
|
let null = File::create(path).unwrap();
|
||||||
|
let stderr = FileDescriptor::redirect_stdio(&null, Stderr).unwrap();
|
||||||
|
let stdout = FileDescriptor::redirect_stdio(&null, Stdout).unwrap();
|
||||||
|
let result = f();
|
||||||
|
FileDescriptor::redirect_stdio(&stderr, Stderr).unwrap();
|
||||||
|
FileDescriptor::redirect_stdio(&stdout, Stdout).unwrap();
|
||||||
|
result
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user