Fail all folders on extension check

This commit is contained in:
Félix Saparelli 2022-01-26 01:12:57 +13:00
parent 6cebaf204f
commit 42d64d0a6d
No known key found for this signature in database
GPG Key ID: B948C4BAE44FC474
2 changed files with 21 additions and 2 deletions

View File

@ -128,8 +128,8 @@ impl Filterer for GlobsetFilterer {
if !self.extensions.is_empty() {
if is_dir {
trace!("omitted from extension check due to being a dir");
continue;
trace!("failed on extension check due to being a dir");
return Ok(false);
}
if let Some(ext) = path.extension() {

View File

@ -297,6 +297,25 @@ async fn ignores_take_precedence() {
filterer.file_does_pass("FINAL-FINAL.docx");
}
#[tokio::test]
async fn extensions_fail_dirs() {
let filterer = filt(&[], &[], &["py"]).await;
filterer.file_does_pass("Cargo.py");
filterer.file_doesnt_pass("Cargo.toml");
filterer.dir_doesnt_pass("Cargo");
filterer.dir_doesnt_pass("Cargo.toml");
filterer.dir_doesnt_pass("Cargo.py");
}
#[tokio::test]
async fn extensions_fail_extensionless() {
let filterer = filt(&[], &[], &["py"]).await;
filterer.file_does_pass("Cargo.py");
filterer.file_doesnt_pass("Cargo");
}
// The following tests replicate the "buggy"/"confusing" watchexec v1 behaviour.
#[tokio::test]