]> go.fuhry.dev Git - fsnotify.git/commitdiff
windows: run TestWatchRename/rename_overwriting_existing_file (#490)
authorMartin Tournoij <martin@arp242.net>
Fri, 5 Aug 2022 19:52:45 +0000 (21:52 +0200)
committerGitHub <noreply@github.com>
Fri, 5 Aug 2022 19:52:45 +0000 (21:52 +0200)
This Skip() was added in 2013 (c825c6d) with "Windows cannot overwrite
file on rename", but it seems to work fine. os.Rename() is also
documented as "If newpath already exists and is not a directory, Rename
replaces it", so if it *doesn't* work it's a bug in os.Rename(). Maybe
os.Rename() behaved different nine years ago.

inotify.go
integration_test.go

index 454e81e27ce072e328d0e35e241977e4d98e8a8e..9f33b1867e5f159f4b1e239e0a16129554a5f6ef 100644 (file)
@@ -241,11 +241,12 @@ func (w *Watcher) readEvents() {
                // We don't know how many events we just read into the buffer
                // While the offset points to at least one whole event...
                for offset <= uint32(n-unix.SizeofInotifyEvent) {
-                       // Point "raw" to the event in the buffer
-                       raw := (*unix.InotifyEvent)(unsafe.Pointer(&buf[offset]))
-
-                       mask := uint32(raw.Mask)
-                       nameLen := uint32(raw.Len)
+                       var (
+                               // Point "raw" to the event in the buffer
+                               raw     = (*unix.InotifyEvent)(unsafe.Pointer(&buf[offset]))
+                               mask    = uint32(raw.Mask)
+                               nameLen = uint32(raw.Len)
+                       )
 
                        if mask&unix.IN_Q_OVERFLOW != 0 {
                                select {
index 7f833cec7bd6ea010dd4573d1e031918422bfa47..8768fbfeaf4993e1a14bc04f591cb0bea87cabb7 100644 (file)
@@ -142,11 +142,6 @@ func TestWatchRename(t *testing.T) {
                `},
 
                {"rename overwriting existing file", func(t *testing.T, w *Watcher, tmp string) {
-                       switch runtime.GOOS {
-                       case "windows":
-                               t.Skipf("os.Rename over existing file does not create an event on %q", runtime.GOOS)
-                       }
-
                        touch(t, tmp, "renamed")
                        addWatch(t, w, tmp)
 
@@ -158,11 +153,9 @@ func TestWatchRename(t *testing.T) {
                        remove /renamed
                        create /renamed
 
-                       # No remove event for Windows and Linux.
+                       # No remove event for inotify; inotify just sends MOVE_SELF.
                        linux:
                                create /renamed
-                       windows:
-                               create /renamed
                `},
 
                {"rename watched directory", func(t *testing.T, w *Watcher, tmp string) {