summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2016-09-16 06:58:10 -0400
committerAndrew Gallant <jamslam@gmail.com>2016-09-16 06:58:10 -0400
commit8203a80ac7f010e32f8302822787eb9b5de8c9be (patch)
tree19faf05deb003fd5d8298b79a142f6fbd0809fc3
parent0e46171e3b189b2bd89f45c3a492dea36361d8bc (diff)
fix tests
-rw-r--r--src/gitignore.rs6
-rw-r--r--src/glob.rs3
-rw-r--r--src/pathutil.rs4
3 files changed, 6 insertions, 7 deletions
diff --git a/src/gitignore.rs b/src/gitignore.rs
index cac42a94..7678db4b 100644
--- a/src/gitignore.rs
+++ b/src/gitignore.rs
@@ -124,8 +124,10 @@ impl Gitignore {
/// Like matched, but takes a path that has already been stripped.
pub fn matched_stripped(&self, path: &Path, is_dir: bool) -> Match {
thread_local! {
- static MATCHES: RefCell<Vec<usize>> = RefCell::new(vec![]);
- }
+ static MATCHES: RefCell<Vec<usize>> = {
+ RefCell::new(vec![])
+ };
+ };
MATCHES.with(|matches| {
let mut matches = matches.borrow_mut();
self.set.matches_into(path, &mut *matches);
diff --git a/src/glob.rs b/src/glob.rs
index c5b5d8d3..e7da9322 100644
--- a/src/glob.rs
+++ b/src/glob.rs
@@ -759,9 +759,6 @@ mod tests {
let pat = Pattern::new($pat).unwrap();
let path = &Path::new($path).to_str().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()));
}
};
diff --git a/src/pathutil.rs b/src/pathutil.rs
index e92416e5..3cc92f7b 100644
--- a/src/pathutil.rs
+++ b/src/pathutil.rs
@@ -61,11 +61,11 @@ pub fn file_name<'a, P: AsRef<Path> + ?Sized>(
let mut last_slash = 0;
for (i, &b) in path.iter().enumerate().rev() {
if b == b'/' {
- last_slash = i;
+ last_slash = i + 1;
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.