1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-02-09 14:14:56 +02:00

fix tests

This commit is contained in:
Andrew Gallant 2016-09-16 06:58:10 -04:00
parent 0e46171e3b
commit 8203a80ac7
3 changed files with 6 additions and 7 deletions

View File

@ -124,8 +124,10 @@ impl Gitignore {
/// Like matched, but takes a path that has already been stripped. /// Like matched, but takes a path that has already been stripped.
pub fn matched_stripped(&self, path: &Path, is_dir: bool) -> Match { pub fn matched_stripped(&self, path: &Path, is_dir: bool) -> Match {
thread_local! { thread_local! {
static MATCHES: RefCell<Vec<usize>> = RefCell::new(vec![]); static MATCHES: RefCell<Vec<usize>> = {
} RefCell::new(vec![])
};
};
MATCHES.with(|matches| { MATCHES.with(|matches| {
let mut matches = matches.borrow_mut(); let mut matches = matches.borrow_mut();
self.set.matches_into(path, &mut *matches); self.set.matches_into(path, &mut *matches);

View File

@ -759,9 +759,6 @@ mod tests {
let pat = Pattern::new($pat).unwrap(); let pat = Pattern::new($pat).unwrap();
let path = &Path::new($path).to_str().unwrap(); let path = &Path::new($path).to_str().unwrap();
let re = Regex::new(&pat.to_regex_with(&$options)).unwrap(); let re = Regex::new(&pat.to_regex_with(&$options)).unwrap();
// println!("PATTERN: {}", $pat);
// println!("REGEX: {:?}", re);
// println!("PATH: {}", path);
assert!(!re.is_match(path.as_bytes())); assert!(!re.is_match(path.as_bytes()));
} }
}; };

View File

@ -61,11 +61,11 @@ pub fn file_name<'a, P: AsRef<Path> + ?Sized>(
let mut last_slash = 0; let mut last_slash = 0;
for (i, &b) in path.iter().enumerate().rev() { for (i, &b) in path.iter().enumerate().rev() {
if b == b'/' { if b == b'/' {
last_slash = i; last_slash = i + 1;
break; break;
} }
} }
Some(OsStr::from_bytes(&path[last_slash + 1..])) Some(OsStr::from_bytes(&path[last_slash..]))
} }
/// The final component of the path, if it is a normal file. /// The final component of the path, if it is a normal file.