From d52dcb575edb9a188edcb5ad83f03d316c17650c Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sun, 15 Nov 2026 19:36:13 +0100 Subject: [PATCH 1/2] fix(xtask): reject unknown corpus arguments before fetching Validate corpus options before dispatch so a typo cannot silently succeed or start corpus downloads. Preserve existing aliases and modifier flags. --- xtask/src/corpus.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xtask/src/corpus.rs b/xtask/src/corpus.rs index 0be1f83625..ca622490ca 100644 --- a/xtask/src/corpus.rs +++ b/xtask/src/corpus.rs @@ -27,6 +27,13 @@ const HEIF_CRATES: &[&str] = &["photocraft-io"]; const CRITICAL: &[&str] = &["crates/io/", "crates/compose/", "crates/gpu/", "crates/text/", "crates/format/", "crates/raw/", "crates/engine/src/atn_cmds"]; /// `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> { + for arg in args { + match *arg { + "--all" | "--pngsuite" | "--download" | "--psd" | "--psd-tools" | "--heif" | "--pixls" | "--exr" | "--affinity" | "--atn" | "--photoshop" + | "--gimp" | "--local" | "--update-manifest" => {} + other => return Err(format!("corpus: unknown argument `{other}`")), + } + } let update = args.contains(&"--update-manifest"); let mut did = false; if args.contains(&"--all") { From 068b3d23d485162f3277eda6ecfdc7232882aa5d Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sun, 15 Nov 2026 19:37:14 +0100 Subject: [PATCH 2/2] test(xtask): cover corpus argument errors before fetching Check a misspelled corpus flag by itself and alongside --all in both orders. --- xtask/src/corpus/tests.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xtask/src/corpus/tests.rs b/xtask/src/corpus/tests.rs index b1c7b515a9..9f89d39ae2 100644 --- a/xtask/src/corpus/tests.rs +++ b/xtask/src/corpus/tests.rs @@ -1,5 +1,12 @@ use super::*; +#[test] +fn corpus_rejects_unknown_arguments_before_fetching() { + for args in [vec!["--psd-tool"], vec!["--all", "--psd-tool"], vec!["--psd-tool", "--all"]] { + assert_eq!(cmd(&args), Err("corpus: unknown argument `--psd-tool`".into())); + } +} + /// 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();