summaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modfetch/codehost/git_test.go
diff options
context:
space:
mode:
authorJay Conrod <jayconrod@google.com>2019-11-08 13:05:56 -0500
committerJay Conrod <jayconrod@google.com>2019-11-11 17:53:51 +0000
commit70be4819a47263055040d6beb5c0b1b31487f52c (patch)
treea0d2f013ad6efeb05c031c24af652095470121d5 /src/cmd/go/internal/modfetch/codehost/git_test.go
parent275a7be3da9fded6ec71c92633bca30caf6dd93b (diff)
downloadgo-git-70be4819a47263055040d6beb5c0b1b31487f52c.tar.gz
cmd/go: fix windows test failures
search.CleanPatterns now preserves backslash separators in absolute paths in Windows. These had resulted in inconsistent error messages. search.MatchPackagesInFS is now more accepting of patterns with backslashes. It was inconsistent before. Several tests are fixed to work with Windows (mostly to match slashes or backslashes). Fixes #25300 Change-Id: Ibbf9ccd145353f7e3d345205c6fcc01d7066d1c2 Reviewed-on: https://go-review.googlesource.com/c/go/+/206144 Run-TryBot: Jay Conrod <jayconrod@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/go/internal/modfetch/codehost/git_test.go')
-rw-r--r--src/cmd/go/internal/modfetch/codehost/git_test.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/cmd/go/internal/modfetch/codehost/git_test.go b/src/cmd/go/internal/modfetch/codehost/git_test.go
index 39c904f92c..cc32a1eb51 100644
--- a/src/cmd/go/internal/modfetch/codehost/git_test.go
+++ b/src/cmd/go/internal/modfetch/codehost/git_test.go
@@ -78,7 +78,16 @@ func testMain(m *testing.M) int {
func testRepo(remote string) (Repo, error) {
if remote == "localGitRepo" {
- return LocalGitRepo(filepath.ToSlash(localGitRepo))
+ // Convert absolute path to file URL. LocalGitRepo will not accept
+ // Windows absolute paths because they look like a host:path remote.
+ // TODO(golang.org/issue/32456): use url.FromFilePath when implemented.
+ var url string
+ if strings.HasPrefix(localGitRepo, "/") {
+ url = "file://" + localGitRepo
+ } else {
+ url = "file:///" + filepath.ToSlash(localGitRepo)
+ }
+ return LocalGitRepo(url)
}
kind := "git"
for _, k := range []string{"hg"} {