From 81a9e84be89719e2a856b7600b6cf5780295d340 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Sun, 4 Apr 2021 14:16:25 -0600 Subject: no thoughts. head empty --- src/makefile/mod.rs | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'src/makefile') 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 { 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(()) + } +} -- cgit v1.2.3