all: skip more memory-intensive tests on linux-arm

Updates golang/go#32834

Change-Id: I9844dc09d9a6eb2e79a0b28a1e69ed018bfa1bff
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192578
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Bryan C. Mills 2019-08-30 12:02:01 -04:00
parent df13fa7beb
commit 311ec0312e
8 changed files with 44 additions and 16 deletions

View File

@ -23,6 +23,11 @@ import (
"golang.org/x/tools/internal/testenv"
)
func TestMain(m *testing.M) {
testenv.ExitIfSmallMachine()
os.Exit(m.Run())
}
// ----------------------------------------------------------------------------
// The following three functions (Builder, HasGoBuild, MustHaveGoBuild) were
// copied from $GOROOT/src/internal/testenv since that package is not available

View File

@ -13,6 +13,7 @@ import (
"go/build"
"go/constant"
"go/types"
"os"
"path/filepath"
"reflect"
"runtime"
@ -23,8 +24,14 @@ import (
"golang.org/x/tools/go/buildutil"
"golang.org/x/tools/go/loader"
"golang.org/x/tools/internal/testenv"
)
func TestMain(m *testing.M) {
testenv.ExitIfSmallMachine()
os.Exit(m.Run())
}
// TestFromArgs checks that conf.FromArgs populates conf correctly.
// It does no I/O.
func TestFromArgs(t *testing.T) {

View File

@ -28,11 +28,7 @@ import (
)
func TestMain(m *testing.M) {
if os.Getenv("GO_BUILDER_NAME") == "linux-arm" {
fmt.Fprintf(os.Stderr, "skipping test: linux-arm builder lacks sufficient memory (https://golang.org/issue/32834)\n")
os.Exit(0)
}
testenv.ExitIfSmallMachine()
os.Exit(m.Run())
}

View File

@ -2,9 +2,17 @@ package imports
import (
"go/build"
"os"
"testing"
"golang.org/x/tools/internal/testenv"
)
func TestMain(m *testing.M) {
testenv.ExitIfSmallMachine()
os.Exit(m.Run())
}
// TestNilOpts tests that process does not crash with nil opts.
func TestNilOpts(t *testing.T) {
var testOpts = []struct {

View File

@ -7,7 +7,6 @@ package cmd_test
import (
"bytes"
"context"
"fmt"
"io/ioutil"
"os"
"path/filepath"
@ -17,14 +16,11 @@ import (
"golang.org/x/tools/go/packages/packagestest"
"golang.org/x/tools/internal/lsp/tests"
"golang.org/x/tools/internal/testenv"
)
func TestMain(m *testing.M) {
if os.Getenv("GO_BUILDER_NAME") == "linux-arm" {
fmt.Fprintf(os.Stderr, "skipping test: linux-arm builder lacks sufficient memory (https://golang.org/issue/32834)\n")
os.Exit(0)
}
testenv.ExitIfSmallMachine()
os.Exit(m.Run())
}

View File

@ -23,14 +23,11 @@ import (
"golang.org/x/tools/internal/lsp/source"
"golang.org/x/tools/internal/lsp/tests"
"golang.org/x/tools/internal/span"
"golang.org/x/tools/internal/testenv"
)
func TestMain(m *testing.M) {
if os.Getenv("GO_BUILDER_NAME") == "linux-arm" {
fmt.Fprintf(os.Stderr, "skipping test: linux-arm builder lacks sufficient memory (https://golang.org/issue/32834)\n")
os.Exit(0)
}
testenv.ExitIfSmallMachine()
os.Exit(m.Run())
}

View File

@ -8,6 +8,7 @@ import (
"bytes"
"context"
"fmt"
"os"
"os/exec"
"path/filepath"
"sort"
@ -22,8 +23,14 @@ import (
"golang.org/x/tools/internal/lsp/source"
"golang.org/x/tools/internal/lsp/tests"
"golang.org/x/tools/internal/span"
"golang.org/x/tools/internal/testenv"
)
func TestMain(m *testing.M) {
testenv.ExitIfSmallMachine()
os.Exit(m.Run())
}
func TestSource(t *testing.T) {
packagestest.TestAll(t, testSource)
}

View File

@ -7,6 +7,7 @@
package testenv
import (
"fmt"
"os"
"os/exec"
"runtime"
@ -106,3 +107,14 @@ func NeedsGoPackagesEnv(t Testing, env []string) {
NeedsGoPackages(t)
}
// ExitIfSmallMachine emits a helpful diagnostic and calls os.Exit(0) if the
// current machine is a builder known to have scarce resources.
//
// It should be called from within a TestMain function.
func ExitIfSmallMachine() {
if os.Getenv("GO_BUILDER_NAME") == "linux-arm" {
fmt.Fprintln(os.Stderr, "skipping test: linux-arm builder lacks sufficient memory (https://golang.org/issue/32834)")
os.Exit(0)
}
}