aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-04 14:16:25 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-04 14:16:25 -0600
commit81a9e84be89719e2a856b7600b6cf5780295d340 (patch)
treeed9c069c5ed97904e985cfe6d972592ad11b5151
parentf6117f5a1b8e5aa426b959c0fe5571de626070dc (diff)
downloadmakers-81a9e84be89719e2a856b7600b6cf5780295d340.tar.gz
makers-81a9e84be89719e2a856b7600b6cf5780295d340.zip
no thoughts. head empty
-rw-r--r--src/makefile/mod.rs38
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(())
+ }
+}