1
0
mirror of https://github.com/golang/go synced 2024-11-12 04:00:23 -07:00

net/http: deflake TestInterruptWithPanic_nil_h2, again

Updates #17243

Change-Id: Iaa737874e75fdac73452f1fc13a5749e8df78ebe
Reviewed-on: https://go-review.googlesource.com/33332
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Brad Fitzpatrick 2016-11-16 23:41:15 +00:00
parent 14e9f4825b
commit 48858a2386

View File

@ -1177,10 +1177,19 @@ func testInterruptWithPanic(t *testing.T, h2 bool, panicValue interface{}) {
const msg = "hello"
defer afterTest(t)
testDone := make(chan struct{})
defer close(testDone)
var errorLog lockedBytesBuffer
gotHeaders := make(chan bool, 1)
cst := newClientServerTest(t, h2, HandlerFunc(func(w ResponseWriter, r *Request) {
io.WriteString(w, msg)
w.(Flusher).Flush()
select {
case <-gotHeaders:
case <-testDone:
}
panic(panicValue)
}), func(ts *httptest.Server) {
ts.Config.ErrorLog = log.New(&errorLog, "", 0)
@ -1190,6 +1199,7 @@ func testInterruptWithPanic(t *testing.T, h2 bool, panicValue interface{}) {
if err != nil {
t.Fatal(err)
}
gotHeaders <- true
defer res.Body.Close()
slurp, err := ioutil.ReadAll(res.Body)
if string(slurp) != msg {