]> go.fuhry.dev Git - fsnotify.git/commitdiff
Add failing test for #277 (#522)
authorMartin Tournoij <martin@arp242.net>
Fri, 14 Oct 2022 16:26:55 +0000 (18:26 +0200)
committerGitHub <noreply@github.com>
Fri, 14 Oct 2022 16:26:55 +0000 (18:26 +0200)
backend_kqueue.go
fsnotify_test.go

index edf9aace0091f795d87ac7fdda1c7ea5cf60da19..141ca8355db9479bfaa373720e99f229e0a253af 100644 (file)
@@ -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()
index 54e446dcb5f0eb6e3bcd15614ea5b1c27652913a..7d3d92fb45762d3e018b3b5d7f476e1f3b0647ed 100644 (file)
@@ -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 {