From: Chris Howey Date: Sat, 28 Apr 2012 16:21:04 +0000 (-0500) Subject: Windows - No Symlinks X-Git-Tag: v1.7.2~431 X-Git-Url: https://go.fuhry.dev/?a=commitdiff_plain;h=75c704b02d7b2fd73ec162067cf2c1c217d0a884;p=fsnotify.git Windows - No Symlinks --- diff --git a/fsnotify_symlink_test.go b/fsnotify_symlink_test.go new file mode 100644 index 0000000..f6899a7 --- /dev/null +++ b/fsnotify_symlink_test.go @@ -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() +} + diff --git a/fsnotify_test.go b/fsnotify_test.go index 107dd31..3561599 100644 --- a/fsnotify_test.go +++ b/fsnotify_test.go @@ -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()