Exclude items by shell pattern as well as by name
Patterns such as `.*` or `@*` are matched against an item's own name with `fnmatch`, in the same places as excluded names: resolving a tree, extending a watch to a directory that appears later, and delivering events. Dependents that prune large trees can now skip whole families of directories without listing each name.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import Testing
|
||||
@testable import Inotify
|
||||
|
||||
@Suite("Exclusion")
|
||||
struct ExclusionTests {
|
||||
@Test func excludesANameThatMatchesAPattern() async throws {
|
||||
let inotify = try Inotify()
|
||||
await inotify.exclude(patterns: "*.tmp", "@*")
|
||||
|
||||
#expect(await inotify.isExcluded("scan.tmp"))
|
||||
#expect(await inotify.isExcluded("@eaDir"))
|
||||
#expect(await !inotify.isExcluded("scan.pdf"))
|
||||
}
|
||||
|
||||
@Test func excludesAnExactName() async throws {
|
||||
let inotify = try Inotify()
|
||||
await inotify.exclude(name: ".git")
|
||||
|
||||
#expect(await inotify.isExcluded(".git"))
|
||||
#expect(await !inotify.isExcluded(".gitignore"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user