mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-14 06:22:24 +00:00
craft-plate-test writes JSON scenes through craft-pdf and checks the written PDF's structure (CI, under a second) and, locally only, its separated plates through Ghostscript tiffsep (scripts/plate-check.sh). Apps can run the same scenes through their own export as a dev-dependency.
38 lines
1.6 KiB
Rust
38 lines
1.6 KiB
Rust
//! Local plate check: separates every scene with Ghostscript and judges its sample points.
|
|
//! Run it with `scripts/plate-check.sh`; it never runs in CI.
|
|
|
|
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
|
|
|
|
use craft_plate_test::reference::{self, Context};
|
|
use craft_plate_test::report::{self, Status};
|
|
use craft_plate_test::{gs, scene};
|
|
|
|
#[test]
|
|
#[ignore = "needs Ghostscript; run scripts/plate-check.sh"]
|
|
fn every_scene_separates_as_expected() {
|
|
let Some(version) = gs::version() else {
|
|
println!("note: Ghostscript ({:?}) not found; set {} or install gs", gs::program(), gs::GS_ENV);
|
|
return;
|
|
};
|
|
let scenes = scene::load_dir(&scene::scenes_dir()).unwrap();
|
|
let ctx = Context::from_env(&scenes);
|
|
if ctx.font.is_none() {
|
|
println!("note: {} not set; text points are skipped", reference::FONT_DIR_ENV);
|
|
}
|
|
let report = report::run(&ctx, version);
|
|
let path = report::write(&report, &report::output_dir()).unwrap();
|
|
for result in &report.scenes {
|
|
let pending = result.pending.as_deref().map(|t| format!(" (pending {t})")).unwrap_or_default();
|
|
println!("{} {:?}{pending}", result.id, result.status);
|
|
}
|
|
println!("report: {}", path.display());
|
|
let wrong: Vec<String> = report
|
|
.scenes
|
|
.iter()
|
|
.filter(|r| !r.status.as_expected())
|
|
.map(|r| format!("{} {:?}{}", r.id, r.status, r.error.as_deref().map(|e| format!(": {e}")).unwrap_or_default()))
|
|
.collect();
|
|
assert!(wrong.is_empty(), "see {}:\n{}", path.display(), wrong.join("\n"));
|
|
assert!(report.scenes.iter().any(|r| r.status == Status::Pass));
|
|
}
|