Skip to content

Commit

Permalink
try CI
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenzV committed Aug 29, 2024
1 parent 39bb3c5 commit 6b59a27
Show file tree
Hide file tree
Showing 18 changed files with 486 additions and 20 deletions.
477 changes: 468 additions & 9 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ cosmic-text = {git = "https://github.com/LaurenzV/cosmic-text", rev = "d8cad28"}
quote = "1.0.37"
syn = { version = "2.0.76", features = ["full", "extra-traits"] }
proc-macro2 = "1.0.86"
oxipng = "9.1.2"
krilla-macros = {path = "krilla-macros"}

[package]
Expand Down Expand Up @@ -71,5 +72,6 @@ rustybuzz = { workspace = true }
sitro = { workspace = true }
cosmic-text = { workspace = true }
krilla-macros = { workspace = true }
oxipng = { workspace = true }


26 changes: 16 additions & 10 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::font::Font;
use crate::stream::Glyph;
use difference::{Changeset, Difference};
use image::{load_from_memory, Rgba, RgbaImage};
use resvg::render;
use rustybuzz::{Direction, UnicodeBuffer};
use sitro::{
render_ghostscript, render_mupdf, render_pdfbox, render_pdfium, render_pdfjs, render_poppler,
Expand All @@ -13,6 +12,7 @@ use std::cell::LazyCell;
use std::cmp::max;
use std::path::PathBuf;
use std::sync::Arc;
use oxipng::{InFile, OutFile};
use tiny_skia_path::{Path, PathBuilder, Rect};

mod manual;
Expand All @@ -23,27 +23,27 @@ const STORE: bool = true;

const SNAPSHOT_PATH: LazyCell<PathBuf> = LazyCell::new(|| {
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/snapshots");
std::fs::create_dir_all(&path).unwrap();
let _ = std::fs::create_dir_all(&path);
path
});

const REFS_PATH: LazyCell<PathBuf> = LazyCell::new(|| {
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/refs");
std::fs::create_dir_all(&path).unwrap();
let _ = std::fs::create_dir_all(&path);
path
});

const DIFFS_PATH: LazyCell<PathBuf> = LazyCell::new(|| {
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/diffs");
std::fs::remove_dir_all(&path);
std::fs::create_dir_all(&path).unwrap();
let _ = std::fs::remove_dir_all(&path);
let _ = std::fs::create_dir_all(&path).unwrap();
path
});

const STORE_PATH: LazyCell<PathBuf> = LazyCell::new(|| {
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/store");
std::fs::remove_dir_all(&path);
std::fs::create_dir_all(&path).unwrap();
let _ = std::fs::remove_dir_all(&path);
let _ = std::fs::create_dir_all(&path).unwrap();
path
});

Expand Down Expand Up @@ -76,14 +76,14 @@ pub fn rect_to_path(x1: f32, y1: f32, x2: f32, y2: f32) -> Path {

fn write_snapshot_to_store(name: &str, content: &[u8]) {
let mut path = STORE_PATH.clone().join("snapshots");
std::fs::create_dir_all(&path).unwrap();
let _ = std::fs::create_dir_all(&path);
path.push(format!("{}.pdf", name));
std::fs::write(&path, &content).unwrap();
}

pub fn write_manual_to_store(name: &str, data: &[u8]) {
let mut path = STORE_PATH.clone().join("manual");
std::fs::create_dir_all(&path).unwrap();
let path = STORE_PATH.clone().join("manual");
let _ = std::fs::create_dir_all(&path);

let pdf_path = path.join(format!("{}.pdf", name));
let txt_path = path.join(format!("{}.txt", name));
Expand Down Expand Up @@ -141,6 +141,12 @@ pub fn check_render(name: &str, renderer: &Renderer, document: RenderedDocument)

if !ref_path.exists() {
std::fs::write(&ref_path, page).unwrap();
oxipng::optimize(
&InFile::Path(ref_path.clone()),
&OutFile::from_path(ref_path),
&oxipng::Options::max_compression(),
)
.unwrap();
panic!("new reference image was created");
}

Expand Down
1 change: 0 additions & 1 deletion src/tests/visreg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use cosmic_text::{Attrs, Buffer, FontSystem, Metrics, Shaping};
use fontdb::{Database, Source};
use krilla_macros::visreg;
use skrifa::GlyphId;
use std::sync::Arc;
use tiny_skia_path::{NormalizedF32, PathBuilder, Rect, Transform};

#[visreg]
Expand Down
Binary file added tests/refs/cosmic_text_ghostscript.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/refs/cosmic_text_mupdf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/refs/cosmic_text_pdfbox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/refs/cosmic_text_pdfium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/refs/cosmic_text_pdfjs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/refs/cosmic_text_poppler.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/refs/cosmic_text_quartz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/refs/linear_gradient_ghostscript.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/refs/linear_gradient_mupdf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/refs/linear_gradient_pdfbox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/refs/linear_gradient_pdfium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/refs/linear_gradient_pdfjs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/refs/linear_gradient_poppler.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/refs/linear_gradient_quartz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6b59a27

Please sign in to comment.