}
// Close removes all watches and closes the events channel.
-func (w *Watcher) Close() error {
- return nil
-}
+func (w *Watcher) Close() error { return nil }
+
+// WatchList returns all paths added with [Add] (and are not yet removed).
+//
+// Returns nil if [Watcher.Close] was called.
+func (w *Watcher) WatchList() []string { return nil }
// Add starts monitoring the path for changes.
//
//
// Instead, watch the parent directory and use Event.Name to filter out files
// you're not interested in. There is an example of this in [cmd/fsnotify/file.go].
-func (w *Watcher) Add(name string) error {
- return nil
-}
+func (w *Watcher) Add(name string) error { return nil }
// Remove stops monitoring the path for changes.
//
// /tmp/dir and /tmp/dir/subdir then you will need to remove both.
//
// Removing a path that has not yet been added returns [ErrNonExistentWatch].
-func (w *Watcher) Remove(name string) error {
- return nil
-}
+func (w *Watcher) Remove(name string) error { return nil }
-//go:build !plan9
-// +build !plan9
-
package fsnotify
import (
{"file in directory is not readable", func(t *testing.T, w *Watcher, tmp string) {
if runtime.GOOS == "windows" {
- t.Skip("attributes don't work on Windows")
+ t.Skip("attributes don't work on Windows") // Figure out how to make a file unreadable
}
touch(t, tmp, "file-unreadable")
kqueue:
WRITE "/file"
REMOVE "/file"
+
+ windows:
+ empty
`},
{"watch same dir twice", func(t *testing.T, w *Watcher, tmp string) {
// CREATE "/private/var/.../TestWatchwatch_a_symlink_to_a_dir2551725268/001/dir/file"
// Pretty sure this is caused by the broken symlink-follow
// behaviour too.
-
t.Skip("broken on macOS")
}
// FIFO
{"create new named pipe", func(t *testing.T, w *Watcher, tmp string) {
if runtime.GOOS == "windows" {
- t.Skip("no named pipes on windows")
+ t.Skip() // No named pipes on Windows.
}
touch(t, tmp, "file")
addWatch(t, w, tmp)
// Device node
{"create new device node pipe", func(t *testing.T, w *Watcher, tmp string) {
if runtime.GOOS == "windows" {
- t.Skip("no device nodes on windows")
+ t.Skip() // No device nodes on Windows.
}
if isKqueue() {
+ // Don't want to use os/user to check uid, since that pulls in
+ // cgo by default and stuff that uses fsnotify won't be
+ // statically linked by default.
t.Skip("needs root on BSD")
}
+ if isSolaris() {
+ t.Skip(`"mknod fails with "not owner"`)
+ }
touch(t, tmp, "file")
addWatch(t, w, tmp)
// kqueue.go does a lot of weird things with symlinks that I
// don't think are necessarily correct, but need to test a bit
// more.
- t.Skip()
+ t.Skip("broken on macOS")
}
symlink(t, ".", tmp, "link")
// TODO: fix it; this seems a bit hard though; the entire way
// kqueue backend deals with symlinks is meh, and need to
// be careful not to break compatibility.
- t.Skip("broken")
+ t.Skip("broken on kqueue")
}
touch(t, tmp, "file1")
}
func TestWatchAttrib(t *testing.T) {
- if runtime.GOOS == "windows" {
- t.Skip("attributes don't work on Windows")
- }
-
tests := []testCase{
{"chmod", func(t *testing.T, w *Watcher, tmp string) {
file := filepath.Join(tmp, "file")
chmod(t, 0o700, file)
}, `
CHMOD "/file"
+
+ windows:
+ empty
`},
{"write does not trigger CHMOD", func(t *testing.T, w *Watcher, tmp string) {
cat(t, "data", file)
addWatch(t, w, file)
chmod(t, 0o700, file)
-
cat(t, "more data", file)
}, `
CHMOD "/file"
WRITE "/file"
+
+ windows:
+ write /file
`},
{"chmod after write", func(t *testing.T, w *Watcher, tmp string) {
CHMOD "/file"
WRITE "/file"
CHMOD "/file"
+
+ windows:
+ write /file
`},
}
t.Run("closes channels after read", func(t *testing.T) {
if runtime.GOOS == "netbsd" {
- t.Skip("flaky") // TODO
+ t.Skip("flaky")
}
t.Parallel()
func TestAdd(t *testing.T) {
t.Run("permission denied", func(t *testing.T) {
if runtime.GOOS == "windows" {
- t.Skip("attributes don't work on Windows")
+ t.Skip("chmod doesn't work on Windows") // See if we can make a file unreadable
}
t.Parallel()
}
}
-func isKqueue() bool {
- switch runtime.GOOS {
- case "linux", "windows":
- return false
- }
- return true
-}
-
// Verify the watcher can keep up with file creations/deletions when under load.
func TestWatchStress(t *testing.T) {
if isCI() {
func TestWatchList(t *testing.T) {
if runtime.GOOS == "windows" {
// TODO: probably should I guess...
- t.Skip("WatchList has always beek broken on Windows and I don't feel like fixing it")
+ t.Skip("WatchList has always been broken on Windows and I don't feel like fixing it")
}
t.Parallel()