Disables file deleteion in TestReSeekInotify.

This commit is contained in:
Vlad Losev 2017-03-19 17:39:19 -07:00
parent b0c08f2030
commit a294104811
No known key found for this signature in database
GPG Key ID: 3A3C3B9FAA3AB7AE
1 changed files with 20 additions and 5 deletions

View File

@ -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 {