mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-27 16:59:43 +01:00
* Home: Learn after the presets, as one row of skill cards The presets stand right under New and Open again, as in 0.24.1, and Learn follows them before Community. Learn is a Column page section whose heading row ends in the Quick skill guide link (learn.skills), over a raised card per skill: its title over its tutorials as plain links (learn.show), a page link gap apart. The four cards stand in one row in a full-width column and two by two in a narrower one. The section is about half as tall as before (161 points at 1600x1000, was 333). * Chrome: menu titles, title bar cursor and tab close button as production's The menu bar's titles stand as production's egui buttons (MenuTitleLook::Button): 24 high, 4-point corners, 2 points beside the text, 6 apart, in place of square 26-high rows padded 6. The title bar and the panel headers keep the arrow, over the menu titles too (MoveBandCursor::Arrow), where the move band showed its open hand. A document tab's x is a 12-point glyph that brightens under the pointer with no fill (TabCloseLook::Glyph), in place of a fill as tall as the tab. Needs craft-libs fix/vc-look10-chrome (MenuTitleLook, MoveBandCursor, TabCloseLook); the pin moves when it lands on next. * craft-libs: next b0d422cf0, with the menu title, move band cursor and tab close looks VectorCraft sets
105 lines
4.0 KiB
Rust
105 lines
4.0 KiB
Rust
//! Verify that PDF reading and writing use one immutable shared crate and patched backends.
|
|
|
|
use std::path::Path;
|
|
use std::process::Command;
|
|
|
|
use serde_json::Value;
|
|
|
|
const REV: &str = "b0d422cf0c23baccdaca314b916458a89c0952e0";
|
|
const PACKAGES: &[(&str, &str, &str)] = &[
|
|
("craft-pdf", "0.1.0", REV),
|
|
("krilla", "0.8.2", REV),
|
|
("hayro-syntax", "0.7.2", REV),
|
|
("hayro-interpret", "0.7.0", REV),
|
|
("hayro-jbig2", "0.3.0", REV),
|
|
("hayro-cmap", "0.1.0", REV),
|
|
("hayro-postscript", "0.1.0", REV),
|
|
];
|
|
|
|
/// The resolved source of a craft-libs package at `rev`.
|
|
fn source(rev: &str) -> String {
|
|
format!("git+https://github.com/storytold/craft-libs?rev={rev}#{rev}")
|
|
}
|
|
|
|
pub fn run(root: &Path) -> Result<(), String> {
|
|
let output = Command::new(std::env::var_os("CARGO").unwrap_or_else(|| "cargo".into()))
|
|
.current_dir(root)
|
|
.args(["metadata", "--locked", "--format-version", "1"])
|
|
.output()
|
|
.map_err(|e| format!("cargo metadata: {e}"))?;
|
|
if !output.status.success() {
|
|
return Err(format!("cargo metadata: {}", String::from_utf8_lossy(&output.stderr)));
|
|
}
|
|
let metadata: Value = serde_json::from_slice(&output.stdout).map_err(|e| format!("cargo metadata: {e}"))?;
|
|
validate(&metadata)?;
|
|
println!("PDF: shared crate and patched backends match their pinned sources");
|
|
Ok(())
|
|
}
|
|
|
|
fn validate(metadata: &Value) -> Result<(), String> {
|
|
let packages = metadata.get("packages").and_then(Value::as_array).ok_or("cargo metadata has no packages")?;
|
|
for &(name, version, rev) in PACKAGES {
|
|
let source = source(rev);
|
|
let mut found = packages.iter().filter(|p| p.get("name").and_then(Value::as_str) == Some(name));
|
|
let package = found.next().ok_or_else(|| format!("{name}: missing resolved package"))?;
|
|
if found.next().is_some() {
|
|
return Err(format!("{name}: expected one resolved package"));
|
|
}
|
|
if package.get("version").and_then(Value::as_str) != Some(version) || package.get("source").and_then(Value::as_str) != Some(source.as_str()) {
|
|
return Err(format!("{name}: expected {version} from {source}; got {package}"));
|
|
}
|
|
}
|
|
Ok(())
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
use serde_json::json;
|
|
|
|
fn metadata() -> Value {
|
|
let packages: Vec<_> = PACKAGES.iter().map(|(name, version, rev)| json!({"name":name, "version":version, "source":source(rev)})).collect();
|
|
json!({"packages": packages})
|
|
}
|
|
|
|
#[test]
|
|
fn accepts_pinned_pdf_packages_without_changing_printer_transport() {
|
|
let mut m = metadata();
|
|
m["packages"]
|
|
.as_array_mut()
|
|
.unwrap()
|
|
.push(json!({"name":"craft-print", "version":"0.1.0", "source":"git+https://github.com/storytold/craft-libs?rev=d991bf6792f8ade99c51358bf3c1d902c8cd96b5#d991bf6792f8ade99c51358bf3c1d902c8cd96b5"}));
|
|
assert!(validate(&m).is_ok());
|
|
}
|
|
|
|
#[test]
|
|
fn rejects_missing_or_duplicate_pdf_packages() {
|
|
for index in 0..PACKAGES.len() {
|
|
let mut m = metadata();
|
|
m["packages"].as_array_mut().unwrap().remove(index);
|
|
assert!(validate(&m).is_err());
|
|
let mut m = metadata();
|
|
let duplicate = m["packages"][index].clone();
|
|
m["packages"].as_array_mut().unwrap().push(duplicate);
|
|
assert!(validate(&m).is_err());
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn rejects_registry_local_version_and_revision_drift() {
|
|
for index in 0..PACKAGES.len() {
|
|
for (field, value) in [
|
|
("source", Value::Null),
|
|
("source", json!("registry+https://github.com/rust-lang/crates.io-index")),
|
|
("source", json!("git+https://github.com/storytold/craft-libs?branch=main#other")),
|
|
("source", json!(source("92d392cff132eaf53e13afff77f38b5c11b73aa0"))),
|
|
("version", json!("0.99.0")),
|
|
] {
|
|
let mut m = metadata();
|
|
m["packages"][index][field] = value;
|
|
assert!(validate(&m).is_err());
|
|
}
|
|
}
|
|
}
|
|
}
|