1
0
mirror of https://github.com/golang/go synced 2024-11-17 12:24:51 -07:00

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: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Elias Naur 2019-04-30 22:15:46 +02:00
parent 85387aa364
commit 08318f5942

View File

@ -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) {
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"} {
dir, err := ioutil.TempDir("", d)
if err != nil { if err != nil {
t.Fatalf("TempDir: %v", err) t.Fatalf("TempDir: %v", err)
} }
d2, err := ioutil.TempDir("", "d2") // Expand symlinks so path equality tests work.
dir, err = filepath.EvalSymlinks(dir)
if err != nil { if err != nil {
t.Fatalf("TempDir: %v", err) t.Fatalf("EvalSymlinks: %v", err)
}
dirs = append(dirs, dir)
} }
dirs = []string{d1, d2}
} }
} }
oldwd := Getenv("PWD") oldwd := Getenv("PWD")