From a294104811bb5efe83fb0a3ef3411979693287e4 Mon Sep 17 00:00:00 2001 From: Vlad Losev Date: Sun, 19 Mar 2017 17:39:19 -0700 Subject: [PATCH] Disables file deleteion in TestReSeekInotify. --- tail_test.go | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/tail_test.go b/tail_test.go index e29da4b..82b1665 100644 --- a/tail_test.go +++ b/tail_test.go @@ -345,11 +345,19 @@ func reOpen(t *testing.T, poll bool) { content := []string{"hello", "world", "more", "data", "endofworld"} go tailTest.VerifyTailOutput(tail, content, false) - // deletion must trigger reopen - <-time.After(delay) - tailTest.RemoveFile("test.txt") - <-time.After(delay) - tailTest.CreateFile("test.txt", "more\ndata\n") + if poll { + // deletion must trigger reopen + <-time.After(delay) + tailTest.RemoveFile("test.txt") + <-time.After(delay) + tailTest.CreateFile("test.txt", "more\ndata\n") + } else { + // In inotify mode, fsnotify is currently unable to deliver notifications + // about deletion of open files, so we are not testing file deletion. + // (see https://github.com/fsnotify/fsnotify/issues/194 for details). + <-time.After(delay) + tailTest.AppendToFile("test.txt", "more\ndata\n") + } // rename must trigger reopen <-time.After(delay) @@ -426,6 +434,13 @@ func (t TailTest) CreateFile(name string, contents string) { } } +func (t TailTest) AppendToFile(name string, contents string) { + err := ioutil.WriteFile(t.path+"/"+name, []byte(contents), 0600|os.ModeAppend) + if err != nil { + t.Fatal(err) + } +} + func (t TailTest) RemoveFile(name string) { err := os.Remove(t.path + "/" + name) if err != nil {