Added missing arguments error whenever we try to run an recipe with

arguments, since arguments are unsupported.
This commit is contained in:
Casey Rodarmor 2016-10-27 00:31:50 -07:00
parent d5f81dc0b4
commit ebd4186452
3 changed files with 20 additions and 0 deletions

1
notes
View File

@ -15,6 +15,7 @@ notes
- allow exporting environment variables - allow exporting environment variables
- write some tests to test the binary itself and all command line flags - write some tests to test the binary itself and all command line flags
- remove unhandled token stuff - remove unhandled token stuff
- test that run runs first recipe by default
- parse arguments on command line: - parse arguments on command line:
. ugly but conservative: j build --set a=hello . ugly but conservative: j build --set a=hello
. by export: A=HELLO j build . by export: A=HELLO j build

View File

@ -585,6 +585,11 @@ impl<'a> Justfile<'a> {
} }
let recipes = names.iter().map(|name| self.recipes.get(name).unwrap()).collect::<Vec<_>>(); let recipes = names.iter().map(|name| self.recipes.get(name).unwrap()).collect::<Vec<_>>();
let mut ran = HashSet::new(); let mut ran = HashSet::new();
for recipe in &recipes {
if !recipe.arguments.is_empty() {
return Err(RunError::MissingArguments);
}
}
for recipe in recipes { for recipe in recipes {
try!(self.run_recipe(recipe, &mut ran)); try!(self.run_recipe(recipe, &mut ran));
} }
@ -620,6 +625,7 @@ impl<'a> Display for Justfile<'a> {
#[derive(Debug)] #[derive(Debug)]
enum RunError<'a> { enum RunError<'a> {
UnknownRecipes{recipes: Vec<&'a str>}, UnknownRecipes{recipes: Vec<&'a str>},
MissingArguments,
Signal{recipe: &'a str, signal: i32}, Signal{recipe: &'a str, signal: i32},
Code{recipe: &'a str, code: i32}, Code{recipe: &'a str, code: i32},
UnknownFailure{recipe: &'a str}, UnknownFailure{recipe: &'a str},
@ -637,6 +643,9 @@ impl<'a> Display for RunError<'a> {
try!(write!(f, "Justfile does not contain recipes: {}", recipes.join(" "))); 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} => { RunError::Code{recipe, code} => {
try!(write!(f, "Recipe \"{}\" failed with code {}", recipe, code)); try!(write!(f, "Recipe \"{}\" failed with code {}", recipe, code));
}, },

View File

@ -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] #[test]
fn run_shebang() { fn run_shebang() {