]> go.fuhry.dev Git - fsnotify.git/commitdiff
Windows - No Symlinks
authorChris Howey <chris@howey.me>
Sat, 28 Apr 2012 16:21:04 +0000 (11:21 -0500)
committerChris Howey <chris@howey.me>
Sat, 28 Apr 2012 16:21:04 +0000 (11:21 -0500)
fsnotify_symlink_test.go [new file with mode: 0644]
fsnotify_test.go

diff --git a/fsnotify_symlink_test.go b/fsnotify_symlink_test.go
new file mode 100644 (file)
index 0000000..f6899a7
--- /dev/null
@@ -0,0 +1,58 @@
+// 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.
+
+// -build windows
+
+package fsnotify
+
+import (
+       "os"
+       "testing"
+)
+
+func TestFsnotifyFakeSymlink(t *testing.T) {
+       // Create an fsnotify watcher instance and initialize it
+       watcher, err := NewWatcher()
+       if err != nil {
+               t.Fatalf("NewWatcher() failed: %s", err)
+       }
+
+       const testDir string = "_test"
+
+       // Create directory to watch
+       if os.Mkdir(testDir, 0777) != nil {
+               t.Fatalf("Failed to create test directory: %s", err)
+       }
+       defer os.RemoveAll(testDir)
+
+       if os.Symlink("_test/zzz", "_test/zzznew") != nil {
+               t.Fatalf("Failed to create bogus symlink: %s", err)
+       }
+       t.Logf("Created bogus symlink")
+
+       var errorsReceived = 0
+       // Receive errors on the error channel on a separate goroutine
+       go func() {
+               for errors := range watcher.Error {
+                       t.Logf("Received error: %s", errors)
+                       errorsReceived++
+               }
+       }()
+
+       // Add a watch for testDir
+       err = watcher.Watch(testDir)
+       if err != nil {
+               t.Fatalf("Watcher.Watch() failed: %s", err)
+       }
+
+       // Should not be error, just no events for broken links (watching nothing)
+       if errorsReceived > 0 {
+               t.Fatal("fsnotify errors have been received.")
+       }
+
+       // Try closing the fsnotify instance
+       t.Log("calling Close()")
+       watcher.Close()
+}
+
index 107dd316ef0015a462bb5c130fec4b67f94b39bc..3561599aa198d86c04b96402a9493b33106358ca 100644 (file)
@@ -217,51 +217,6 @@ func TestFsnotifyRename(t *testing.T) {
        os.Remove(testFileRenamed)
 }
 
-func TestFsnotifyFakeSymlink(t *testing.T) {
-       // Create an fsnotify watcher instance and initialize it
-       watcher, err := NewWatcher()
-       if err != nil {
-               t.Fatalf("NewWatcher() failed: %s", err)
-       }
-
-       const testDir string = "_test"
-
-       // Create directory to watch
-       if os.Mkdir(testDir, 0777) != nil {
-               t.Fatalf("Failed to create test directory: %s", err)
-       }
-       defer os.RemoveAll(testDir)
-
-       if os.Symlink("_test/zzz", "_test/zzznew") != nil {
-               t.Fatalf("Failed to create bogus symlink: %s", err)
-       }
-       t.Logf("Created bogus symlink")
-
-       var errorsReceived = 0
-       // Receive errors on the error channel on a separate goroutine
-       go func() {
-               for errors := range watcher.Error {
-                       t.Logf("Received error: %s", errors)
-                       errorsReceived++
-               }
-       }()
-
-       // Add a watch for testDir
-       err = watcher.Watch(testDir)
-       if err != nil {
-               t.Fatalf("Watcher.Watch() failed: %s", err)
-       }
-
-       // Should not be error, just no events for broken links (watching nothing)
-       if errorsReceived > 0 {
-               t.Fatal("fsnotify errors have been received.")
-       }
-
-       // Try closing the fsnotify instance
-       t.Log("calling Close()")
-       watcher.Close()
-}
-
 func TestFsnotifyAttrib(t *testing.T) {
        // Create an fsnotify watcher instance and initialize it
        watcher, err := NewWatcher()