Lint tests too
This commit is contained in:
parent
a3c5bd7201
commit
5f7123ecbe
|
@ -248,7 +248,7 @@ mod tests {
|
|||
}
|
||||
|
||||
fn build_gitignore(pattern: &str) -> GitignoreFile {
|
||||
GitignoreFile::from_strings(vec![pattern], &base_dir()).unwrap()
|
||||
GitignoreFile::from_strings(&[pattern], &base_dir()).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -332,7 +332,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_empty_file_never_excludes() {
|
||||
let file = GitignoreFile::from_strings(vec![], &base_dir()).unwrap();
|
||||
let file = GitignoreFile::from_strings(&[], &base_dir()).unwrap();
|
||||
|
||||
assert!(!file.is_excluded(&base_dir().join("target")));
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_checks_all_patterns() {
|
||||
let patterns = vec!["target", "target2"];
|
||||
let file = GitignoreFile::from_strings(patterns, &base_dir()).unwrap();
|
||||
let file = GitignoreFile::from_strings(&patterns, &base_dir()).unwrap();
|
||||
|
||||
assert!(file.is_excluded(&base_dir().join("target").join("foo.txt")));
|
||||
assert!(file.is_excluded(&base_dir().join("target2").join("bar.txt")));
|
||||
|
@ -349,7 +349,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_handles_whitelisting() {
|
||||
let patterns = vec!["target", "!target/foo.txt"];
|
||||
let file = GitignoreFile::from_strings(patterns, &base_dir()).unwrap();
|
||||
let file = GitignoreFile::from_strings(&patterns, &base_dir()).unwrap();
|
||||
|
||||
assert!(!file.is_excluded(&base_dir().join("target").join("foo.txt")));
|
||||
assert!(file.is_excluded(&base_dir().join("target").join("blah.txt")));
|
||||
|
|
|
@ -241,7 +241,7 @@ mod tests {
|
|||
}
|
||||
|
||||
fn build_ignore(pattern: &str) -> IgnoreFile {
|
||||
IgnoreFile::from_strings(vec![pattern], &base_dir()).unwrap()
|
||||
IgnoreFile::from_strings(&[pattern], &base_dir()).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -325,7 +325,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_empty_file_never_excludes() {
|
||||
let file = IgnoreFile::from_strings(vec![], &base_dir()).unwrap();
|
||||
let file = IgnoreFile::from_strings(&[], &base_dir()).unwrap();
|
||||
|
||||
assert!(!file.is_excluded(&base_dir().join("target")));
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_checks_all_patterns() {
|
||||
let patterns = vec!["target", "target2"];
|
||||
let file = IgnoreFile::from_strings(patterns, &base_dir()).unwrap();
|
||||
let file = IgnoreFile::from_strings(&patterns, &base_dir()).unwrap();
|
||||
|
||||
assert!(file.is_excluded(&base_dir().join("target").join("foo.txt")));
|
||||
assert!(file.is_excluded(&base_dir().join("target2").join("bar.txt")));
|
||||
|
@ -342,7 +342,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_handles_whitelisting() {
|
||||
let patterns = vec!["target", "!target/foo.txt"];
|
||||
let file = IgnoreFile::from_strings(patterns, &base_dir()).unwrap();
|
||||
let file = IgnoreFile::from_strings(&patterns, &base_dir()).unwrap();
|
||||
|
||||
assert!(!file.is_excluded(&base_dir().join("target").join("foo.txt")));
|
||||
assert!(file.is_excluded(&base_dir().join("target").join("blah.txt")));
|
||||
|
|
|
@ -76,8 +76,8 @@ impl NotificationFilter {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::NotificationFilter;
|
||||
use gitignore;
|
||||
use ignore;
|
||||
use crate::gitignore;
|
||||
use crate::ignore;
|
||||
use std::path::Path;
|
||||
|
||||
#[test]
|
||||
|
@ -85,7 +85,7 @@ mod tests {
|
|||
let filter =
|
||||
NotificationFilter::new(&[], &[], gitignore::load(&[]), ignore::load(&[])).unwrap();
|
||||
|
||||
assert!(!filter.is_excluded(&Path::new("foo")));
|
||||
assert!(!filter.is_excluded(Path::new("foo")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -98,8 +98,8 @@ mod tests {
|
|||
)
|
||||
.unwrap();
|
||||
|
||||
assert!(filter.is_excluded(&Path::new("/path/to/test.json")));
|
||||
assert!(filter.is_excluded(&Path::new("test.json")));
|
||||
assert!(filter.is_excluded(Path::new("/path/to/test.json")));
|
||||
assert!(filter.is_excluded(Path::new("test.json")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -108,9 +108,9 @@ mod tests {
|
|||
let filter =
|
||||
NotificationFilter::new(filters, &[], gitignore::load(&[]), ignore::load(&[])).unwrap();
|
||||
|
||||
assert!(!filter.is_excluded(&Path::new("hello.rs")));
|
||||
assert!(!filter.is_excluded(&Path::new("Cargo.toml")));
|
||||
assert!(filter.is_excluded(&Path::new("README.md")));
|
||||
assert!(!filter.is_excluded(Path::new("hello.rs")));
|
||||
assert!(!filter.is_excluded(Path::new("Cargo.toml")));
|
||||
assert!(filter.is_excluded(Path::new("README.md")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -119,9 +119,9 @@ mod tests {
|
|||
let filter =
|
||||
NotificationFilter::new(&[], ignores, gitignore::load(&[]), ignore::load(&[])).unwrap();
|
||||
|
||||
assert!(filter.is_excluded(&Path::new("hello.rs")));
|
||||
assert!(filter.is_excluded(&Path::new("Cargo.toml")));
|
||||
assert!(!filter.is_excluded(&Path::new("README.md")));
|
||||
assert!(filter.is_excluded(Path::new("hello.rs")));
|
||||
assert!(filter.is_excluded(Path::new("Cargo.toml")));
|
||||
assert!(!filter.is_excluded(Path::new("README.md")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -131,8 +131,8 @@ mod tests {
|
|||
NotificationFilter::new(ignores, ignores, gitignore::load(&[]), ignore::load(&[]))
|
||||
.unwrap();
|
||||
|
||||
assert!(filter.is_excluded(&Path::new("hello.rs")));
|
||||
assert!(filter.is_excluded(&Path::new("Cargo.toml")));
|
||||
assert!(filter.is_excluded(&Path::new("README.md")));
|
||||
assert!(filter.is_excluded(Path::new("hello.rs")));
|
||||
assert!(filter.is_excluded(Path::new("Cargo.toml")));
|
||||
assert!(filter.is_excluded(Path::new("README.md")));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -462,8 +462,7 @@ fn get_longest_common_path(paths: &[PathBuf]) -> Option<String> {
|
|||
#[cfg(test)]
|
||||
#[cfg(target_family = "unix")]
|
||||
mod tests {
|
||||
use notify;
|
||||
use pathop::PathOp;
|
||||
use crate::pathop::PathOp;
|
||||
use std::collections::HashSet;
|
||||
use std::path::PathBuf;
|
||||
|
||||
|
@ -474,7 +473,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_start() {
|
||||
let _ = spawn(&vec!["echo".into(), "hi".into()], &[], true);
|
||||
let _ = spawn(&["echo".into(), "hi".into()], &[], true);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue