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

server_test.go panic #27

Open
dmorn opened this issue Sep 1, 2020 · 1 comment
Open

server_test.go panic #27

dmorn opened this issue Sep 1, 2020 · 1 comment

Comments

@dmorn
Copy link

dmorn commented Sep 1, 2020

I end up here I just forked, cloned and run go test a couple of times. It looks like a message got logged after the test function returned.

styx % go test ./...
PASS
panic: Log in goroutine after TestRootQid has completed

goroutine 251 [running]:
testing.(*common).logDepth(0xc000130600, 0xc000016f40, 0x1b, 0x3)
	/usr/local/Cellar/go/1.15/libexec/src/testing/testing.go:738 +0x59f
testing.(*common).log(...)
	/usr/local/Cellar/go/1.15/libexec/src/testing/testing.go:720
testing.(*common).Logf(0xc000130600, 0x122355b, 0x19, 0xc000049630, 0x1, 0x1)
	/usr/local/Cellar/go/1.15/libexec/src/testing/testing.go:766 +0x7e
aqwari.net/net/styx.testLogger.Printf(0xc000130600, 0x122355b, 0x19, 0xc000049630, 0x1, 0x1)
	/Users/danielmorandini/src/aqwari.net/net/styx/server_test.go:30 +0x5f
aqwari.net/net/styx.(*Server).logf(...)
	/Users/danielmorandini/src/aqwari.net/net/styx/server.go:200
aqwari.net/net/styx.(*conn).serve(0xc000401140)
	/Users/danielmorandini/src/aqwari.net/net/styx/conn.go:193 +0x218
created by aqwari.net/net/styx.(*Server).Serve
	/Users/danielmorandini/src/aqwari.net/net/styx/server.go:134 +0x3a5
FAIL	aqwari.net/net/styx	0.021s
?   	aqwari.net/net/styx/internal/netutil	[no test files]
ok  	aqwari.net/net/styx/internal/pool	(cached)
ok  	aqwari.net/net/styx/internal/qidpool	(cached)
ok  	aqwari.net/net/styx/internal/styxfile	(cached)
?   	aqwari.net/net/styx/internal/sys	[no test files]
ok  	aqwari.net/net/styx/internal/threadsafe	(cached)
ok  	aqwari.net/net/styx/internal/tracing	(cached) [no tests to run]
ok  	aqwari.net/net/styx/internal/util	(cached) [no tests to run]
?   	aqwari.net/net/styx/styxauth	[no test files]
ok  	aqwari.net/net/styx/styxproto	(cached)
FAIL
@dmorn
Copy link
Author

dmorn commented Sep 1, 2020

Panic can be quickly "fixed" avoiding the t logger and using the log package, but I guess the issue is more subtle (and connected to #13, which I experienced too)

diff --git a/server_test.go b/server_test.go
index f88a461..20860b7 100644
--- a/server_test.go
+++ b/server_test.go
@@ -5,6 +5,7 @@ import (
 	"errors"
 	"fmt"
 	"io"
+	"log"
 	"os"
 	"path"
 	"sort"
@@ -22,14 +23,6 @@ const (
 	maxuint16 = 1<<16 - 1
 )
 
-type testLogger struct {
-	*testing.T
-}
-
-func (t testLogger) Printf(format string, args ...interface{}) {
-	t.Logf(format, args...)
-}
-
 type testServer struct {
 	callback func(req, rsp styxproto.Msg)
 	handler  Handler
@@ -112,7 +105,7 @@ func chanServer(t *testing.T, handler Handler) (in, out chan styxproto.Msg) {
 	// last for one session
 	srv := Server{
 		Handler:  handler,
-		ErrorLog: testLogger{t},
+		ErrorLog: log.New(os.Stderr, "", 0),
 	}
 	go srv.Serve(&ln)
 	conn, err := ln.Dial()

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

No branches or pull requests

1 participant