@@ -2,7 +2,6 @@ use crate::font::Font;
2
2
use crate :: stream:: Glyph ;
3
3
use difference:: { Changeset , Difference } ;
4
4
use image:: { load_from_memory, Rgba , RgbaImage } ;
5
- use resvg:: render;
6
5
use rustybuzz:: { Direction , UnicodeBuffer } ;
7
6
use sitro:: {
8
7
render_ghostscript, render_mupdf, render_pdfbox, render_pdfium, render_pdfjs, render_poppler,
@@ -13,6 +12,7 @@ use std::cell::LazyCell;
13
12
use std:: cmp:: max;
14
13
use std:: path:: PathBuf ;
15
14
use std:: sync:: Arc ;
15
+ use oxipng:: { InFile , OutFile } ;
16
16
use tiny_skia_path:: { Path , PathBuilder , Rect } ;
17
17
18
18
mod manual;
@@ -23,27 +23,27 @@ const STORE: bool = true;
23
23
24
24
const SNAPSHOT_PATH : LazyCell < PathBuf > = LazyCell :: new ( || {
25
25
let path = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) . join ( "tests/snapshots" ) ;
26
- std:: fs:: create_dir_all ( & path) . unwrap ( ) ;
26
+ let _ = std:: fs:: create_dir_all ( & path) ;
27
27
path
28
28
} ) ;
29
29
30
30
const REFS_PATH : LazyCell < PathBuf > = LazyCell :: new ( || {
31
31
let path = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) . join ( "tests/refs" ) ;
32
- std:: fs:: create_dir_all ( & path) . unwrap ( ) ;
32
+ let _ = std:: fs:: create_dir_all ( & path) ;
33
33
path
34
34
} ) ;
35
35
36
36
const DIFFS_PATH : LazyCell < PathBuf > = LazyCell :: new ( || {
37
37
let path = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) . join ( "tests/diffs" ) ;
38
- std:: fs:: remove_dir_all ( & path) ;
39
- std:: fs:: create_dir_all ( & path) . unwrap ( ) ;
38
+ let _ = std:: fs:: remove_dir_all ( & path) ;
39
+ let _ = std:: fs:: create_dir_all ( & path) . unwrap ( ) ;
40
40
path
41
41
} ) ;
42
42
43
43
const STORE_PATH : LazyCell < PathBuf > = LazyCell :: new ( || {
44
44
let path = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) . join ( "tests/store" ) ;
45
- std:: fs:: remove_dir_all ( & path) ;
46
- std:: fs:: create_dir_all ( & path) . unwrap ( ) ;
45
+ let _ = std:: fs:: remove_dir_all ( & path) ;
46
+ let _ = std:: fs:: create_dir_all ( & path) . unwrap ( ) ;
47
47
path
48
48
} ) ;
49
49
@@ -76,14 +76,14 @@ pub fn rect_to_path(x1: f32, y1: f32, x2: f32, y2: f32) -> Path {
76
76
77
77
fn write_snapshot_to_store ( name : & str , content : & [ u8 ] ) {
78
78
let mut path = STORE_PATH . clone ( ) . join ( "snapshots" ) ;
79
- std:: fs:: create_dir_all ( & path) . unwrap ( ) ;
79
+ let _ = std:: fs:: create_dir_all ( & path) ;
80
80
path. push ( format ! ( "{}.pdf" , name) ) ;
81
81
std:: fs:: write ( & path, & content) . unwrap ( ) ;
82
82
}
83
83
84
84
pub fn write_manual_to_store ( name : & str , data : & [ u8 ] ) {
85
- let mut path = STORE_PATH . clone ( ) . join ( "manual" ) ;
86
- std:: fs:: create_dir_all ( & path) . unwrap ( ) ;
85
+ let path = STORE_PATH . clone ( ) . join ( "manual" ) ;
86
+ let _ = std:: fs:: create_dir_all ( & path) ;
87
87
88
88
let pdf_path = path. join ( format ! ( "{}.pdf" , name) ) ;
89
89
let txt_path = path. join ( format ! ( "{}.txt" , name) ) ;
@@ -141,6 +141,12 @@ pub fn check_render(name: &str, renderer: &Renderer, document: RenderedDocument)
141
141
142
142
if !ref_path. exists ( ) {
143
143
std:: fs:: write ( & ref_path, page) . unwrap ( ) ;
144
+ oxipng:: optimize (
145
+ & InFile :: Path ( ref_path. clone ( ) ) ,
146
+ & OutFile :: from_path ( ref_path) ,
147
+ & oxipng:: Options :: max_compression ( ) ,
148
+ )
149
+ . unwrap ( ) ;
144
150
panic ! ( "new reference image was created" ) ;
145
151
}
146
152
0 commit comments