1
0
mirror of https://github.com/golang/go synced 2024-11-13 19:00:25 -07:00

net: don't miss testing server teardowns when test fails early

Change-Id: I9fa678e43b4ae3970323cac474b5f86d4d933997
Reviewed-on: https://go-review.googlesource.com/9382
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Mikio Hara 2015-04-26 07:52:28 +09:00
parent 8a413752fb
commit 9bef5cfb9b

View File

@ -69,6 +69,11 @@ func TestTCPServer(t *testing.T) {
var lss []*localServer
var tpchs []chan error
defer func() {
for _, ls := range lss {
ls.teardown()
}
}()
for i := 0; i < N; i++ {
ls, err := (&streamListener{Listener: ln}).newLocalServer()
if err != nil {
@ -77,11 +82,6 @@ func TestTCPServer(t *testing.T) {
lss = append(lss, ls)
tpchs = append(tpchs, make(chan error, 1))
}
defer func() {
for _, ls := range lss {
ls.teardown()
}
}()
for i := 0; i < N; i++ {
ch := tpchs[i]
handler := func(ls *localServer, ln Listener) { transponder(ln, ch) }
@ -153,6 +153,11 @@ func TestUnixAndUnixpacketServer(t *testing.T) {
var lss []*localServer
var tpchs []chan error
defer func() {
for _, ls := range lss {
ls.teardown()
}
}()
for i := 0; i < N; i++ {
ls, err := (&streamListener{Listener: ln}).newLocalServer()
if err != nil {
@ -161,11 +166,6 @@ func TestUnixAndUnixpacketServer(t *testing.T) {
lss = append(lss, ls)
tpchs = append(tpchs, make(chan error, 1))
}
defer func() {
for _, ls := range lss {
ls.teardown()
}
}()
for i := 0; i < N; i++ {
ch := tpchs[i]
handler := func(ls *localServer, ln Listener) { transponder(ln, ch) }