Skip to content

tests: report errors from goroutines with t.Error, as go vet requires - #25

Open
louisabraham wants to merge 1 commit into
go-llsqlite:masterfrom
conception-ai:vet-blob-test
Open

louisabraham wants to merge 1 commit into
go-llsqlite:masterfrom
conception-ai:vet-blob-test

Conversation

@louisabraham

Copy link
Copy Markdown

go vet ./... reports four calls to t.Fatal/t.Fatalf from a goroutine other than the test's:

sqlitex/savepoint_test.go:350:4: call to (*testing.T).Fatalf from a non-test goroutine
sqlitex/pool_test.go:202:4: call to (*testing.T).Fatal from a non-test goroutine
blob_test.go:218:5: call to (*testing.T).Fatal from a non-test goroutine
blob_test.go:237:6: call to (*testing.T).Fatalf from a non-test goroutine

t.Fatal calls runtime.Goexit, which only stops the goroutine that calls it. From another goroutine it does not stop the test, and testing documents that it must not be called there. Each call is replaced with t.Error/t.Errorf, followed by return where the goroutine must stop.

In pool_test.go, the goroutine still closes done after a failed Step. Before this change, a failure there skipped close(done).

Checked: go vet ./... reports nothing, and go test -race ./... passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant