mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-21 20:28:28 +00:00
Merge PR #15846: fix(xtask): include current ATN command paths in the corpus gate
This commit is contained in:
+7
-2
@@ -24,7 +24,12 @@ const HEIF_CRATES: &[&str] = &["photocraft-io"];
|
||||
|
||||
/// Paths whose changes make `test-corpus --changed` run (the file-format and rendering crates,
|
||||
/// and the engine's `.atn` import and export).
|
||||
const CRITICAL: &[&str] = &["crates/io/", "crates/compose/", "crates/gpu/", "crates/text/", "crates/format/", "crates/raw/", "crates/engine/src/atn_cmds"];
|
||||
const CRITICAL: &[&str] = &["crates/io/", "crates/compose/", "crates/gpu/", "crates/text/", "crates/format/", "crates/raw/", "crates/engine/src/cmd/atn_cmds/"];
|
||||
|
||||
fn is_critical(path: &str) -> bool {
|
||||
path == "crates/engine/src/cmd/atn_cmds.rs" || CRITICAL.iter().any(|prefix| path.starts_with(prefix))
|
||||
}
|
||||
|
||||
/// `cargo xtask corpus [--all | --pngsuite | --download | --psd | --psd-tools | --heif | --exr | --pixls | --affinity | --atn | --photoshop [--local] | --gimp [--local]] [--update-manifest]`
|
||||
pub fn cmd(args: &[&str]) -> Result<(), String> {
|
||||
let update = args.contains(&"--update-manifest");
|
||||
@@ -417,7 +422,7 @@ pub fn test_cmd(args: &[&str]) -> Result<(), String> {
|
||||
let mut raw_changed = false;
|
||||
if ours.contains(&"--changed") {
|
||||
let changed = changed_files()?;
|
||||
let hits: Vec<&String> = changed.iter().filter(|f| CRITICAL.iter().any(|c| f.starts_with(c))).collect();
|
||||
let hits: Vec<&String> = changed.iter().filter(|f| is_critical(f)).collect();
|
||||
if hits.is_empty() {
|
||||
println!("test-corpus --changed: nothing under {} changed since origin/main; skipping", CRITICAL.join(", "));
|
||||
return Ok(());
|
||||
|
||||
@@ -1,5 +1,50 @@
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn changed_atn_root_triggers_corpus_tests() {
|
||||
assert!(is_critical("crates/engine/src/cmd/atn_cmds.rs"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn changed_atn_modules_trigger_corpus_tests() {
|
||||
for path in ["crates/engine/src/cmd/atn_cmds/steps_render.rs", "crates/engine/src/cmd/atn_cmds/tests.rs"] {
|
||||
assert!(is_critical(path), "{path}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn similarly_named_atn_siblings_do_not_trigger_corpus_tests() {
|
||||
for path in [
|
||||
"crates/engine/src/cmd/atn_cmds_extra.rs",
|
||||
"crates/engine/src/cmd/atn_cmds_old/tests.rs",
|
||||
"crates/engine/src/cmd/atn_cmds.rs.bak",
|
||||
"crates/engine/src/cmd/atn_cmds",
|
||||
] {
|
||||
assert!(!is_critical(path), "{path}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn existing_critical_sources_still_trigger_corpus_tests() {
|
||||
for path in [
|
||||
"crates/io/src/ora.rs",
|
||||
"crates/compose/src/lib.rs",
|
||||
"crates/gpu/src/lib.rs",
|
||||
"crates/text/src/lib.rs",
|
||||
"crates/format/src/lib.rs",
|
||||
"crates/raw/src/lib.rs",
|
||||
] {
|
||||
assert!(is_critical(path), "{path}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unrelated_sources_do_not_trigger_corpus_tests() {
|
||||
for path in ["crates/engine/src/jobs.rs", "crates/engine/src/cmd/layer_cmds.rs", "docs/actions.md", "apps/photocraft-web/src/main.rs"] {
|
||||
assert!(!is_critical(path), "{path}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The flags each pinned corpus is fetched with by `fetch_all(local, update)`.
|
||||
fn calls(local: bool, update: bool) -> Vec<(&'static str, bool)> {
|
||||
let mut seen = Vec::new();
|
||||
|
||||
Reference in New Issue
Block a user