diff --git a/xtask/src/corpus.rs b/xtask/src/corpus.rs index 3d217c9f78..70297aea85 100644 --- a/xtask/src/corpus.rs +++ b/xtask/src/corpus.rs @@ -32,6 +32,13 @@ fn is_critical(path: &str) -> bool { /// `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") { diff --git a/xtask/src/corpus/tests.rs b/xtask/src/corpus/tests.rs index 921bdc24e9..9795272627 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())); + } +} + #[test] fn changed_atn_root_triggers_corpus_tests() { assert!(is_critical("crates/engine/src/cmd/atn_cmds.rs"));