From ebd41864526b01b1bb42b2e4f9ab7f03c0d057a2 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Thu, 27 Oct 2016 00:31:50 -0700 Subject: [PATCH] Added missing arguments error whenever we try to run an recipe with arguments, since arguments are unsupported. --- notes | 1 + src/lib.rs | 9 +++++++++ src/tests.rs | 10 ++++++++++ 3 files changed, 20 insertions(+) diff --git a/notes b/notes index db4c522..758ab93 100644 --- a/notes +++ b/notes @@ -15,6 +15,7 @@ notes - allow exporting environment variables - write some tests to test the binary itself and all command line flags - remove unhandled token stuff +- test that run runs first recipe by default - parse arguments on command line: . ugly but conservative: j build --set a=hello . by export: A=HELLO j build diff --git a/src/lib.rs b/src/lib.rs index 06cb848..1d58c74 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -585,6 +585,11 @@ impl<'a> Justfile<'a> { } let recipes = names.iter().map(|name| self.recipes.get(name).unwrap()).collect::>(); let mut ran = HashSet::new(); + for recipe in &recipes { + if !recipe.arguments.is_empty() { + return Err(RunError::MissingArguments); + } + } for recipe in recipes { try!(self.run_recipe(recipe, &mut ran)); } @@ -620,6 +625,7 @@ impl<'a> Display for Justfile<'a> { #[derive(Debug)] enum RunError<'a> { UnknownRecipes{recipes: Vec<&'a str>}, + MissingArguments, Signal{recipe: &'a str, signal: i32}, Code{recipe: &'a str, code: i32}, UnknownFailure{recipe: &'a str}, @@ -637,6 +643,9 @@ impl<'a> Display for RunError<'a> { try!(write!(f, "Justfile does not contain recipes: {}", recipes.join(" "))); }; }, + RunError::MissingArguments => { + try!(write!(f, "Running recipes with arguments is not yet supported")); + }, RunError::Code{recipe, code} => { try!(write!(f, "Recipe \"{}\" failed with code {}", recipe, code)); }, diff --git a/src/tests.rs b/src/tests.rs index e271a77..e132c82 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -601,6 +601,16 @@ c: b } } +#[test] +fn run_arguments_not_supported() { + let text = "a foo:"; + match parse_success(text).run(&["a"]) { + Err(super::RunError::MissingArguments) => {} + result => panic!("Expecting MissingArguments from run() but got {:?}", result), + } +} + + /* #[test] fn run_shebang() {