git » chasquid » commit d570372

localrpc test: Don't call t.Fatal from a goroutine

author Alberto Bertogli
2023-10-03 22:30:17 UTC
committer Alberto Bertogli
2023-10-03 22:32:30 UTC
parent 74e7c960310ce307ef5ac6505d6526308bda6678

localrpc test: Don't call t.Fatal from a goroutine

The testing package does not allow t.Fatal to be called from a different
goroutine; however, we do that if the testing server fails listen or
accept connections.

Since that is unexpected and rare, this patch turns those calls into
panics.

internal/localrpc/client_test.go +2 -2

diff --git a/internal/localrpc/client_test.go b/internal/localrpc/client_test.go
index 055bccb..e704a52 100644
--- a/internal/localrpc/client_test.go
+++ b/internal/localrpc/client_test.go
@@ -15,13 +15,13 @@ func NewFakeServer(t *testing.T, path, output string) {
 	t.Helper()
 	lis, err := net.Listen("unix", path)
 	if err != nil {
-		t.Fatal(err)
+		panic(err)
 	}
 
 	for {
 		conn, err := lis.Accept()
 		if err != nil {
-			t.Fatal(err)
+			panic(err)
 		}
 		t.Logf("FakeServer %v: accepted ", conn)