Commit 0ce55b63 authored by Hiroshi Ioka's avatar Hiroshi Ioka Committed by Ian Lance Taylor

internal/testenv: take testing.TB instead of *testing.T in MustHave* and SkipFlaky*

Change-Id: I16475e9bb055b934302870ccb5136174dc3bc817
Reviewed-on: https://go-review.googlesource.com/64670
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 1787ced8
...@@ -47,7 +47,7 @@ func HasGoBuild() bool { ...@@ -47,7 +47,7 @@ func HasGoBuild() bool {
// MustHaveGoBuild checks that the current system can build programs with ``go build'' // MustHaveGoBuild checks that the current system can build programs with ``go build''
// and then run them with os.StartProcess or exec.Command. // and then run them with os.StartProcess or exec.Command.
// If not, MustHaveGoBuild calls t.Skip with an explanation. // If not, MustHaveGoBuild calls t.Skip with an explanation.
func MustHaveGoBuild(t *testing.T) { func MustHaveGoBuild(t testing.TB) {
if !HasGoBuild() { if !HasGoBuild() {
t.Skipf("skipping test: 'go build' not available on %s/%s", runtime.GOOS, runtime.GOARCH) t.Skipf("skipping test: 'go build' not available on %s/%s", runtime.GOOS, runtime.GOARCH)
} }
...@@ -61,7 +61,7 @@ func HasGoRun() bool { ...@@ -61,7 +61,7 @@ func HasGoRun() bool {
// MustHaveGoRun checks that the current system can run programs with ``go run.'' // MustHaveGoRun checks that the current system can run programs with ``go run.''
// If not, MustHaveGoRun calls t.Skip with an explanation. // If not, MustHaveGoRun calls t.Skip with an explanation.
func MustHaveGoRun(t *testing.T) { func MustHaveGoRun(t testing.TB) {
if !HasGoRun() { if !HasGoRun() {
t.Skipf("skipping test: 'go run' not available on %s/%s", runtime.GOOS, runtime.GOARCH) t.Skipf("skipping test: 'go run' not available on %s/%s", runtime.GOOS, runtime.GOARCH)
} }
...@@ -71,7 +71,7 @@ func MustHaveGoRun(t *testing.T) { ...@@ -71,7 +71,7 @@ func MustHaveGoRun(t *testing.T) {
// It is a convenience wrapper around GoTool. // It is a convenience wrapper around GoTool.
// If the tool is unavailable GoToolPath calls t.Skip. // If the tool is unavailable GoToolPath calls t.Skip.
// If the tool should be available and isn't, GoToolPath calls t.Fatal. // If the tool should be available and isn't, GoToolPath calls t.Fatal.
func GoToolPath(t *testing.T) string { func GoToolPath(t testing.TB) string {
MustHaveGoBuild(t) MustHaveGoBuild(t)
path, err := GoTool() path, err := GoTool()
if err != nil { if err != nil {
...@@ -130,7 +130,7 @@ func HasSrc() bool { ...@@ -130,7 +130,7 @@ func HasSrc() bool {
// MustHaveExec checks that the current system can start new processes // MustHaveExec checks that the current system can start new processes
// using os.StartProcess or (more commonly) exec.Command. // using os.StartProcess or (more commonly) exec.Command.
// If not, MustHaveExec calls t.Skip with an explanation. // If not, MustHaveExec calls t.Skip with an explanation.
func MustHaveExec(t *testing.T) { func MustHaveExec(t testing.TB) {
if !HasExec() { if !HasExec() {
t.Skipf("skipping test: cannot exec subprocess on %s/%s", runtime.GOOS, runtime.GOARCH) t.Skipf("skipping test: cannot exec subprocess on %s/%s", runtime.GOOS, runtime.GOARCH)
} }
...@@ -145,7 +145,7 @@ func HasExternalNetwork() bool { ...@@ -145,7 +145,7 @@ func HasExternalNetwork() bool {
// MustHaveExternalNetwork checks that the current system can use // MustHaveExternalNetwork checks that the current system can use
// external (non-localhost) networks. // external (non-localhost) networks.
// If not, MustHaveExternalNetwork calls t.Skip with an explanation. // If not, MustHaveExternalNetwork calls t.Skip with an explanation.
func MustHaveExternalNetwork(t *testing.T) { func MustHaveExternalNetwork(t testing.TB) {
if testing.Short() { if testing.Short() {
t.Skipf("skipping test: no external network in -short mode") t.Skipf("skipping test: no external network in -short mode")
} }
...@@ -159,7 +159,7 @@ func HasCGO() bool { ...@@ -159,7 +159,7 @@ func HasCGO() bool {
} }
// MustHaveCGO calls t.Skip if cgo is not available. // MustHaveCGO calls t.Skip if cgo is not available.
func MustHaveCGO(t *testing.T) { func MustHaveCGO(t testing.TB) {
if !haveCGO { if !haveCGO {
t.Skipf("skipping test: no cgo") t.Skipf("skipping test: no cgo")
} }
...@@ -173,7 +173,7 @@ func HasSymlink() bool { ...@@ -173,7 +173,7 @@ func HasSymlink() bool {
// MustHaveSymlink reports whether the current system can use os.Symlink. // MustHaveSymlink reports whether the current system can use os.Symlink.
// If not, MustHaveSymlink calls t.Skip with an explanation. // If not, MustHaveSymlink calls t.Skip with an explanation.
func MustHaveSymlink(t *testing.T) { func MustHaveSymlink(t testing.TB) {
ok, reason := hasSymlink() ok, reason := hasSymlink()
if !ok { if !ok {
t.Skipf("skipping test: cannot make symlinks on %s/%s%s", runtime.GOOS, runtime.GOARCH, reason) t.Skipf("skipping test: cannot make symlinks on %s/%s%s", runtime.GOOS, runtime.GOARCH, reason)
...@@ -190,7 +190,7 @@ func HasLink() bool { ...@@ -190,7 +190,7 @@ func HasLink() bool {
// MustHaveLink reports whether the current system can use os.Link. // MustHaveLink reports whether the current system can use os.Link.
// If not, MustHaveLink calls t.Skip with an explanation. // If not, MustHaveLink calls t.Skip with an explanation.
func MustHaveLink(t *testing.T) { func MustHaveLink(t testing.TB) {
if !HasLink() { if !HasLink() {
t.Skipf("skipping test: hardlinks are not supported on %s/%s", runtime.GOOS, runtime.GOARCH) t.Skipf("skipping test: hardlinks are not supported on %s/%s", runtime.GOOS, runtime.GOARCH)
} }
...@@ -198,13 +198,13 @@ func MustHaveLink(t *testing.T) { ...@@ -198,13 +198,13 @@ func MustHaveLink(t *testing.T) {
var flaky = flag.Bool("flaky", false, "run known-flaky tests too") var flaky = flag.Bool("flaky", false, "run known-flaky tests too")
func SkipFlaky(t *testing.T, issue int) { func SkipFlaky(t testing.TB, issue int) {
if !*flaky { if !*flaky {
t.Skipf("skipping known flaky test without the -flaky flag; see golang.org/issue/%d", issue) t.Skipf("skipping known flaky test without the -flaky flag; see golang.org/issue/%d", issue)
} }
} }
func SkipFlakyNet(t *testing.T) { func SkipFlakyNet(t testing.TB) {
if v, _ := strconv.ParseBool(os.Getenv("GO_BUILDER_FLAKY_NET")); v { if v, _ := strconv.ParseBool(os.Getenv("GO_BUILDER_FLAKY_NET")); v {
t.Skip("skipping test on builder known to have frequent network failures") t.Skip("skipping test on builder known to have frequent network failures")
} }
......
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