Skip to content

Commit 541e685

Browse files
committed
Test some actual ignore caches
1 parent 476299e commit 541e685

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/fs/feature/ignore.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,21 @@ mod test {
125125
}
126126

127127

128+
fn test_cache(dir: &'static str, pats: Vec<&str>) -> IgnoreCache {
129+
IgnoreCache { entries: RwLock::new(vec![ (dir.into(), IgnorePatterns::parse_from_iter(pats.into_iter()).0) ]) }
130+
}
128131

129132
#[test]
130133
fn an_empty_cache_ignores_nothing() {
131134
let ignores = IgnoreCache::default();
132135
assert_eq!(false, ignores.is_ignored(Path::new("/usr/bin/drinking")));
133136
assert_eq!(false, ignores.is_ignored(Path::new("target/debug/exa")));
134137
}
138+
139+
#[test]
140+
fn a_nonempty_cache_ignores_some_things() {
141+
let ignores = test_cache("/vagrant", vec![ "target" ]);
142+
assert_eq!(false, ignores.is_ignored(Path::new("/vagrant/src")));
143+
assert_eq!(true, ignores.is_ignored(Path::new("/vagrant/target")));
144+
}
135145
}

0 commit comments

Comments
 (0)