diff options
author | Andy Pan <panjf2000@gmail.com> | 2020-11-21 15:27:00 +0800 |
---|---|---|
committer | Jay Conrod <jayconrod@google.com> | 2021-02-23 17:38:55 +0000 |
commit | c7f596f919d779dc01a60f876cbd9d8cc2cd70b2 (patch) | |
tree | 16d6e830decc0b51d170d2919b1a87ebbe0d18d6 /src/cmd/go/internal/test | |
parent | 5e94fe931613111c170e4798131790b3db2bbe90 (diff) | |
download | go-git-c7f596f919d779dc01a60f876cbd9d8cc2cd70b2.tar.gz |
cmd/go: resolve TODO by replacing InDir() function
Change-Id: Idf886bbc4e66c9ee2a41c90034075301e0a21a58
Reviewed-on: https://go-review.googlesource.com/c/go/+/271909
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/internal/test')
-rw-r--r-- | src/cmd/go/internal/test/test.go | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go index 7fc9e8fbdc..ea9dfbe4e8 100644 --- a/src/cmd/go/internal/test/test.go +++ b/src/cmd/go/internal/test/test.go @@ -29,6 +29,7 @@ import ( "cmd/go/internal/cfg" "cmd/go/internal/load" "cmd/go/internal/lockedfile" + "cmd/go/internal/search" "cmd/go/internal/str" "cmd/go/internal/trace" "cmd/go/internal/work" @@ -1499,7 +1500,7 @@ func computeTestInputsID(a *work.Action, testlog []byte) (cache.ActionID, error) if !filepath.IsAbs(name) { name = filepath.Join(pwd, name) } - if a.Package.Root == "" || !inDir(name, a.Package.Root) { + if a.Package.Root == "" || search.InDir(name, a.Package.Root) == "" { // Do not recheck files outside the module, GOPATH, or GOROOT root. break } @@ -1508,7 +1509,7 @@ func computeTestInputsID(a *work.Action, testlog []byte) (cache.ActionID, error) if !filepath.IsAbs(name) { name = filepath.Join(pwd, name) } - if a.Package.Root == "" || !inDir(name, a.Package.Root) { + if a.Package.Root == "" || search.InDir(name, a.Package.Root) == "" { // Do not recheck files outside the module, GOPATH, or GOROOT root. break } @@ -1526,18 +1527,6 @@ func computeTestInputsID(a *work.Action, testlog []byte) (cache.ActionID, error) return sum, nil } -func inDir(path, dir string) bool { - if str.HasFilePathPrefix(path, dir) { - return true - } - xpath, err1 := filepath.EvalSymlinks(path) - xdir, err2 := filepath.EvalSymlinks(dir) - if err1 == nil && err2 == nil && str.HasFilePathPrefix(xpath, xdir) { - return true - } - return false -} - func hashGetenv(name string) cache.ActionID { h := cache.NewHash("getenv") v, ok := os.LookupEnv(name) |