1
0
mirror of https://github.com/golang/go synced 2024-11-18 17:54:57 -07:00

go/...: make most tests pass with gccgo

There is one non-test change: have FakeContext change the compiler to
"gc", as callers expect to be accessing a gc-style GOROOT.

The go/pointer, go/ssa, and go/ssa/interp tests still fail with gccgo.

Change-Id: I850c9618401f6b9e63d7ca7196f91931b03f1524
Reviewed-on: https://go-review.googlesource.com/117395
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Ian Lance Taylor 2018-06-07 21:33:18 -07:00
parent 4e38c85762
commit c65208ee29
8 changed files with 36 additions and 6 deletions

View File

@ -10,6 +10,7 @@ package buildutil_test
import (
"go/build"
"runtime"
"sort"
"strings"
"testing"
@ -18,6 +19,10 @@ import (
)
func TestAllPackages(t *testing.T) {
if runtime.Compiler == "gccgo" {
t.Skip("gccgo has no standard packages")
}
all := buildutil.AllPackages(&build.Default)
set := make(map[string]bool)

View File

@ -41,6 +41,7 @@ func FakeContext(pkgs map[string]map[string]string) *build.Context {
ctxt := build.Default // copy
ctxt.GOROOT = "/go"
ctxt.GOPATH = ""
ctxt.Compiler = "gc"
ctxt.IsDir = func(dir string) bool {
dir = clean(dir)
if dir == "" {

View File

@ -15,6 +15,10 @@ import (
)
func TestContainingPackage(t *testing.T) {
if runtime.Compiler == "gccgo" {
t.Skip("gccgo has no GOROOT")
}
// unvirtualized:
goroot := runtime.GOROOT()
gopath := gopathContainingTools(t)

View File

@ -3,6 +3,7 @@
// license that can be found in the LICENSE file.
// +build go1.7
// +build gc
package gcexportdata_test

View File

@ -64,8 +64,6 @@ var importablePackages = [...]string{
"encoding/pem",
"encoding/xml",
"errors",
"exp/proxy",
"exp/terminal",
"expvar",
"flag",
"fmt",
@ -116,8 +114,6 @@ var importablePackages = [...]string{
"net/smtp",
"net/textproto",
"net/url",
"old/regexp",
"old/template",
"os/exec",
"os",
"os/signal",
@ -183,12 +179,12 @@ func TestInstallationImporter(t *testing.T) {
// Test for certain specific entities in the imported data.
for _, test := range [...]importerTest{
{pkgpath: "io", name: "Reader", want: "type Reader interface{Read(p []uint8) (n int, err error)}"},
{pkgpath: "io", name: "Reader", want: "type Reader interface{Read(p []byte) (n int, err error)}"},
{pkgpath: "io", name: "ReadWriter", want: "type ReadWriter interface{Reader; Writer}"},
{pkgpath: "math", name: "Pi", want: "const Pi untyped float"},
{pkgpath: "math", name: "Sin", want: "func Sin(x float64) float64"},
{pkgpath: "sort", name: "Ints", want: "func Ints(a []int)"},
{pkgpath: "unsafe", name: "Pointer", want: "type Pointer unsafe.Pointer"},
{pkgpath: "unsafe", name: "Pointer", want: "type Pointer"},
} {
runImporterTest(t, imp, nil, &test)
}

View File

@ -144,6 +144,13 @@ func TestObjImporter(t *testing.T) {
for _, test := range importerTests {
gofile := filepath.Join("testdata", test.pkgpath+".go")
if _, err := os.Stat(gofile); err != nil {
// There is a .gox file but no .go file,
// so there is nothing to compile.
continue
}
ofile := filepath.Join(tmpdir, test.pkgpath+".o")
afile := filepath.Join(artmpdir, "lib"+test.pkgpath+".a")
@ -154,6 +161,10 @@ func TestObjImporter(t *testing.T) {
t.Fatalf("gccgo %s failed: %s", gofile, err)
}
// The expected initializations are version dependent,
// so don't check for them.
test.wantinits = nil
runImporterTest(t, imp, initmap, &test)
cmd = exec.Command("ar", "cr", afile, ofile)

View File

@ -23,6 +23,9 @@ import (
)
func TestBExportData_stdlib(t *testing.T) {
if runtime.Compiler == "gccgo" {
t.Skip("gccgo standard library is inaccessible")
}
if runtime.GOOS == "android" {
t.Skipf("incomplete std lib on %s", runtime.GOOS)
}

View File

@ -15,6 +15,7 @@ import (
"go/types"
"path/filepath"
"reflect"
"runtime"
"sort"
"strings"
"sync"
@ -127,6 +128,10 @@ func TestLoad_MissingInitialPackage(t *testing.T) {
}
func TestLoad_MissingInitialPackage_AllowErrors(t *testing.T) {
if runtime.Compiler == "gccgo" {
t.Skip("gccgo has no standard library test files")
}
var conf loader.Config
conf.AllowErrors = true
conf.Import("nosuchpkg")
@ -251,6 +256,10 @@ func TestLoad_FromSource_Success(t *testing.T) {
}
func TestLoad_FromImports_Success(t *testing.T) {
if runtime.Compiler == "gccgo" {
t.Skip("gccgo has no standard library test files")
}
var conf loader.Config
conf.ImportWithTests("fmt")
conf.ImportWithTests("errors")