Commit 08318f59 authored by Elias Naur's avatar Elias Naur

os: fix tests on self-hosted Go builds

Updates #31722

Change-Id: I467bb2539f993fad642abf96388a58a263fbe007
Reviewed-on: https://go-review.googlesource.com/c/go/+/174311
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 85387aa3
...@@ -59,13 +59,26 @@ var sysdir = func() *sysDir { ...@@ -59,13 +59,26 @@ var sysdir = func() *sysDir {
if err != nil { if err != nil {
wd = err.Error() wd = err.Error()
} }
return &sysDir{ sd := &sysDir{
filepath.Join(wd, "..", ".."), filepath.Join(wd, "..", ".."),
[]string{ []string{
"ResourceRules.plist", "ResourceRules.plist",
"Info.plist", "Info.plist",
}, },
} }
found := true
for _, f := range sd.files {
path := filepath.Join(sd.name, f)
if _, err := Stat(path); err != nil {
found = false
break
}
}
if found {
return sd
}
// In a self-hosted iOS build the above files might
// not exist. Look for system files instead below.
} }
case "windows": case "windows":
return &sysDir{ return &sysDir{
...@@ -1191,15 +1204,18 @@ func TestChdirAndGetwd(t *testing.T) { ...@@ -1191,15 +1204,18 @@ func TestChdirAndGetwd(t *testing.T) {
case "darwin": case "darwin":
switch runtime.GOARCH { switch runtime.GOARCH {
case "arm", "arm64": case "arm", "arm64":
d1, err := ioutil.TempDir("", "d1") for _, d := range []string{"d1", "d2"} {
if err != nil { dir, err := ioutil.TempDir("", d)
t.Fatalf("TempDir: %v", err) if err != nil {
} t.Fatalf("TempDir: %v", err)
d2, err := ioutil.TempDir("", "d2") }
if err != nil { // Expand symlinks so path equality tests work.
t.Fatalf("TempDir: %v", err) dir, err = filepath.EvalSymlinks(dir)
if err != nil {
t.Fatalf("EvalSymlinks: %v", err)
}
dirs = append(dirs, dir)
} }
dirs = []string{d1, d2}
} }
} }
oldwd := Getenv("PWD") oldwd := Getenv("PWD")
......
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