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.
23 lines
592 B
Swift
23 lines
592 B
Swift
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"))
|
|
}
|
|
}
|