Flaky tests are a distraction and cover up real problems.
File bugs instead and mark them as flaky.
This moves the net/http flaky test flagging mechanism to internal/testenv.
Updates #15156
Updates #15157
Updates #15158
Change-Id: I0e561cd2a09c0dec369cd4ed93bc5a2b40233dfe
Reviewed-on: https://go-review.googlesource.com/21614
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
import (
"fmt"
+ "internal/testenv"
"math/rand"
"runtime"
"strings"
}
func TestTimeout(t *testing.T) {
+ if runtime.GOOS == "openbsd" {
+ testenv.SkipFlaky(t, 15158)
+ }
c, _ := WithTimeout(Background(), 100*time.Millisecond)
if got, prefix := fmt.Sprint(c), "context.Background.WithDeadline("; !strings.HasPrefix(got, prefix) {
t.Errorf("c.String() = %q want prefix %q", got, prefix)
"testing": {"L2", "flag", "fmt", "os", "runtime/debug", "runtime/pprof", "runtime/trace", "time"},
"testing/iotest": {"L2", "log"},
"testing/quick": {"L2", "flag", "fmt", "reflect"},
- "internal/testenv": {"L2", "OS", "testing"},
+ "internal/testenv": {"L2", "OS", "flag", "testing"},
// L4 is defined as L3+fmt+log+time, because in general once
// you're using L3 packages, use of fmt, log, or time is not a big deal.
package testenv
import (
+ "flag"
"os"
"os/exec"
"path/filepath"
t.Skipf("skipping test: no external network in -short mode")
}
}
+
+var flaky = flag.Bool("flaky", false, "run known-flaky tests too")
+
+func SkipFlaky(t *testing.T, issue int) {
+ if !*flaky {
+ t.Skipf("skipping known flaky test without the -flaky flag; see golang.org/issue/%d", issue)
+ }
+}
switch runtime.GOOS {
case "plan9":
t.Skipf("%s does not have full support of socktest", runtime.GOOS)
+ case "openbsd":
+ testenv.SkipFlaky(t, 15157)
}
const T = 100 * time.Millisecond
t.Skipf("%s does not have full support of socktest", runtime.GOOS)
case "windows":
t.Skipf("not implemented a way to cancel dial racers in TCP SYN-SENT state on %s", runtime.GOOS)
+ case "openbsd":
+ testenv.SkipFlaky(t, 15157)
}
if !supportsIPv4 || !supportsIPv6 {
t.Skip("both IPv4 and IPv6 are required")
package http_test
import (
- "flag"
"fmt"
"net/http"
"os"
"time"
)
-var flaky = flag.Bool("flaky", false, "run known-flaky tests too")
-
func TestMain(m *testing.M) {
v := m.Run()
if v == 0 && goroutineLeaked() {
}
}
-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() {
"crypto/tls"
"errors"
"fmt"
+ "internal/testenv"
"io"
"io/ioutil"
"log"
// Trying to repro golang.org/issue/3514
func TestTLSServerClosesConnection(t *testing.T) {
defer afterTest(t)
- setFlaky(t, 7634)
+ testenv.SkipFlaky(t, 7634)
closedc := make(chan bool, 1)
ts := httptest.NewTLSServer(HandlerFunc(func(w ResponseWriter, r *Request) {
import (
"fmt"
+ "internal/testenv"
"io"
"io/ioutil"
"net/internal/socktest"
func TestDialTimeoutMaxDuration(t *testing.T) {
t.Parallel()
+ if runtime.GOOS == "openbsd" {
+ testenv.SkipFlaky(t, 15157)
+ }
ln, err := newLocalListener("tcp")
if err != nil {
import (
"bytes"
+ "internal/testenv"
"os"
"reflect"
"runtime"
if !testableNetwork("unixgram") {
t.Skip("unixgram test")
}
+ if runtime.GOOS == "openbsd" {
+ testenv.SkipFlaky(t, 15157)
+ }
addr := testUnixAddr()
la, err := ResolveUnixAddr("unixgram", addr)
func func4(c chan int) { <-c }
func TestGoroutineCounts(t *testing.T) {
+ if runtime.GOOS == "openbsd" {
+ testenv.SkipFlaky(t, 15156)
+ }
c := make(chan int)
for i := 0; i < 100; i++ {
if i%10 == 0 {