fix race in test setup/teardown

not easily triggered, but it happened just now on a build server.
This commit is contained in:
Mechiel Lukkien
2023-08-07 23:14:31 +02:00
parent 849b4ec9e9
commit 49cf16d3f2
15 changed files with 29 additions and 36 deletions

View File

@ -346,11 +346,9 @@ func startArgs(t *testing.T, first, isTLS, allowLoginWithoutTLS bool) *testconn
err = acc.SetPassword("testtest")
tcheck(t, err, "set password")
}
var switchDone chan struct{}
switchStop := func() {}
if first {
switchDone = store.Switchboard()
} else {
switchDone = make(chan struct{}) // Dummy, that can be closed.
switchStop = store.Switchboard()
}
serverConn, clientConn := net.Pipe()
@ -368,7 +366,7 @@ func startArgs(t *testing.T, first, isTLS, allowLoginWithoutTLS bool) *testconn
cid := connCounter
go func() {
serve("test", cid, tlsConfig, serverConn, isTLS, allowLoginWithoutTLS)
close(switchDone)
switchStop()
close(done)
}()
client, err := imapclient.New(clientConn, true)