Fixes race in test

- Enabled race flag in the make file to alway run with -race locally
- Moved polling interval into TestMain to avoid race
This commit is contained in:
Nino Khodabandeh 2016-04-08 11:47:25 -07:00
parent 08067f95ff
commit b58ee27c66
2 changed files with 8 additions and 5 deletions

View File

@ -1,7 +1,7 @@
default: test
test: *.go
go test -v ./...
go test -v -race ./...
fmt:
gofmt -w .

View File

@ -25,6 +25,13 @@ func init() {
}
}
func TestMain(m *testing.M) {
// Use a smaller poll duration for faster test runs. Keep it below
// 100ms (which value is used as common delays for tests)
watch.POLL_DURATION = 5 * time.Millisecond
os.Exit(m.Run())
}
func TestMustExist(t *testing.T) {
tail, err := TailFile("/no/such/file", Config{Follow: true, MustExist: true})
if err == nil {
@ -387,10 +394,6 @@ func NewTailTest(name string, t *testing.T) TailTest {
tt.Fatal(err)
}
// Use a smaller poll duration for faster test runs. Keep it below
// 100ms (which value is used as common delays for tests)
watch.POLL_DURATION = 5 * time.Millisecond
return tt
}