From: Martin Tournoij Date: Fri, 14 Oct 2022 16:26:55 +0000 (+0200) Subject: Add failing test for #277 (#522) X-Git-Tag: v1.7.2~48 X-Git-Url: https://go.fuhry.dev/?a=commitdiff_plain;h=aaabe109285e92d579a78b9192ff387f010eaf6b;p=fsnotify.git Add failing test for #277 (#522) --- diff --git a/backend_kqueue.go b/backend_kqueue.go index edf9aac..141ca83 100644 --- a/backend_kqueue.go +++ b/backend_kqueue.go @@ -368,7 +368,6 @@ const noteAllEvents = unix.NOTE_DELETE | unix.NOTE_WRITE | unix.NOTE_ATTRIB | un // Returns the real path to the file which was added, if any, which may be different from the one passed in the case of symlinks. func (w *Watcher) addWatch(name string, flags uint32) (string, error) { var isDir bool - // Make ./name and name equivalent name = filepath.Clean(name) w.mu.Lock() diff --git a/fsnotify_test.go b/fsnotify_test.go index 54e446d..7d3d92f 100644 --- a/fsnotify_test.go +++ b/fsnotify_test.go @@ -588,6 +588,35 @@ func TestWatchSymlink(t *testing.T) { create /link write /link `}, + + // Bug #277 + {"277", func(t *testing.T, w *Watcher, tmp string) { + if isKqueue() { + // 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") + } + + touch(t, tmp, "file1") + touch(t, tmp, "file2") + symlink(t, filepath.Join(tmp, "file1"), tmp, "link1") + symlink(t, filepath.Join(tmp, "file2"), tmp, "link2") + + addWatch(t, w, tmp) + touch(t, tmp, "foo") + rm(t, tmp, "foo") + mkdir(t, tmp, "apple") + mv(t, filepath.Join(tmp, "apple"), tmp, "pear") + rmAll(t, tmp, "pear") + }, ` + create /foo # touch foo + remove /foo # rm foo + create /apple # mkdir apple + rename /apple # mv apple pear + create /pear + remove /pear # rm -r pear + `}, } for _, tt := range tests {