Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix go vet warnings: call to (*T).Fatalf from a non-test goroutine #416

Merged
merged 1 commit into from Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion inotify_poller_test.go
Expand Up @@ -179,7 +179,7 @@ func TestPollerConcurrent(t *testing.T) {
for {
ok, err := poller.wait()
if err != nil {
t.Fatalf("poller failed: %v", err)
t.Errorf("poller failed: %v", err)
}
oks <- ok
if !<-live {
Expand Down Expand Up @@ -227,4 +227,8 @@ func TestPollerConcurrent(t *testing.T) {
t.Fatalf("expected true")
}
tfd.get(t)

// wait for all goroutines for finish.
live <- false
<-oks
}
9 changes: 7 additions & 2 deletions inotify_test.go
Expand Up @@ -330,15 +330,17 @@ func TestInotifyInnerMapLength(t *testing.T) {
if err != nil {
t.Fatalf("Failed to create watcher: %v", err)
}
defer w.Close()

err = w.Add(testFile)
if err != nil {
t.Fatalf("Failed to add testFile: %v", err)
}
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
for err := range w.Errors {
t.Fatalf("error received: %s", err)
t.Errorf("error received: %s", err)
}
}()

Expand All @@ -357,6 +359,9 @@ func TestInotifyInnerMapLength(t *testing.T) {
if len(w.paths) != 0 {
t.Fatalf("Expected paths len is 0, but got: %d, %v", len(w.paths), w.paths)
}

w.Close()
wg.Wait()
}

func TestInotifyOverflow(t *testing.T) {
Expand Down
18 changes: 15 additions & 3 deletions integration_test.go
Expand Up @@ -14,6 +14,7 @@ import (
"path"
"path/filepath"
"runtime"
"sync"
"sync/atomic"
"testing"
"time"
Expand Down Expand Up @@ -75,9 +76,12 @@ func TestFsnotifyMultipleOperations(t *testing.T) {
watcher := newWatcher(t)

// Receive errors on the error channel on a separate goroutine
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
for err := range watcher.Errors {
t.Fatalf("error received: %s", err)
t.Errorf("error received: %s", err)
}
}()

Expand Down Expand Up @@ -187,6 +191,9 @@ func TestFsnotifyMultipleOperations(t *testing.T) {
case <-time.After(2 * time.Second):
t.Fatal("event stream was not closed after 2 seconds")
}

// wait for all groutines to finish.
wg.Wait()
}

func TestFsnotifyMultipleCreates(t *testing.T) {
Expand Down Expand Up @@ -837,10 +844,13 @@ func TestRemovalOfWatch(t *testing.T) {
t.Fatalf("Could not remove the watch: %v\n", err)
}

var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
select {
case ev := <-watcher.Events:
t.Fatalf("We received event: %v\n", ev)
t.Errorf("We received event: %v\n", ev)
case <-time.After(500 * time.Millisecond):
t.Log("No event received, as expected.")
}
Expand All @@ -858,7 +868,9 @@ func TestRemovalOfWatch(t *testing.T) {
if err := os.Chmod(testFileAlreadyExists, 0700); err != nil {
t.Fatalf("chmod failed: %s", err)
}
time.Sleep(400 * time.Millisecond)

// wait for all groutines to finish.
wg.Wait()
}

func TestFsnotifyAttrib(t *testing.T) {
Expand Down