Commit af768fdd authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

net/http: add mechanism for marking flaky http tests

This shouldn't need to exist in general, but in practice I want something
like this a few times per year.

Change-Id: I9c220e58be44b7726f75d776f714212c570cf8bb
Reviewed-on: https://go-review.googlesource.com/18286Reviewed-by: default avatarRuss Cox <rsc@golang.org>
parent 4391aca8
......@@ -5,6 +5,7 @@
package http_test
import (
"flag"
"fmt"
"net/http"
"os"
......@@ -15,6 +16,8 @@ import (
"time"
)
var flaky = flag.Bool("flaky", false, "run known-flaky tests too")
func TestMain(m *testing.M) {
v := m.Run()
if v == 0 && goroutineLeaked() {
......@@ -88,6 +91,12 @@ func setParallel(t *testing.T) {
}
}
func setFlaky(t *testing.T, issue int) {
if !*flaky {
t.Skipf("skipping known flaky test; see golang.org/issue/%d", issue)
}
}
func afterTest(t testing.TB) {
http.DefaultTransport.(*http.Transport).CloseIdleConnections()
if testing.Short() {
......
......@@ -1649,7 +1649,7 @@ func TestCancelRequestWithChannelBeforeDo(t *testing.T) {
// Issue 11020. The returned error message should be errRequestCanceled
func TestTransportCancelBeforeResponseHeaders(t *testing.T) {
t.Skip("Skipping flaky test; see Issue 11894")
setFlaky(t, 11894)
defer afterTest(t)
serverConnCh := make(chan net.Conn, 1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment