1
0
mirror of https://github.com/golang/go synced 2024-11-26 04:17:59 -07:00

misc/cgo: skip cgotest.TestCrossPackageTests on iOS and set PWD

I hope that this will fix the tests on iOS, but 'gomote create' isn't
giving me an instance I can test with. (Please patch and test before
approving.)

Updates #15919
Updates #30228

Change-Id: I1b7cd30d5b127a1ad3243b329fa005d229f69a24
Reviewed-on: https://go-review.googlesource.com/c/163726
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Bryan C. Mills 2019-02-25 22:09:46 -05:00
parent 3cf56e78d8
commit b5a68a9e41
7 changed files with 15 additions and 0 deletions

View File

@ -37,6 +37,7 @@ func testMain(m *testing.M) int {
if err := os.Chdir(modRoot); err != nil { if err := os.Chdir(modRoot); err != nil {
log.Panic(err) log.Panic(err)
} }
os.Setenv("PWD", modRoot)
if err := ioutil.WriteFile("go.mod", []byte("module cgolife\n"), 0666); err != nil { if err := ioutil.WriteFile("go.mod", []byte("module cgolife\n"), 0666); err != nil {
log.Panic(err) log.Panic(err)
} }

View File

@ -37,6 +37,7 @@ func testMain(m *testing.M) int {
if err := os.Chdir(modRoot); err != nil { if err := os.Chdir(modRoot); err != nil {
log.Panic(err) log.Panic(err)
} }
os.Setenv("PWD", modRoot)
if err := ioutil.WriteFile("go.mod", []byte("module cgostdio\n"), 0666); err != nil { if err := ioutil.WriteFile("go.mod", []byte("module cgostdio\n"), 0666); err != nil {
log.Panic(err) log.Panic(err)
} }

View File

@ -9,6 +9,7 @@ import (
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"runtime"
"strings" "strings"
"testing" "testing"
) )
@ -26,6 +27,13 @@ import (
// this shim and move the tests currently located in testdata back into the // this shim and move the tests currently located in testdata back into the
// parent directory. // parent directory.
func TestCrossPackageTests(t *testing.T) { func TestCrossPackageTests(t *testing.T) {
if runtime.GOOS == "darwin" {
switch runtime.GOARCH {
case "arm", "arm64":
t.Skip("Can't exec cmd/go subprocess on iOS.")
}
}
GOPATH, err := ioutil.TempDir("", "cgotest") GOPATH, err := ioutil.TempDir("", "cgotest")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)

View File

@ -60,6 +60,7 @@ func testMain(m *testing.M) int {
if err := os.Chdir(modRoot); err != nil { if err := os.Chdir(modRoot); err != nil {
log.Panic(err) log.Panic(err)
} }
os.Setenv("PWD", modRoot)
if err := ioutil.WriteFile("go.mod", []byte("module testcarchive\n"), 0666); err != nil { if err := ioutil.WriteFile("go.mod", []byte("module testcarchive\n"), 0666); err != nil {
log.Panic(err) log.Panic(err)
} }

View File

@ -132,6 +132,7 @@ func testMain(m *testing.M) int {
if err := os.Chdir(modRoot); err != nil { if err := os.Chdir(modRoot); err != nil {
log.Panic(err) log.Panic(err)
} }
os.Setenv("PWD", modRoot)
if err := ioutil.WriteFile("go.mod", []byte("module testcshared\n"), 0666); err != nil { if err := ioutil.WriteFile("go.mod", []byte("module testcshared\n"), 0666); err != nil {
log.Panic(err) log.Panic(err)
} }

View File

@ -51,12 +51,14 @@ func TestMain(m *testing.M) {
if err := os.Chdir(altRoot); err != nil { if err := os.Chdir(altRoot); err != nil {
log.Panic(err) log.Panic(err)
} }
os.Setenv("PWD", altRoot)
goCmd(nil, "build", "-buildmode=plugin", "-o", filepath.Join(modRoot, "plugin-mismatch.so"), "./plugin-mismatch") goCmd(nil, "build", "-buildmode=plugin", "-o", filepath.Join(modRoot, "plugin-mismatch.so"), "./plugin-mismatch")
os.Setenv("GOPATH", GOPATH) os.Setenv("GOPATH", GOPATH)
if err := os.Chdir(modRoot); err != nil { if err := os.Chdir(modRoot); err != nil {
log.Panic(err) log.Panic(err)
} }
os.Setenv("PWD", modRoot)
os.Setenv("LD_LIBRARY_PATH", modRoot) os.Setenv("LD_LIBRARY_PATH", modRoot)

View File

@ -126,6 +126,7 @@ func testMain(m *testing.M) (int, error) {
fmt.Printf("+ cd %s\n", modRoot) fmt.Printf("+ cd %s\n", modRoot)
} }
os.Chdir(modRoot) os.Chdir(modRoot)
os.Setenv("PWD", modRoot)
if err := ioutil.WriteFile("go.mod", []byte("module testshared\n"), 0666); err != nil { if err := ioutil.WriteFile("go.mod", []byte("module testshared\n"), 0666); err != nil {
return 0, err return 0, err
} }