diff options
Diffstat (limited to 'src/makefile/mod.rs')
-rw-r--r-- | src/makefile/mod.rs | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/src/makefile/mod.rs b/src/makefile/mod.rs index cda5559..24996a8 100644 --- a/src/makefile/mod.rs +++ b/src/makefile/mod.rs @@ -182,7 +182,7 @@ impl<'a> Makefile<'a> { commands: rule.commands.clone(), stem: rule .first_match(name)? - .and_then(|x| x.get(0).map(|x| x.as_str().to_owned())), + .and_then(|x| x.get(1).map(|x| x.as_str().to_owned())), already_updated: Cell::new(false), }); break; @@ -306,10 +306,7 @@ impl<'a> Makefile<'a> { } else if macro_name.starts_with('*') { // The $* macro shall evaluate to the current target name with // its suffix deleted. (GNUism: the match stem) - vec![Path::new(target.stem.as_ref().unwrap_or(&target.name)) - .with_extension("") - .to_string_lossy() - .into()] + vec![target.stem.as_ref().unwrap_or(&target.name).to_owned()] } else { unreachable!() }; @@ -445,3 +442,34 @@ fn builtin_targets() -> Vec<Target> { already_updated: Cell::new(false), }] } + +#[cfg(test)] +mod test { + use super::*; + + type R = Result<()>; + + #[cfg(feature = "full")] + #[test] + fn stem() -> R { + let args = Args::empty(); + let rule = InferenceRule { + products: vec!["this-is-a-%-case".to_owned()], + prerequisites: vec![], + commands: vec![], + }; + let file = Makefile { + inference_rules: vec![rule], + builtin_inference_rules: vec![], + macros: MacroSet::new(), + targets: Default::default(), + first_non_special_target: None, + args: &args, + fucking_bullshit_recursion_stack: Default::default(), + }; + + let target = file.get_target("this-is-a-test-case")?; + assert_eq!(target.borrow().stem, Some("test".to_owned())); + Ok(()) + } +} |