Skip to content

Commit

Permalink
Merge branch 'main' into configOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
arp242 committed Oct 19, 2023
2 parents 29cf359 + e545940 commit e6384f3
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 76 deletions.
32 changes: 16 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,22 @@ jobs:
su action -c 'go120 test -parallel 1 ./...'
# illumos
# testillumos:
# runs-on: macos-12
# name: test (illumos, 1.19)
# steps:
# - uses: actions/checkout@v3
# - name: test (illumos, 1.19)
# id: test
# uses: papertigers/illumos-vm@r38
# with:
# prepare: |
# pkg install go-119
# run: |
# useradd action
# export GOCACHE=/tmp/go-cache
# export GOPATH=/tmp/go-path
# su action -c '/opt/ooce/go-1.19/bin/go test -parallel 1 ./...'
testillumos:
runs-on: macos-12
name: test (illumos, 1.19)
steps:
- uses: actions/checkout@v3
- name: test (illumos, 1.19)
id: test
uses: papertigers/illumos-vm@r38
with:
prepare: |
pkg install go-119
run: |
useradd action
export GOCACHE=/tmp/go-cache
export GOPATH=/tmp/go-path
su action -c '/opt/ooce/go-1.19/bin/go test -parallel 1 ./...'
# Older Debian 6, for old Linux kernels.
testDebian6:
Expand Down
5 changes: 5 additions & 0 deletions backend_fen.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ import (
// Paths can be added as "C:\path\to\dir", but forward slashes
// ("C:/path/to/dir") will also work.
//
// When a watched directory is removed it will always send an event for the
// directory itself, but may not send events for all files in that directory.
// Sometimes it will send events for all times, sometimes it will send no
// events, and often only for some files.
//
// The default buffer size is 64K, which is the largest value that is guaranteed
// to work with SMB filesystems. If you have many events in quick succession
// this may not be enough, and you will have to use [WithBufferSize] to increase
Expand Down
5 changes: 5 additions & 0 deletions backend_inotify.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ import (
// Paths can be added as "C:\path\to\dir", but forward slashes
// ("C:/path/to/dir") will also work.
//
// When a watched directory is removed it will always send an event for the
// directory itself, but may not send events for all files in that directory.
// Sometimes it will send events for all times, sometimes it will send no
// events, and often only for some files.
//
// The default buffer size is 64K, which is the largest value that is guaranteed
// to work with SMB filesystems. If you have many events in quick succession
// this may not be enough, and you will have to use [WithBufferSize] to increase
Expand Down
5 changes: 5 additions & 0 deletions backend_kqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ import (
// Paths can be added as "C:\path\to\dir", but forward slashes
// ("C:/path/to/dir") will also work.
//
// When a watched directory is removed it will always send an event for the
// directory itself, but may not send events for all files in that directory.
// Sometimes it will send events for all times, sometimes it will send no
// events, and often only for some files.
//
// The default buffer size is 64K, which is the largest value that is guaranteed
// to work with SMB filesystems. If you have many events in quick succession
// this may not be enough, and you will have to use [WithBufferSize] to increase
Expand Down
5 changes: 5 additions & 0 deletions backend_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ import "errors"
// Paths can be added as "C:\path\to\dir", but forward slashes
// ("C:/path/to/dir") will also work.
//
// When a watched directory is removed it will always send an event for the
// directory itself, but may not send events for all files in that directory.
// Sometimes it will send events for all times, sometimes it will send no
// events, and often only for some files.
//
// The default buffer size is 64K, which is the largest value that is guaranteed
// to work with SMB filesystems. If you have many events in quick succession
// this may not be enough, and you will have to use [WithBufferSize] to increase
Expand Down
5 changes: 5 additions & 0 deletions backend_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ import (
// Paths can be added as "C:\path\to\dir", but forward slashes
// ("C:/path/to/dir") will also work.
//
// When a watched directory is removed it will always send an event for the
// directory itself, but may not send events for all files in that directory.
// Sometimes it will send events for all times, sometimes it will send no
// events, and often only for some files.
//
// The default buffer size is 64K, which is the largest value that is guaranteed
// to work with SMB filesystems. If you have many events in quick succession
// this may not be enough, and you will have to use [WithBufferSize] to increase
Expand Down
120 changes: 60 additions & 60 deletions fsnotify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,66 +699,6 @@ func TestWatchRemove(t *testing.T) {
CHMOD "/file"
`},

{"remove watched directory", func(t *testing.T, w *Watcher, tmp string) {
touch(t, tmp, "a")
touch(t, tmp, "b")
touch(t, tmp, "c")
touch(t, tmp, "d")
touch(t, tmp, "e")
touch(t, tmp, "f")
touch(t, tmp, "g")
mkdir(t, tmp, "h")
mkdir(t, tmp, "h", "a")
mkdir(t, tmp, "i")
mkdir(t, tmp, "i", "a")
mkdir(t, tmp, "j")
mkdir(t, tmp, "j", "a")
addWatch(t, w, tmp)
rmAll(t, tmp)
}, `
remove /
remove /a
remove /b
remove /c
remove /d
remove /e
remove /f
remove /g
remove /h
remove /i
remove /j
# TODO: this is broken; I've also seen (/i and /j missing):
# REMOVE "/"
# REMOVE "/a"
# REMOVE "/b"
# REMOVE "/c"
# REMOVE "/d"
# REMOVE "/e"
# REMOVE "/f"
# REMOVE "/g"
# WRITE "/h"
# WRITE "/h"
windows:
REMOVE "/"
REMOVE "/a"
REMOVE "/b"
REMOVE "/c"
REMOVE "/d"
REMOVE "/e"
REMOVE "/f"
REMOVE "/g"
REMOVE "/h"
REMOVE "/i"
REMOVE "/j"
WRITE "/h"
WRITE "/h"
WRITE "/i"
WRITE "/i"
WRITE "/j"
WRITE "/j"
`},

{"remove recursive", func(t *testing.T, w *Watcher, tmp string) {
recurseOnly(t)

Expand Down Expand Up @@ -797,6 +737,66 @@ func TestWatchRemove(t *testing.T) {
tt := tt
tt.run(t)
}

t.Run("remove watched directory", func(t *testing.T) {
t.Parallel()
tmp := t.TempDir()

w := newCollector(t)
w.collect(t)

touch(t, tmp, "a")
touch(t, tmp, "b")
touch(t, tmp, "c")
touch(t, tmp, "d")
touch(t, tmp, "e")
touch(t, tmp, "f")
touch(t, tmp, "g")
mkdir(t, tmp, "h")
mkdir(t, tmp, "h", "a")
mkdir(t, tmp, "i")
mkdir(t, tmp, "i", "a")
mkdir(t, tmp, "j")
mkdir(t, tmp, "j", "a")
addWatch(t, w.w, tmp)
rmAll(t, tmp)

if runtime.GOOS != "windows" {
cmpEvents(t, tmp, w.stop(t), newEvents(t, `
remove /
remove /a
remove /b
remove /c
remove /d
remove /e
remove /f
remove /g
remove /h
remove /i
remove /j`))
return
}

// ReadDirectoryChangesW gives undefined results: not all files are
// always present. So test only that 1) we got the directory itself, and
// 2) we don't get events for unspected files.
var (
events = w.stop(t)
found bool
)
for _, e := range events {
if e.Name == tmp && e.Has(Remove) {
found = true
continue
}
if filepath.Dir(e.Name) != tmp {
t.Errorf("unexpected event: %s", e)
}
}
if !found {
t.Fatalf("didn't see directory in:\n%s", events)
}
})
}

func TestWatchRecursive(t *testing.T) {
Expand Down
5 changes: 5 additions & 0 deletions mkdoc.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ watcher=$(<<EOF
// Paths can be added as "C:\\path\\to\\dir", but forward slashes
// ("C:/path/to/dir") will also work.
//
// When a watched directory is removed it will always send an event for the
// directory itself, but may not send events for all files in that directory.
// Sometimes it will send events for all times, sometimes it will send no
// events, and often only for some files.
//
// The default buffer size is 64K, which is the largest value that is guaranteed
// to work with SMB filesystems. If you have many events in quick succession
// this may not be enough, and you will have to use [WithBufferSize] to increase
Expand Down

0 comments on commit e6384f3

Please sign in to comment.