diff options
-rw-r--r-- | src/makefile/inference_rules.rs | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/makefile/inference_rules.rs b/src/makefile/inference_rules.rs index d7db1e6..7f77bd7 100644 --- a/src/makefile/inference_rules.rs +++ b/src/makefile/inference_rules.rs @@ -36,7 +36,10 @@ impl InferenceRule { pub fn first_match<'s, 't: 's>(&'s self, target_name: &'t str) -> Result<Option<Captures<'t>>> { self.products .iter() - .map(|pattern| r#match(pattern, target_name)) + .map(|pattern| { + // TODO find a better way to make the self_subdir_match test pass + r#match(pattern.strip_prefix("./").unwrap_or(pattern), target_name) + }) .try_fold(None, |x, y| y.map(|y| x.or(y))) } @@ -196,4 +199,32 @@ mod test { assert!(rule.matches("licenseListPublisher-2.2.1.jar-valid")?); Ok(()) } + + #[cfg(feature = "full")] + #[test] + fn subdir_match() -> R { + let rule = InferenceRule { + source: ItemSource::Builtin, + products: vec!["a/%.o".to_owned()], + prerequisites: vec!["a/%.c".to_owned()], + commands: vec![], + macros: MacroSet::new(), + }; + assert!(rule.matches("a/foo.o")?); + Ok(()) + } + + #[cfg(feature = "full")] + #[test] + fn self_subdir_match() -> R { + let rule = InferenceRule { + source: ItemSource::Builtin, + products: vec!["./%.o".to_owned()], + prerequisites: vec!["./%.c".to_owned()], + commands: vec![], + macros: MacroSet::new(), + }; + assert!(rule.matches("foo.o")?); + Ok(()) + } } |