diff options
author | Yuri Tkachenko <yuri.tam.tkachenko@gmail.com> | 2015-11-30 12:15:28 +0300 |
---|---|---|
committer | Yuri Tkachenko <yuri.tam.tkachenko@gmail.com> | 2015-11-30 12:15:28 +0300 |
commit | 8b982f7effa336a503ab61c676ee0f2473de6e3b (patch) | |
tree | ecd49a12e3cb9e4bff398057df01d44eade70da4 /Godeps/_workspace/src/gopkg.in/fsnotify.v1/integration_test.go | |
parent | 71b548ef052d4e84ea0d067df51e4850ffdba572 (diff) | |
parent | d4eb8743e3bd36b6cd2e7939c9a698d893b215d7 (diff) | |
download | chat-8b982f7effa336a503ab61c676ee0f2473de6e3b.tar.gz chat-8b982f7effa336a503ab61c676ee0f2473de6e3b.tar.bz2 chat-8b982f7effa336a503ab61c676ee0f2473de6e3b.zip |
Merge remote-tracking branch 'mattermost/master' into patch-1
Diffstat (limited to 'Godeps/_workspace/src/gopkg.in/fsnotify.v1/integration_test.go')
-rw-r--r-- | Godeps/_workspace/src/gopkg.in/fsnotify.v1/integration_test.go | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/gopkg.in/fsnotify.v1/integration_test.go b/Godeps/_workspace/src/gopkg.in/fsnotify.v1/integration_test.go index 59169c6af..49e48ff1c 100644 --- a/Godeps/_workspace/src/gopkg.in/fsnotify.v1/integration_test.go +++ b/Godeps/_workspace/src/gopkg.in/fsnotify.v1/integration_test.go @@ -10,6 +10,7 @@ import ( "io/ioutil" "os" "os/exec" + "path" "path/filepath" "runtime" "sync/atomic" @@ -1065,6 +1066,53 @@ func TestFsnotifyFakeSymlink(t *testing.T) { watcher.Close() } +func TestCyclicSymlink(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("symlinks don't work on Windows.") + } + + watcher := newWatcher(t) + + testDir := tempMkdir(t) + defer os.RemoveAll(testDir) + + link := path.Join(testDir, "link") + if err := os.Symlink(".", link); err != nil { + t.Fatalf("could not make symlink: %v", err) + } + addWatch(t, watcher, testDir) + + var createEventsReceived counter + go func() { + for ev := range watcher.Events { + if ev.Op&Create == Create { + createEventsReceived.increment() + } + } + }() + + if err := os.Remove(link); err != nil { + t.Fatalf("Error removing link: %v", err) + } + + // It would be nice to be able to expect a delete event here, but kqueue has + // no way for us to get events on symlinks themselves, because opening them + // opens an fd to the file to which they point. + + if err := ioutil.WriteFile(link, []byte("foo"), 0700); err != nil { + t.Fatalf("could not make symlink: %v", err) + } + + // We expect this event to be received almost immediately, but let's wait 500 ms to be sure + time.Sleep(500 * time.Millisecond) + + if got := createEventsReceived.value(); got == 0 { + t.Errorf("want at least 1 create event got %v", got) + } + + watcher.Close() +} + // TestConcurrentRemovalOfWatch tests that concurrent calls to RemoveWatch do not race. // See https://codereview.appspot.com/103300045/ // go test -test.run=TestConcurrentRemovalOfWatch -test.cpu=1,1,1,1,1 -race |