mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-12 12:22:47 +00:00
Add the linesweeper 0.5.0 package to vendor/ with no file changed, so that a fix to it can reach the Craft apps through this repository without waiting for a linesweeper release. The GitHub repository its manifest names is archived, and its README says development moved off GitHub. Leave out the test font (fonts live in craft-fonts), the logo artwork, the snapshot images and the package's repository tooling. SOURCE.json lists each with its hash. Add a workspace exclude, a [patch.crates-io] entry, SOURCE.json with the archive hash and per-file hashes, NOTICE and ATTRIBUTION.md rows, and the package's tests in the backend test script. craft-prepress's flatten feature now builds against the copy, so Cargo.lock drops the package's registry source and checksum.
47 lines
1.3 KiB
Rust
47 lines
1.3 KiB
Rust
use kurbo::BezPath;
|
|
use libtest_mimic::{Arguments, Failed, Trial};
|
|
use linesweeper::binary_op;
|
|
use std::path::{Path, PathBuf};
|
|
|
|
fn main() {
|
|
let args = Arguments::from_args();
|
|
let tests = regression_tests();
|
|
|
|
libtest_mimic::run(&args, tests).exit();
|
|
}
|
|
|
|
fn regression_tests() -> Vec<Trial> {
|
|
let ws = std::env::var("CARGO_MANIFEST_DIR").unwrap();
|
|
let paths = glob::glob(&format!("{ws}/tests/regression/**/*.txt")).unwrap();
|
|
paths
|
|
.into_iter()
|
|
.map(|p| {
|
|
let p = p.unwrap();
|
|
let name = input_path_base(&p).display().to_string();
|
|
Trial::test(name, || generate_regression_test(p))
|
|
})
|
|
.collect()
|
|
}
|
|
|
|
fn input_path_base(input_path: &Path) -> &Path {
|
|
let ws = std::env::var("CARGO_MANIFEST_DIR").unwrap();
|
|
let base = format!("{ws}/tests/regression");
|
|
input_path.strip_prefix(base).unwrap()
|
|
}
|
|
|
|
fn generate_regression_test(path: PathBuf) -> Result<(), Failed> {
|
|
let input = std::fs::read_to_string(&path).unwrap();
|
|
let lines: Vec<_> = input.lines().collect();
|
|
assert_eq!(lines.len(), 2);
|
|
let p0 = BezPath::from_svg(lines[0]).unwrap();
|
|
let p1 = BezPath::from_svg(lines[1]).unwrap();
|
|
binary_op(
|
|
&p0,
|
|
&p1,
|
|
linesweeper::FillRule::EvenOdd,
|
|
linesweeper::BinaryOp::Xor,
|
|
)
|
|
.unwrap();
|
|
Ok(())
|
|
}
|