Files
craft-libs/crates/plate-test/tests/ghostscript.rs
T
aiongg f7ae814d91 plate-test: app-neutral print color scenes, checked by PDF structure and Ghostscript plates
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.
2026-10-20 03:41:13 +00:00

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));
}