misc/ios: evaluate symlinks before comparing GOROOT and GOPATH

CL 163726 added workarounds to keep the iOS builders happy in
a symlinked temporary dir.

The workarounds also made the tests more realistic and improved
performance. Keep them but also handle symlinks better in the
exec wrapper.

Change-Id: Iaa2c03a1a3fb3aa5aaf62d79d52b63d5d8f11db5
Reviewed-on: https://go-review.googlesource.com/c/164698
Reviewed-by: Bryan C. Mills <bcmills@google.com>
This commit is contained in:
Elias Naur 2019-03-01 01:15:24 +01:00
parent d96b7fbf98
commit aafa855fd3

View File

@ -633,8 +633,12 @@ func subdir() (pkgpath string, underGoRoot bool, err error) {
if err != nil {
return "", false, err
}
if root := runtime.GOROOT(); strings.HasPrefix(cwd, root) {
subdir, err := filepath.Rel(root, cwd)
goroot, err := filepath.EvalSymlinks(runtime.GOROOT())
if err != nil {
return "", false, err
}
if strings.HasPrefix(cwd, goroot) {
subdir, err := filepath.Rel(goroot, cwd)
if err != nil {
return "", false, err
}
@ -642,10 +646,14 @@ func subdir() (pkgpath string, underGoRoot bool, err error) {
}
for _, p := range filepath.SplitList(build.Default.GOPATH) {
if !strings.HasPrefix(cwd, p) {
pabs, err := filepath.EvalSymlinks(p)
if err != nil {
return "", false, err
}
if !strings.HasPrefix(cwd, pabs) {
continue
}
subdir, err := filepath.Rel(p, cwd)
subdir, err := filepath.Rel(pabs, cwd)
if err == nil {
return subdir, false, nil
}