From 70be4819a47263055040d6beb5c0b1b31487f52c Mon Sep 17 00:00:00 2001 From: Jay Conrod Date: Fri, 8 Nov 2019 13:05:56 -0500 Subject: 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 Reviewed-by: Bryan C. Mills --- src/cmd/go/internal/modfetch/codehost/git_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/cmd/go/internal/modfetch/codehost/git_test.go') 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"} { -- cgit v1.2.1