MCPcopy Create free account
hub / github.com/hpcloud/tail / reOpen

Function reOpen

tail_test.go:330–370  ·  view source on GitHub ↗
(t *testing.T, poll bool)

Source from the content-addressed store, hash-verified

328}
329
330func reOpen(t *testing.T, poll bool) {
331 var name string
332 var delay time.Duration
333 if poll {
334 name = "reopen-polling"
335 delay = 300 * time.Millisecond // account for POLL_DURATION
336 } else {
337 name = "reopen-inotify"
338 delay = 100 * time.Millisecond
339 }
340 tailTest := NewTailTest(name, t)
341 tailTest.CreateFile("test.txt", "hello\nworld\n")
342 tail := tailTest.StartTail(
343 "test.txt",
344 Config{Follow: true, ReOpen: true, Poll: poll})
345 content := []string{"hello", "world", "more", "data", "endofworld"}
346 go tailTest.ReadLines(tail, content)
347
348 // deletion must trigger reopen
349 <-time.After(delay)
350 tailTest.RemoveFile("test.txt")
351 <-time.After(delay)
352 tailTest.CreateFile("test.txt", "more\ndata\n")
353
354 // rename must trigger reopen
355 <-time.After(delay)
356 tailTest.RenameFile("test.txt", "test.txt.rotated")
357 <-time.After(delay)
358 tailTest.CreateFile("test.txt", "endofworld\n")
359
360 // Delete after a reasonable delay, to give tail sufficient time
361 // to read all lines.
362 <-time.After(delay)
363 tailTest.RemoveFile("test.txt")
364 <-time.After(delay)
365
366 // Do not bother with stopping as it could kill the tomb during
367 // the reading of data written above. Timings can vary based on
368 // test environment.
369 tail.Cleanup()
370}
371
372func reSeek(t *testing.T, poll bool) {
373 var name string

Callers 2

TestReOpenInotifyFunction · 0.85
TestReOpenPollingFunction · 0.85

Calls 7

CreateFileMethod · 0.95
StartTailMethod · 0.95
ReadLinesMethod · 0.95
RemoveFileMethod · 0.95
RenameFileMethod · 0.95
NewTailTestFunction · 0.85
CleanupMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…