mirror of
https://github.com/golang/go
synced 2024-11-17 08:04:46 -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:
parent
85387aa364
commit
08318f5942
@ -59,13 +59,26 @@ var sysdir = func() *sysDir {
|
||||
if err != nil {
|
||||
wd = err.Error()
|
||||
}
|
||||
return &sysDir{
|
||||
sd := &sysDir{
|
||||
filepath.Join(wd, "..", ".."),
|
||||
[]string{
|
||||
"ResourceRules.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":
|
||||
return &sysDir{
|
||||
@ -1191,15 +1204,18 @@ func TestChdirAndGetwd(t *testing.T) {
|
||||
case "darwin":
|
||||
switch runtime.GOARCH {
|
||||
case "arm", "arm64":
|
||||
d1, err := ioutil.TempDir("", "d1")
|
||||
if err != nil {
|
||||
t.Fatalf("TempDir: %v", err)
|
||||
for _, d := range []string{"d1", "d2"} {
|
||||
dir, err := ioutil.TempDir("", d)
|
||||
if err != nil {
|
||||
t.Fatalf("TempDir: %v", err)
|
||||
}
|
||||
// Expand symlinks so path equality tests work.
|
||||
dir, err = filepath.EvalSymlinks(dir)
|
||||
if err != nil {
|
||||
t.Fatalf("EvalSymlinks: %v", err)
|
||||
}
|
||||
dirs = append(dirs, dir)
|
||||
}
|
||||
d2, err := ioutil.TempDir("", "d2")
|
||||
if err != nil {
|
||||
t.Fatalf("TempDir: %v", err)
|
||||
}
|
||||
dirs = []string{d1, d2}
|
||||
}
|
||||
}
|
||||
oldwd := Getenv("PWD")
|
||||
|
Loading…
Reference in New Issue
Block a user