From e895d422e170752e6dfc1ee6c6b8074228eca9d4 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Mon, 27 May 2013 13:53:50 -0700 Subject: [PATCH] run TestReOpen with both poll = true and false this catches a bug with log rotation when using polling file watcher. --- tail_test.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tail_test.go b/tail_test.go index c6cf53b..8b7adca 100644 --- a/tail_test.go +++ b/tail_test.go @@ -80,10 +80,12 @@ func TestLocationEnd(_t *testing.T) { tail.Stop() } -func TestReOpen(_t *testing.T) { +func _TestReOpen(_t *testing.T, poll bool) { t := NewTailTest("reopen", _t) t.CreateFile("test.txt", "hello\nworld\n") - tail := t.StartTail("test.txt", Config{Follow: true, ReOpen: true, Location: -1}) + tail := t.StartTail( + "test.txt", + Config{Follow: true, ReOpen: true, Poll: poll, Location: -1}) go t.VerifyTailOutput(tail, []string{"hello", "world", "more", "data", "endofworld"}) // deletion must trigger reopen @@ -106,6 +108,16 @@ func TestReOpen(_t *testing.T) { tail.Stop() } +// The use of polling file watcher could affect file rotation +// (detected via renames), so test these explicitly. + +func TestReOpenWithPoll(_t *testing.T) { + _TestReOpen(_t, true) +} + +func TestReOpenWithoutPoll(_t *testing.T) { + _TestReOpen(_t, false) +} // Test library