зеркало из https://github.com/golang/tools.git
gopls/internal/lsp/protocol: fix TestURIFromPath on windows
Update TestURIFromPath not to assume the drive name for the default volume. Fixes golang/go#63366 Change-Id: I0196f11e628821b941d418831f3a3da7cf125ddf Reviewed-on: https://go-review.googlesource.com/c/tools/+/556496 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Родитель
d2200d1bd6
Коммит
f2d3f78aad
|
@ -8,6 +8,7 @@
|
|||
package protocol_test
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/tools/gopls/internal/lsp/protocol"
|
||||
|
@ -18,6 +19,15 @@ import (
|
|||
// tests by using only forward slashes, assuming that the standard library
|
||||
// functions filepath.ToSlash and filepath.FromSlash do not need testing.
|
||||
func TestURIFromPath(t *testing.T) {
|
||||
rootPath, err := filepath.Abs("/")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(rootPath) < 2 || rootPath[1] != ':' {
|
||||
t.Fatalf("malformed root path %q", rootPath)
|
||||
}
|
||||
driveLetter := string(rootPath[0])
|
||||
|
||||
for _, test := range []struct {
|
||||
path, wantFile string
|
||||
wantURI protocol.DocumentURI
|
||||
|
@ -44,13 +54,13 @@ func TestURIFromPath(t *testing.T) {
|
|||
},
|
||||
{
|
||||
path: `\path\to\dir`,
|
||||
wantFile: `C:\path\to\dir`,
|
||||
wantURI: protocol.DocumentURI("file:///C:/path/to/dir"),
|
||||
wantFile: driveLetter + `:\path\to\dir`,
|
||||
wantURI: protocol.DocumentURI("file:///" + driveLetter + ":/path/to/dir"),
|
||||
},
|
||||
{
|
||||
path: `\a\b\c\src\bob.go`,
|
||||
wantFile: `C:\a\b\c\src\bob.go`,
|
||||
wantURI: protocol.DocumentURI("file:///C:/a/b/c/src/bob.go"),
|
||||
wantFile: driveLetter + `:\a\b\c\src\bob.go`,
|
||||
wantURI: protocol.DocumentURI("file:///" + driveLetter + ":/a/b/c/src/bob.go"),
|
||||
},
|
||||
{
|
||||
path: `c:\Go\src\bob george\george\george.go`,
|
||||
|
|
Загрузка…
Ссылка в новой задаче