1
0
mirror of https://github.com/golang/go synced 2024-09-30 10:18:32 -06:00

net: convert TestTCPServer to use subtests

My fix in CL 202618 inadvertently violated an invariant in the inner
loop of TestTCPServer (namely, that len(trchs) == i). That causes a
panic when one or more of the channels is omitted due to a flake.

Instead of trying to fix up the test, let's just factor out a subtest
and skip the whole thing if the transceiver's Dial flakes out.

Updates #32919

Change-Id: Ib6f274a44194311c8c5a2faf19f586cc9eccfd4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/202561
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Bryan C. Mills 2019-10-22 12:44:44 -04:00
parent 51504f0a2d
commit 22278ca0d4

View File

@ -56,9 +56,9 @@ func TestTCPServer(t *testing.T) {
const N = 3 const N = 3
for i, tt := range tcpServerTests { for i, tt := range tcpServerTests {
t.Run(tt.snet+" "+tt.saddr+"<-"+tt.taddr, func(t *testing.T) {
if !testableListenArgs(tt.snet, tt.saddr, tt.taddr) { if !testableListenArgs(tt.snet, tt.saddr, tt.taddr) {
t.Logf("skipping %s test", tt.snet+" "+tt.saddr+"<-"+tt.taddr) t.Skip("not testable")
continue
} }
ln, err := Listen(tt.snet, tt.saddr) ln, err := Listen(tt.snet, tt.saddr)
@ -109,8 +109,7 @@ func TestTCPServer(t *testing.T) {
// "i/o timeout" errors when dialing address ::1. The errors have not // "i/o timeout" errors when dialing address ::1. The errors have not
// been observed on newer versions of the OS, so we don't plan to work // been observed on newer versions of the OS, so we don't plan to work
// around them. See https://golang.org/issue/32919. // around them. See https://golang.org/issue/32919.
t.Logf("ignoring error on known-flaky macOS 10.12 builder: %v", err) t.Skipf("skipping due to error on known-flaky macOS 10.12 builder: %v", err)
continue
} }
t.Fatal(err) t.Fatal(err)
} }
@ -129,6 +128,7 @@ func TestTCPServer(t *testing.T) {
t.Errorf("#%d: %v", i, err) t.Errorf("#%d: %v", i, err)
} }
} }
})
} }
} }