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:
parent
08067f95ff
commit
b58ee27c66
2
Makefile
2
Makefile
|
@ -1,7 +1,7 @@
|
||||||
default: test
|
default: test
|
||||||
|
|
||||||
test: *.go
|
test: *.go
|
||||||
go test -v ./...
|
go test -v -race ./...
|
||||||
|
|
||||||
fmt:
|
fmt:
|
||||||
gofmt -w .
|
gofmt -w .
|
||||||
|
|
11
tail_test.go
11
tail_test.go
|
@ -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) {
|
func TestMustExist(t *testing.T) {
|
||||||
tail, err := TailFile("/no/such/file", Config{Follow: true, MustExist: true})
|
tail, err := TailFile("/no/such/file", Config{Follow: true, MustExist: true})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -387,10 +394,6 @@ func NewTailTest(name string, t *testing.T) TailTest {
|
||||||
tt.Fatal(err)
|
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
|
return tt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue