Skip to content

Commit

Permalink
all: skip more memory-intensive tests on linux-arm
Browse files Browse the repository at this point in the history
Updates golang/go#32834

Change-Id: I9844dc09d9a6eb2e79a0b28a1e69ed018bfa1bff
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192578
Run-TryBot: Bryan C. Mills <[email protected]>
Reviewed-by: Brad Fitzpatrick <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
  • Loading branch information
Bryan C. Mills committed Aug 30, 2019
1 parent df13fa7 commit 311ec03
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 16 deletions.
5 changes: 5 additions & 0 deletions go/internal/gcimporter/gcimporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions go/loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"go/build"
"go/constant"
"go/types"
"os"
"path/filepath"
"reflect"
"runtime"
Expand All @@ -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) {
Expand Down
6 changes: 1 addition & 5 deletions go/packages/packages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

Expand Down
8 changes: 8 additions & 0 deletions internal/imports/imports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 2 additions & 6 deletions internal/lsp/cmd/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package cmd_test
import (
"bytes"
"context"
"fmt"
"io/ioutil"
"os"
"path/filepath"
Expand All @@ -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())
}

Expand Down
7 changes: 2 additions & 5 deletions internal/lsp/lsp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

Expand Down
7 changes: 7 additions & 0 deletions internal/lsp/source/source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"bytes"
"context"
"fmt"
"os"
"os/exec"
"path/filepath"
"sort"
Expand All @@ -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)
}
Expand Down
12 changes: 12 additions & 0 deletions internal/testenv/testenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package testenv

import (
"fmt"
"os"
"os/exec"
"runtime"
Expand Down Expand Up @@ -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)
}
}

0 comments on commit 311ec03

Please sign in to comment.