-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go: limit test input file change detection to local GOROOT/GOPATH…
… tree We've had a series of problems with tests unexpectedly (and innocently) looking at system files that appear to (but don't) change in meaningful ways, like /dev/null on OS X having a modification time set to the current time. Cut all these off by only applying file change detection to the local package root: the GOROOT or specific sub-GOPATH in which the package being tested is found. (This means that if you test reads /tmp/x and you change /tmp/x, the cached result will still be used. Don't do that, or else use -count=1.) Fixes golang#23390. Change-Id: I30b6dd194835deb645a040aea5e6e4f68af09edb Reviewed-on: https://go-review.googlesource.com/87015 Run-TryBot: Russ Cox <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
- Loading branch information
Showing
5 changed files
with
82 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2018 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package str | ||
|
||
import ( | ||
"path/filepath" | ||
"strings" | ||
) | ||
|
||
// HasFilePathPrefix reports whether the filesystem path s begins with the | ||
// elements in prefix. | ||
func HasFilePathPrefix(s, prefix string) bool { | ||
sv := strings.ToUpper(filepath.VolumeName(s)) | ||
pv := strings.ToUpper(filepath.VolumeName(prefix)) | ||
s = s[len(sv):] | ||
prefix = prefix[len(pv):] | ||
switch { | ||
default: | ||
return false | ||
case sv != pv: | ||
return false | ||
case len(s) == len(prefix): | ||
return s == prefix | ||
case len(s) > len(prefix): | ||
if prefix != "" && prefix[len(prefix)-1] == filepath.Separator { | ||
return strings.HasPrefix(s, prefix) | ||
} | ||
return s[len(prefix)] == filepath.Separator && s[:len(prefix)] == prefix | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters