From a4d8db16f75f220f658e017afa1ad683e19a1423 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Mon, 5 Sep 2016 21:36:19 -0400 Subject: [PATCH] Fix glob tests. When matching directly with a regex, we need to make sure the path is normalized first. --- src/glob.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/glob.rs b/src/glob.rs index faec94e..bd7d247 100644 --- a/src/glob.rs +++ b/src/glob.rs @@ -414,6 +414,8 @@ impl<'a> Parser<'a> { #[cfg(test)] mod tests { + use std::path::Path; + use regex::bytes::Regex; use super::{Error, Pattern, MatchOptions, SetBuilder, Token}; @@ -461,8 +463,9 @@ mod tests { #[test] fn $name() { let pat = Pattern::new($pat).unwrap(); + let path = &Path::new($path).to_str().unwrap(); let re = Regex::new(&pat.to_regex_with(&$options)).unwrap(); - assert!(re.is_match($path.as_bytes())); + assert!(re.is_match(path.as_bytes())); } }; } @@ -475,8 +478,9 @@ mod tests { #[test] fn $name() { let pat = Pattern::new($pat).unwrap(); + let path = &Path::new($path).to_str().unwrap(); let re = Regex::new(&pat.to_regex_with(&$options)).unwrap(); - assert!(!re.is_match($path.as_bytes())); + assert!(!re.is_match(path.as_bytes())); } }; }