Skip to content

Commit

Permalink
Fix glob tests.
Browse files Browse the repository at this point in the history
When matching directly with a regex, we need to make sure the path is
normalized first.
  • Loading branch information
BurntSushi committed Sep 6, 2016
1 parent 3bb387a commit a4d8db1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/glob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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()));
}
};
}
Expand All @@ -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()));
}
};
}
Expand Down

0 comments on commit a4d8db1

Please sign in to comment.