mirror of
https://github.com/watchexec/watchexec.git
synced 2024-09-29 22:51:33 +02:00
globset: Always pass non-path events (#248)
This commit is contained in:
parent
366277c6c1
commit
a6c997f470
@ -110,7 +110,12 @@ impl Filterer for GlobsetFilterer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(event.paths().any(|(path, file_type)| {
|
let mut paths = event.paths().peekable();
|
||||||
|
if paths.peek().is_none() {
|
||||||
|
trace!("non-path event (pass)");
|
||||||
|
Ok(true)
|
||||||
|
} else {
|
||||||
|
Ok(paths.any(|(path, file_type)| {
|
||||||
let _span = trace_span!("path", ?path).entered();
|
let _span = trace_span!("path", ?path).entered();
|
||||||
let is_dir = file_type
|
let is_dir = file_type
|
||||||
.map(|t| matches!(t, FileType::Dir))
|
.map(|t| matches!(t, FileType::Dir))
|
||||||
@ -149,4 +154,5 @@ impl Filterer for GlobsetFilterer {
|
|||||||
true
|
true
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -347,6 +347,26 @@ async fn multipath_allow_on_any_one_pass() {
|
|||||||
assert!(filterer.check_event(&event).unwrap());
|
assert!(filterer.check_event(&event).unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn nonpath_event_passes() {
|
||||||
|
use watchexec::{
|
||||||
|
event::{Event, Tag, Source},
|
||||||
|
filter::Filterer,
|
||||||
|
};
|
||||||
|
|
||||||
|
let filterer = filt(&[], &[], &["py"]).await;
|
||||||
|
|
||||||
|
assert!(filterer.check_event(&Event {
|
||||||
|
tags: vec![Tag::Source(Source::Internal)],
|
||||||
|
metadata: Default::default(),
|
||||||
|
}).unwrap());
|
||||||
|
|
||||||
|
assert!(filterer.check_event(&Event {
|
||||||
|
tags: vec![Tag::Source(Source::Keyboard)],
|
||||||
|
metadata: Default::default(),
|
||||||
|
}).unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
// The following tests replicate the "buggy"/"confusing" watchexec v1 behaviour.
|
// The following tests replicate the "buggy"/"confusing" watchexec v1 behaviour.
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
Loading…
Reference in New Issue
Block a user