]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: add mechanism for marking flaky http tests
authorBrad Fitzpatrick <bradfitz@golang.org>
Wed, 6 Jan 2016 19:19:39 +0000 (19:19 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 6 Jan 2016 21:00:48 +0000 (21:00 +0000)
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/18286
Reviewed-by: Russ Cox <rsc@golang.org>
src/net/http/main_test.go
src/net/http/transport_test.go

index 1163874ac2214756ecacbd7e2fdcec9609cd3eb6..299cd7b2d2f231c9b5ef75b964d23f595528d8fb 100644 (file)
@@ -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() {
index faac72085d0c1708e65f900cef951da58d54692e..9b4802f2aa87b67309b4bdb577ac2eda6abb9f40 100644 (file)
@@ -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)