]> go.fuhry.dev Git - fsnotify.git/commitdiff
Commited to go.exp
authorChris Howey <chris@howey.me>
Mon, 11 Mar 2013 23:26:37 +0000 (18:26 -0500)
committerChris Howey <chris@howey.me>
Mon, 11 Mar 2013 23:26:37 +0000 (18:26 -0500)
https://codereview.appspot.com/7497045
https://code.google.com/p/go/issues/detail?id=4068

example_test.go
fsnotify.go
fsnotify_bsd.go
fsnotify_linux.go
fsnotify_test.go
fsnotify_windows.go

index 5f0c8b5380538f71565fdee10007d7e622510c35..37c0d0c5f35261cb752396aecd392516dd4b3c1c 100644 (file)
@@ -1,8 +1,13 @@
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
 package fsnotify_test
 
 import (
-       "github.com/howeyc/fsnotify"
        "log"
+
+       "code.google.com/p/go.exp/fsnotify"
 )
 
 func ExampleNewWatcher() {
index a700db6795a760d45c15b758bda33a6a9097c04f..ed731a588be09fbfc9c9e298f264bfa0482a7dfe 100644 (file)
@@ -2,6 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// Package fsnotify implements filesystem notification.
 package fsnotify
 
 import "fmt"
index 1c344f016071305049ed148703d9efc425d4b6a0..f6f779927b5466a731b8861c8eb436d04a2b3520 100644 (file)
@@ -4,7 +4,6 @@
 
 // +build freebsd openbsd netbsd darwin
 
-//Package fsnotify implements filesystem notification.
 package fsnotify
 
 import (
index 2b7dbb4447a609e36220d6ae5a6ce4287342e616..3f0241b766bf3db1a8686c38867300f44f90017f 100644 (file)
@@ -4,7 +4,6 @@
 
 // +build linux
 
-// Package fsnotify implements a wrapper for the Linux inotify system.
 package fsnotify
 
 import (
index 0ae9ed9910e6ac8cb3e3f25f0649a1cf7a4cafc2..d272453c60f44c5ea03037ce2651b6cf067a7dd5 100644 (file)
@@ -1,6 +1,6 @@
-// Copyright 2010 The Go Authors. All rights reserved.\r
-// Use of this source code is governed by a BSD-style\r
-// license that can be found in the LICENSE file.\r
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
 
 package fsnotify
 
@@ -13,7 +13,7 @@ import (
        "time"
 )
 
-// An atomic counter\r
+// An atomic counter
 type counter struct {
        val int32
 }
@@ -31,13 +31,13 @@ func (c *counter) value() int32 {
 }
 
 func TestFsnotifyMultipleOperations(t *testing.T) {
-       // Create an fsnotify watcher instance and initialize it\r
+       // Create an fsnotify watcher instance and initialize it
        watcher, err := NewWatcher()
        if err != nil {
                t.Fatalf("NewWatcher() failed: %s", err)
        }
 
-       // Receive errors on the error channel on a separate goroutine\r
+       // Receive errors on the error channel on a separate goroutine
        go func() {
                for err := range watcher.Error {
                        t.Fatalf("error received: %s", err)
@@ -47,13 +47,13 @@ func TestFsnotifyMultipleOperations(t *testing.T) {
        const testDir string = "_test"
        const testDirToMoveFiles string = "_test2"
 
-       // Create directory to watch\r
+       // Create directory to watch
        if err := os.Mkdir(testDir, 0777); err != nil {
                t.Fatalf("Failed to create test directory: %s", err)
        }
        defer os.RemoveAll(testDir)
 
-       // Create directory to that's not watched\r
+       // Create directory to that's not watched
        if err := os.Mkdir(testDirToMoveFiles, 0777); err != nil {
                t.Fatalf("Failed to create test directory: %s", err)
        }
@@ -62,18 +62,18 @@ func TestFsnotifyMultipleOperations(t *testing.T) {
        const testFile string = "_test/TestFsnotifySeq.testfile"
        const testFileRenamed string = "_test2/TestFsnotifySeqRename.testfile"
 
-       // Add a watch for testDir\r
+       // Add a watch for testDir
        err = watcher.Watch(testDir)
        if err != nil {
                t.Fatalf("Watcher.Watch() failed: %s", err)
        }
-       // Receive events on the event channel on a separate goroutine\r
+       // Receive events on the event channel on a separate goroutine
        eventstream := watcher.Event
        var createReceived, modifyReceived, deleteReceived, renameReceived counter
        done := make(chan bool)
        go func() {
                for event := range eventstream {
-                       // Only count relevant events\r
+                       // Only count relevant events
                        if event.Name == filepath.Clean(testDir) || event.Name == filepath.Clean(testFile) {
                                t.Logf("event received: %s", event)
                                if event.IsDelete() {
@@ -95,8 +95,8 @@ func TestFsnotifyMultipleOperations(t *testing.T) {
                done <- true
        }()
 
-       // Create a file\r
-       // This should add at least one event to the fsnotify event queue\r
+       // Create a file
+       // This should add at least one event to the fsnotify event queue
        var f *os.File
        f, err = os.OpenFile(testFile, os.O_WRONLY|os.O_CREATE, 0666)
        if err != nil {
@@ -109,7 +109,7 @@ func TestFsnotifyMultipleOperations(t *testing.T) {
        f.Sync()
        f.Close()
 
-       time.Sleep(50 * time.Millisecond) // give system time to sync write change before delete\r
+       time.Sleep(50 * time.Millisecond) // give system time to sync write change before delete
 
        cmd := exec.Command("mv", testFile, testFileRenamed)
        err = cmd.Run()
@@ -117,7 +117,7 @@ func TestFsnotifyMultipleOperations(t *testing.T) {
                t.Fatalf("rename failed: %s", err)
        }
 
-       // Modify the file outside of the watched dir\r
+       // Modify the file outside of the watched dir
        f, err = os.Open(testFileRenamed)
        if err != nil {
                t.Fatalf("open test renamed file failed: %s", err)
@@ -126,17 +126,17 @@ func TestFsnotifyMultipleOperations(t *testing.T) {
        f.Sync()
        f.Close()
 
-       time.Sleep(50 * time.Millisecond) // give system time to sync write change before delete\r
+       time.Sleep(50 * time.Millisecond) // give system time to sync write change before delete
 
-       // Recreate the file that was moved\r
+       // Recreate the file that was moved
        f, err = os.OpenFile(testFile, os.O_WRONLY|os.O_CREATE, 0666)
        if err != nil {
                t.Fatalf("creating test file failed: %s", err)
        }
        f.Close()
-       time.Sleep(50 * time.Millisecond) // give system time to sync write change before delete\r
+       time.Sleep(50 * time.Millisecond) // give system time to sync write change before delete
 
-       // We expect this event to be received almost immediately, but let's wait 500 ms to be sure\r
+       // We expect this event to be received almost immediately, but let's wait 500 ms to be sure
        time.Sleep(500 * time.Millisecond)
        cReceived := createReceived.value()
        if cReceived != 2 {
@@ -152,7 +152,7 @@ func TestFsnotifyMultipleOperations(t *testing.T) {
                t.Fatalf("incorrect number of rename+delete events received after 500 ms (%d vs %d)", rReceived+dReceived, 1)
        }
 
-       // Try closing the fsnotify instance\r
+       // Try closing the fsnotify instance
        t.Log("calling Close()")
        watcher.Close()
        t.Log("waiting for the event channel to become closed...")
@@ -165,13 +165,13 @@ func TestFsnotifyMultipleOperations(t *testing.T) {
 }
 
 func TestFsnotifyMultipleCreates(t *testing.T) {
-       // Create an fsnotify watcher instance and initialize it\r
+       // Create an fsnotify watcher instance and initialize it
        watcher, err := NewWatcher()
        if err != nil {
                t.Fatalf("NewWatcher() failed: %s", err)
        }
 
-       // Receive errors on the error channel on a separate goroutine\r
+       // Receive errors on the error channel on a separate goroutine
        go func() {
                for err := range watcher.Error {
                        t.Fatalf("error received: %s", err)
@@ -180,7 +180,7 @@ func TestFsnotifyMultipleCreates(t *testing.T) {
 
        const testDir string = "_test"
 
-       // Create directory to watch\r
+       // Create directory to watch
        if err := os.Mkdir(testDir, 0777); err != nil {
                t.Fatalf("Failed to create test directory: %s", err)
        }
@@ -188,18 +188,18 @@ func TestFsnotifyMultipleCreates(t *testing.T) {
 
        const testFile string = "_test/TestFsnotifySeq.testfile"
 
-       // Add a watch for testDir\r
+       // Add a watch for testDir
        err = watcher.Watch(testDir)
        if err != nil {
                t.Fatalf("Watcher.Watch() failed: %s", err)
        }
-       // Receive events on the event channel on a separate goroutine\r
+       // Receive events on the event channel on a separate goroutine
        eventstream := watcher.Event
        var createReceived, modifyReceived, deleteReceived counter
        done := make(chan bool)
        go func() {
                for event := range eventstream {
-                       // Only count relevant events\r
+                       // Only count relevant events
                        if event.Name == filepath.Clean(testDir) || event.Name == filepath.Clean(testFile) {
                                t.Logf("event received: %s", event)
                                if event.IsDelete() {
@@ -218,8 +218,8 @@ func TestFsnotifyMultipleCreates(t *testing.T) {
                done <- true
        }()
 
-       // Create a file\r
-       // This should add at least one event to the fsnotify event queue\r
+       // Create a file
+       // This should add at least one event to the fsnotify event queue
        var f *os.File
        f, err = os.OpenFile(testFile, os.O_WRONLY|os.O_CREATE, 0666)
        if err != nil {
@@ -232,21 +232,21 @@ func TestFsnotifyMultipleCreates(t *testing.T) {
        f.Sync()
        f.Close()
 
-       time.Sleep(50 * time.Millisecond) // give system time to sync write change before delete\r
+       time.Sleep(50 * time.Millisecond) // give system time to sync write change before delete
 
        os.Remove(testFile)
 
-       time.Sleep(50 * time.Millisecond) // give system time to sync write change before delete\r
+       time.Sleep(50 * time.Millisecond) // give system time to sync write change before delete
 
-       // Recreate the file\r
+       // Recreate the file
        f, err = os.OpenFile(testFile, os.O_WRONLY|os.O_CREATE, 0666)
        if err != nil {
                t.Fatalf("creating test file failed: %s", err)
        }
        f.Close()
-       time.Sleep(50 * time.Millisecond) // give system time to sync write change before delete\r
+       time.Sleep(50 * time.Millisecond) // give system time to sync write change before delete
 
-       // Modify\r
+       // Modify
        f, err = os.OpenFile(testFile, os.O_WRONLY, 0666)
        if err != nil {
                t.Fatalf("creating test file failed: %s", err)
@@ -258,9 +258,9 @@ func TestFsnotifyMultipleCreates(t *testing.T) {
        f.Sync()
        f.Close()
 
-       time.Sleep(50 * time.Millisecond) // give system time to sync write change before delete\r
+       time.Sleep(50 * time.Millisecond) // give system time to sync write change before delete
 
-       // Modify\r
+       // Modify
        f, err = os.OpenFile(testFile, os.O_WRONLY, 0666)
        if err != nil {
                t.Fatalf("creating test file failed: %s", err)
@@ -272,9 +272,9 @@ func TestFsnotifyMultipleCreates(t *testing.T) {
        f.Sync()
        f.Close()
 
-       time.Sleep(50 * time.Millisecond) // give system time to sync write change before delete\r
+       time.Sleep(50 * time.Millisecond) // give system time to sync write change before delete
 
-       // We expect this event to be received almost immediately, but let's wait 500 ms to be sure\r
+       // We expect this event to be received almost immediately, but let's wait 500 ms to be sure
        time.Sleep(500 * time.Millisecond)
        cReceived := createReceived.value()
        if cReceived != 2 {
@@ -289,7 +289,7 @@ func TestFsnotifyMultipleCreates(t *testing.T) {
                t.Fatalf("incorrect number of rename+delete events received after 500 ms (%d vs %d)", dReceived, 1)
        }
 
-       // Try closing the fsnotify instance\r
+       // Try closing the fsnotify instance
        t.Log("calling Close()")
        watcher.Close()
        t.Log("waiting for the event channel to become closed...")
@@ -302,7 +302,7 @@ func TestFsnotifyMultipleCreates(t *testing.T) {
 }
 
 func TestFsnotifyDirOnly(t *testing.T) {
-       // Create an fsnotify watcher instance and initialize it\r
+       // Create an fsnotify watcher instance and initialize it
        watcher, err := NewWatcher()
        if err != nil {
                t.Fatalf("NewWatcher() failed: %s", err)
@@ -310,14 +310,14 @@ func TestFsnotifyDirOnly(t *testing.T) {
 
        const testDir string = "_test"
 
-       // Create directory to watch\r
+       // Create directory to watch
        if err := os.Mkdir(testDir, 0777); err != nil {
                t.Fatalf("Failed to create test directory: %s", err)
        }
        defer os.RemoveAll(testDir)
 
-       // Create a file before watching directory\r
-       // This should NOT add any events to the fsnotify event queue\r
+       // Create a file before watching directory
+       // This should NOT add any events to the fsnotify event queue
        const testFileAlreadyExists string = "_test/TestFsnotifyEventsExisting.testfile"
        {
                var f *os.File
@@ -329,13 +329,13 @@ func TestFsnotifyDirOnly(t *testing.T) {
                f.Close()
        }
 
-       // Add a watch for testDir\r
+       // Add a watch for testDir
        err = watcher.Watch(testDir)
        if err != nil {
                t.Fatalf("Watcher.Watch() failed: %s", err)
        }
 
-       // Receive errors on the error channel on a separate goroutine\r
+       // Receive errors on the error channel on a separate goroutine
        go func() {
                for err := range watcher.Error {
                        t.Fatalf("error received: %s", err)
@@ -344,13 +344,13 @@ func TestFsnotifyDirOnly(t *testing.T) {
 
        const testFile string = "_test/TestFsnotifyDirOnly.testfile"
 
-       // Receive events on the event channel on a separate goroutine\r
+       // Receive events on the event channel on a separate goroutine
        eventstream := watcher.Event
        var createReceived, modifyReceived, deleteReceived counter
        done := make(chan bool)
        go func() {
                for event := range eventstream {
-                       // Only count relevant events\r
+                       // Only count relevant events
                        if event.Name == filepath.Clean(testDir) || event.Name == filepath.Clean(testFile) || event.Name == filepath.Clean(testFileAlreadyExists) {
                                t.Logf("event received: %s", event)
                                if event.IsDelete() {
@@ -369,8 +369,8 @@ func TestFsnotifyDirOnly(t *testing.T) {
                done <- true
        }()
 
-       // Create a file\r
-       // This should add at least one event to the fsnotify event queue\r
+       // Create a file
+       // This should add at least one event to the fsnotify event queue
        var f *os.File
        f, err = os.OpenFile(testFile, os.O_WRONLY|os.O_CREATE, 0666)
        if err != nil {
@@ -383,12 +383,12 @@ func TestFsnotifyDirOnly(t *testing.T) {
        f.Sync()
        f.Close()
 
-       time.Sleep(50 * time.Millisecond) // give system time to sync write change before delete\r
+       time.Sleep(50 * time.Millisecond) // give system time to sync write change before delete
 
        os.Remove(testFile)
        os.Remove(testFileAlreadyExists)
 
-       // We expect this event to be received almost immediately, but let's wait 500 ms to be sure\r
+       // We expect this event to be received almost immediately, but let's wait 500 ms to be sure
        time.Sleep(500 * time.Millisecond)
        cReceived := createReceived.value()
        if cReceived != 1 {
@@ -403,7 +403,7 @@ func TestFsnotifyDirOnly(t *testing.T) {
                t.Fatalf("incorrect number of delete events received after 500 ms (%d vs %d)", dReceived, 2)
        }
 
-       // Try closing the fsnotify instance\r
+       // Try closing the fsnotify instance
        t.Log("calling Close()")
        watcher.Close()
        t.Log("waiting for the event channel to become closed...")
@@ -416,7 +416,7 @@ func TestFsnotifyDirOnly(t *testing.T) {
 }
 
 func TestFsnotifyDeleteWatchedDir(t *testing.T) {
-       // Create an fsnotify watcher instance and initialize it\r
+       // Create an fsnotify watcher instance and initialize it
        watcher, err := NewWatcher()
        if err != nil {
                t.Fatalf("NewWatcher() failed: %s", err)
@@ -425,12 +425,12 @@ func TestFsnotifyDeleteWatchedDir(t *testing.T) {
 
        const testDir string = "_test"
 
-       // Create directory to watch\r
+       // Create directory to watch
        if err := os.Mkdir(testDir, 0777); err != nil {
                t.Fatalf("Failed to create test directory: %s", err)
        }
 
-       // Create a file before watching directory\r
+       // Create a file before watching directory
        const testFileAlreadyExists string = "_test/TestFsnotifyEventsExisting.testfile"
        {
                var f *os.File
@@ -442,31 +442,31 @@ func TestFsnotifyDeleteWatchedDir(t *testing.T) {
                f.Close()
        }
 
-       // Add a watch for testDir\r
+       // Add a watch for testDir
        err = watcher.Watch(testDir)
        if err != nil {
                t.Fatalf("Watcher.Watch() failed: %s", err)
        }
 
-       // Add a watch for testFile\r
+       // Add a watch for testFile
        err = watcher.Watch(testFileAlreadyExists)
        if err != nil {
                t.Fatalf("Watcher.Watch() failed: %s", err)
        }
 
-       // Receive errors on the error channel on a separate goroutine\r
+       // Receive errors on the error channel on a separate goroutine
        go func() {
                for err := range watcher.Error {
                        t.Fatalf("error received: %s", err)
                }
        }()
 
-       // Receive events on the event channel on a separate goroutine\r
+       // Receive events on the event channel on a separate goroutine
        eventstream := watcher.Event
        var deleteReceived counter
        go func() {
                for event := range eventstream {
-                       // Only count relevant events\r
+                       // Only count relevant events
                        if event.Name == filepath.Clean(testDir) || event.Name == filepath.Clean(testFileAlreadyExists) {
                                t.Logf("event received: %s", event)
                                if event.IsDelete() {
@@ -480,7 +480,7 @@ func TestFsnotifyDeleteWatchedDir(t *testing.T) {
 
        os.RemoveAll(testDir)
 
-       // We expect this event to be received almost immediately, but let's wait 500 ms to be sure\r
+       // We expect this event to be received almost immediately, but let's wait 500 ms to be sure
        time.Sleep(500 * time.Millisecond)
        dReceived := deleteReceived.value()
        if dReceived < 2 {
@@ -489,7 +489,9 @@ func TestFsnotifyDeleteWatchedDir(t *testing.T) {
 }
 
 func TestFsnotifySubDir(t *testing.T) {
-       // Create an fsnotify watcher instance and initialize it\r
+       t.Skip("fails on OS X at least")
+
+       // Create an fsnotify watcher instance and initialize it
        watcher, err := NewWatcher()
        if err != nil {
                t.Fatalf("NewWatcher() failed: %s", err)
@@ -500,26 +502,26 @@ func TestFsnotifySubDir(t *testing.T) {
        const testSubDir string = "_test/sub"
        const testSubDirFile string = "_test/sub/TestFsnotifyFile1.testfile"
 
-       // Create directory to watch\r
+       // Create directory to watch
        if err := os.Mkdir(testDir, 0777); err != nil {
                t.Fatalf("Failed to create test directory: %s", err)
        }
        defer os.RemoveAll(testDir)
 
-       // Receive errors on the error channel on a separate goroutine\r
+       // Receive errors on the error channel on a separate goroutine
        go func() {
                for err := range watcher.Error {
                        t.Fatalf("error received: %s", err)
                }
        }()
 
-       // Receive events on the event channel on a separate goroutine\r
+       // Receive events on the event channel on a separate goroutine
        eventstream := watcher.Event
        var createReceived, deleteReceived counter
        done := make(chan bool)
        go func() {
                for event := range eventstream {
-                       // Only count relevant events\r
+                       // Only count relevant events
                        if event.Name == filepath.Clean(testDir) || event.Name == filepath.Clean(testSubDir) || event.Name == filepath.Clean(testFile1) {
                                t.Logf("event received: %s", event)
                                if event.IsCreate() {
@@ -535,18 +537,18 @@ func TestFsnotifySubDir(t *testing.T) {
                done <- true
        }()
 
-       // Add a watch for testDir\r
+       // Add a watch for testDir
        err = watcher.Watch(testDir)
        if err != nil {
                t.Fatalf("Watcher.Watch() failed: %s", err)
        }
 
-       // Create sub-directory\r
+       // Create sub-directory
        if err := os.Mkdir(testSubDir, 0777); err != nil {
                t.Fatalf("Failed to create test sub-directory: %s", err)
        }
 
-       // Create a file\r
+       // Create a file
        var f *os.File
        f, err = os.OpenFile(testFile1, os.O_WRONLY|os.O_CREATE, 0666)
        if err != nil {
@@ -555,7 +557,7 @@ func TestFsnotifySubDir(t *testing.T) {
        f.Sync()
        f.Close()
 
-       // Create a file (Should not see this! we are not watching subdir)\r
+       // Create a file (Should not see this! we are not watching subdir)
        var fs *os.File
        fs, err = os.OpenFile(testSubDirFile, os.O_WRONLY|os.O_CREATE, 0666)
        if err != nil {
@@ -564,11 +566,11 @@ func TestFsnotifySubDir(t *testing.T) {
        fs.Sync()
        fs.Close()
 
-       // Make sure receive deletes for both file and sub-directory\r
+       // Make sure receive deletes for both file and sub-directory
        os.RemoveAll(testSubDir)
        os.Remove(testFile1)
 
-       // We expect this event to be received almost immediately, but let's wait 500 ms to be sure\r
+       // We expect this event to be received almost immediately, but let's wait 500 ms to be sure
        time.Sleep(500 * time.Millisecond)
        cReceived := createReceived.value()
        if cReceived != 2 {
@@ -579,7 +581,7 @@ func TestFsnotifySubDir(t *testing.T) {
                t.Fatalf("incorrect number of delete events received after 500 ms (%d vs %d)", dReceived, 2)
        }
 
-       // Try closing the fsnotify instance\r
+       // Try closing the fsnotify instance
        t.Log("calling Close()")
        watcher.Close()
        t.Log("waiting for the event channel to become closed...")
@@ -592,7 +594,7 @@ func TestFsnotifySubDir(t *testing.T) {
 }
 
 func TestFsnotifyRename(t *testing.T) {
-       // Create an fsnotify watcher instance and initialize it\r
+       // Create an fsnotify watcher instance and initialize it
        watcher, err := NewWatcher()
        if err != nil {
                t.Fatalf("NewWatcher() failed: %s", err)
@@ -600,19 +602,19 @@ func TestFsnotifyRename(t *testing.T) {
 
        const testDir string = "_test"
 
-       // Create directory to watch\r
+       // Create directory to watch
        if err := os.Mkdir(testDir, 0777); err != nil {
                t.Fatalf("Failed to create test directory: %s", err)
        }
        defer os.RemoveAll(testDir)
 
-       // Add a watch for testDir\r
+       // Add a watch for testDir
        err = watcher.Watch(testDir)
        if err != nil {
                t.Fatalf("Watcher.Watch() failed: %s", err)
        }
 
-       // Receive errors on the error channel on a separate goroutine\r
+       // Receive errors on the error channel on a separate goroutine
        go func() {
                for err := range watcher.Error {
                        t.Fatalf("error received: %s", err)
@@ -622,13 +624,13 @@ func TestFsnotifyRename(t *testing.T) {
        const testFile string = "_test/TestFsnotifyEvents.testfile"
        const testFileRenamed string = "_test/TestFsnotifyEvents.testfileRenamed"
 
-       // Receive events on the event channel on a separate goroutine\r
+       // Receive events on the event channel on a separate goroutine
        eventstream := watcher.Event
        var renameReceived counter
        done := make(chan bool)
        go func() {
                for event := range eventstream {
-                       // Only count relevant events\r
+                       // Only count relevant events
                        if event.Name == filepath.Clean(testDir) || event.Name == filepath.Clean(testFile) || event.Name == filepath.Clean(testFileRenamed) {
                                if event.IsRename() {
                                        renameReceived.increment()
@@ -641,8 +643,8 @@ func TestFsnotifyRename(t *testing.T) {
                done <- true
        }()
 
-       // Create a file\r
-       // This should add at least one event to the fsnotify event queue\r
+       // Create a file
+       // This should add at least one event to the fsnotify event queue
        var f *os.File
        f, err = os.OpenFile(testFile, os.O_WRONLY|os.O_CREATE, 0666)
        if err != nil {
@@ -654,7 +656,7 @@ func TestFsnotifyRename(t *testing.T) {
        f.Sync()
        f.Close()
 
-       // Add a watch for testFile\r
+       // Add a watch for testFile
        err = watcher.Watch(testFile)
        if err != nil {
                t.Fatalf("Watcher.Watch() failed: %s", err)
@@ -666,13 +668,13 @@ func TestFsnotifyRename(t *testing.T) {
                t.Fatalf("rename failed: %s", err)
        }
 
-       // We expect this event to be received almost immediately, but let's wait 500 ms to be sure\r
+       // We expect this event to be received almost immediately, but let's wait 500 ms to be sure
        time.Sleep(500 * time.Millisecond)
        if renameReceived.value() == 0 {
                t.Fatal("fsnotify rename events have not been received after 500 ms")
        }
 
-       // Try closing the fsnotify instance\r
+       // Try closing the fsnotify instance
        t.Log("calling Close()")
        watcher.Close()
        t.Log("waiting for the event channel to become closed...")
@@ -687,7 +689,7 @@ func TestFsnotifyRename(t *testing.T) {
 }
 
 func TestFsnotifyRenameToCreate(t *testing.T) {
-       // Create an fsnotify watcher instance and initialize it\r
+       // Create an fsnotify watcher instance and initialize it
        watcher, err := NewWatcher()
        if err != nil {
                t.Fatalf("NewWatcher() failed: %s", err)
@@ -696,25 +698,25 @@ func TestFsnotifyRenameToCreate(t *testing.T) {
        const testDir string = "_test"
        const testDirFrom string = "_testfrom"
 
-       // Create directory to watch\r
+       // Create directory to watch
        if err := os.Mkdir(testDir, 0777); err != nil {
                t.Fatalf("Failed to create test directory: %s", err)
        }
        defer os.RemoveAll(testDir)
 
-       // Create directory to get file\r
+       // Create directory to get file
        if err := os.Mkdir(testDirFrom, 0777); err != nil {
                t.Fatalf("Failed to create test directory: %s", err)
        }
        defer os.RemoveAll(testDirFrom)
 
-       // Add a watch for testDir\r
+       // Add a watch for testDir
        err = watcher.Watch(testDir)
        if err != nil {
                t.Fatalf("Watcher.Watch() failed: %s", err)
        }
 
-       // Receive errors on the error channel on a separate goroutine\r
+       // Receive errors on the error channel on a separate goroutine
        go func() {
                for err := range watcher.Error {
                        t.Fatalf("error received: %s", err)
@@ -724,13 +726,13 @@ func TestFsnotifyRenameToCreate(t *testing.T) {
        const testFile string = "_testfrom/TestFsnotifyEvents.testfile"
        const testFileRenamed string = "_test/TestFsnotifyEvents.testfileRenamed"
 
-       // Receive events on the event channel on a separate goroutine\r
+       // Receive events on the event channel on a separate goroutine
        eventstream := watcher.Event
        var createReceived counter
        done := make(chan bool)
        go func() {
                for event := range eventstream {
-                       // Only count relevant events\r
+                       // Only count relevant events
                        if event.Name == filepath.Clean(testDir) || event.Name == filepath.Clean(testFile) || event.Name == filepath.Clean(testFileRenamed) {
                                if event.IsCreate() {
                                        createReceived.increment()
@@ -743,8 +745,8 @@ func TestFsnotifyRenameToCreate(t *testing.T) {
                done <- true
        }()
 
-       // Create a file\r
-       // This should add at least one event to the fsnotify event queue\r
+       // Create a file
+       // This should add at least one event to the fsnotify event queue
        var f *os.File
        f, err = os.OpenFile(testFile, os.O_WRONLY|os.O_CREATE, 0666)
        if err != nil {
@@ -759,13 +761,13 @@ func TestFsnotifyRenameToCreate(t *testing.T) {
                t.Fatalf("rename failed: %s", err)
        }
 
-       // We expect this event to be received almost immediately, but let's wait 500 ms to be sure\r
+       // We expect this event to be received almost immediately, but let's wait 500 ms to be sure
        time.Sleep(500 * time.Millisecond)
        if createReceived.value() == 0 {
                t.Fatal("fsnotify create events have not been received after 500 ms")
        }
 
-       // Try closing the fsnotify instance\r
+       // Try closing the fsnotify instance
        t.Log("calling Close()")
        watcher.Close()
        t.Log("waiting for the event channel to become closed...")
@@ -780,7 +782,7 @@ func TestFsnotifyRenameToCreate(t *testing.T) {
 }
 
 func TestFsnotifyRenameToOverwrite(t *testing.T) {
-       // Create an fsnotify watcher instance and initialize it\r
+       // Create an fsnotify watcher instance and initialize it
        watcher, err := NewWatcher()
        if err != nil {
                t.Fatalf("NewWatcher() failed: %s", err)
@@ -792,19 +794,19 @@ func TestFsnotifyRenameToOverwrite(t *testing.T) {
        const testFile string = "_testfrom/TestFsnotifyEvents.testfile"
        const testFileRenamed string = "_test/TestFsnotifyEvents.testfileRenamed"
 
-       // Create directory to watch\r
+       // Create directory to watch
        if err := os.Mkdir(testDir, 0777); err != nil {
                t.Fatalf("Failed to create test directory: %s", err)
        }
        defer os.RemoveAll(testDir)
 
-       // Create directory to get file\r
+       // Create directory to get file
        if err := os.Mkdir(testDirFrom, 0777); err != nil {
                t.Fatalf("Failed to create test directory: %s", err)
        }
        defer os.RemoveAll(testDirFrom)
 
-       // Create a file\r
+       // Create a file
        var fr *os.File
        fr, err = os.OpenFile(testFileRenamed, os.O_WRONLY|os.O_CREATE, 0666)
        if err != nil {
@@ -813,26 +815,26 @@ func TestFsnotifyRenameToOverwrite(t *testing.T) {
        fr.Sync()
        fr.Close()
 
-       // Add a watch for testDir\r
+       // Add a watch for testDir
        err = watcher.Watch(testDir)
        if err != nil {
                t.Fatalf("Watcher.Watch() failed: %s", err)
        }
 
-       // Receive errors on the error channel on a separate goroutine\r
+       // Receive errors on the error channel on a separate goroutine
        go func() {
                for err := range watcher.Error {
                        t.Fatalf("error received: %s", err)
                }
        }()
 
-       // Receive events on the event channel on a separate goroutine\r
+       // Receive events on the event channel on a separate goroutine
        eventstream := watcher.Event
        var eventReceived counter
        done := make(chan bool)
        go func() {
                for event := range eventstream {
-                       // Only count relevant events\r
+                       // Only count relevant events
                        if event.Name == filepath.Clean(testFileRenamed) {
                                eventReceived.increment()
                                t.Logf("event received: %s", event)
@@ -843,8 +845,8 @@ func TestFsnotifyRenameToOverwrite(t *testing.T) {
                done <- true
        }()
 
-       // Create a file\r
-       // This should add at least one event to the fsnotify event queue\r
+       // Create a file
+       // This should add at least one event to the fsnotify event queue
        var f *os.File
        f, err = os.OpenFile(testFile, os.O_WRONLY|os.O_CREATE, 0666)
        if err != nil {
@@ -859,13 +861,13 @@ func TestFsnotifyRenameToOverwrite(t *testing.T) {
                t.Fatalf("rename failed: %s", err)
        }
 
-       // We expect this event to be received almost immediately, but let's wait 500 ms to be sure\r
+       // We expect this event to be received almost immediately, but let's wait 500 ms to be sure
        time.Sleep(500 * time.Millisecond)
        if eventReceived.value() == 0 {
                t.Fatal("fsnotify events have not been received after 500 ms")
        }
 
-       // Try closing the fsnotify instance\r
+       // Try closing the fsnotify instance
        t.Log("calling Close()")
        watcher.Close()
        t.Log("waiting for the event channel to become closed...")
@@ -880,7 +882,7 @@ func TestFsnotifyRenameToOverwrite(t *testing.T) {
 }
 
 func TestFsnotifyAttrib(t *testing.T) {
-       // Create an fsnotify watcher instance and initialize it\r
+       // Create an fsnotify watcher instance and initialize it
        watcher, err := NewWatcher()
        if err != nil {
                t.Fatalf("NewWatcher() failed: %s", err)
@@ -888,13 +890,13 @@ func TestFsnotifyAttrib(t *testing.T) {
 
        const testDir string = "_test"
 
-       // Create directory to watch\r
+       // Create directory to watch
        if err := os.Mkdir(testDir, 0777); err != nil {
                t.Fatalf("Failed to create test directory: %s", err)
        }
        defer os.RemoveAll(testDir)
 
-       // Receive errors on the error channel on a separate goroutine\r
+       // Receive errors on the error channel on a separate goroutine
        go func() {
                for err := range watcher.Error {
                        t.Fatalf("error received: %s", err)
@@ -903,13 +905,13 @@ func TestFsnotifyAttrib(t *testing.T) {
 
        const testFile string = "_test/TestFsnotifyAttrib.testfile"
 
-       // Receive events on the event channel on a separate goroutine\r
+       // Receive events on the event channel on a separate goroutine
        eventstream := watcher.Event
        var attribReceived counter
        done := make(chan bool)
        go func() {
                for event := range eventstream {
-                       // Only count relevant events\r
+                       // Only count relevant events
                        if event.Name == filepath.Clean(testDir) || event.Name == filepath.Clean(testFile) {
                                if event.IsModify() {
                                        attribReceived.increment()
@@ -922,8 +924,8 @@ func TestFsnotifyAttrib(t *testing.T) {
                done <- true
        }()
 
-       // Create a file\r
-       // This should add at least one event to the fsnotify event queue\r
+       // Create a file
+       // This should add at least one event to the fsnotify event queue
        var f *os.File
        f, err = os.OpenFile(testFile, os.O_WRONLY|os.O_CREATE, 0666)
        if err != nil {
@@ -935,7 +937,7 @@ func TestFsnotifyAttrib(t *testing.T) {
        f.Sync()
        f.Close()
 
-       // Add a watch for testFile\r
+       // Add a watch for testFile
        err = watcher.Watch(testFile)
        if err != nil {
                t.Fatalf("Watcher.Watch() failed: %s", err)
@@ -947,13 +949,13 @@ func TestFsnotifyAttrib(t *testing.T) {
                t.Fatalf("chmod failed: %s", err)
        }
 
-       // We expect this event to be received almost immediately, but let's wait 500 ms to be sure\r
+       // We expect this event to be received almost immediately, but let's wait 500 ms to be sure
        time.Sleep(500 * time.Millisecond)
        if attribReceived.value() == 0 {
                t.Fatal("fsnotify attribute events have not received after 500 ms")
        }
 
-       // Try closing the fsnotify instance\r
+       // Try closing the fsnotify instance
        t.Log("calling Close()")
        watcher.Close()
        t.Log("waiting for the event channel to become closed...")
@@ -977,7 +979,7 @@ func TestFsnotifyClose(t *testing.T) {
                atomic.StoreInt32(&done, 1)
        }()
 
-       time.Sleep(50e6) // 50 ms\r
+       time.Sleep(50e6) // 50 ms
        if atomic.LoadInt32(&done) == 0 {
                t.Fatal("double Close() test failed: second Close() call didn't return")
        }
index ebc25bb0e1c212367b6b01b764fcc8a64f6dcd4a..d4ef82785629da0b6216523826cc1b38a581abc5 100644 (file)
@@ -4,8 +4,6 @@
 
 // +build windows
 
-// Package fsnotify allows the user to receive
-// file system event notifications on Windows.
 package fsnotify
 
 import (