Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls/internal/span: TestURIFromPath fail in windows #63366

Closed
qiulaidongfeng opened this issue Oct 4, 2023 · 7 comments
Closed

x/tools/gopls/internal/span: TestURIFromPath fail in windows #63366

qiulaidongfeng opened this issue Oct 4, 2023 · 7 comments
Assignees
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@qiulaidongfeng
Copy link
Contributor

What version of Go are you using (go version)?

$ go version
tip

Does this issue reproduce with the latest release?

yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

What did you do?

git clone https://github.com/golang/tools
cd tools
cd gopls
go test ./...

What did you expect to see?

Test Passed.

What did you see instead?

--- FAIL: TestURIFromPath (0.00s)
    uri_windows_test.go:63: URIFromPath("\\path\\to\\dir"): got "file:///E:/path/to/dir", expected "file:///C:/path/to/dir"
    uri_windows_test.go:67: Filename("file:///E:/path/to/dir"): got "E:\\path\\to\\dir", expected "C:\\path\\to\\dir"
    uri_windows_test.go:63: URIFromPath("\\a\\b\\c\\src\\bob.go"): got "file:///E:/a/b/c/src/bob.go", expected "file:///C:/a/b/c/src/bob.go"
    uri_windows_test.go:67: Filename("file:///E:/a/b/c/src/bob.go"): got "E:\\a\\b\\c\\src\\bob.go", expected "C:\\a\\b\\c\\src\\bob.go"
FAIL
exit status 1
FAIL    golang.org/x/tools/gopls/internal/span  1.701s
@qiulaidongfeng qiulaidongfeng changed the title TestURIFromPath: TestURIFromPath fail in windows x/tools/gopls/internal/span: TestURIFromPath fail in windows Oct 4, 2023
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Oct 4, 2023
@gopherbot gopherbot added this to the Unreleased milestone Oct 4, 2023
@findleyr
Copy link
Contributor

findleyr commented Oct 4, 2023

This test is build tagged !windows, so failure is expected. Our CI regularly runs tests on windows.

Are you overriding GOOS?

@qiulaidongfeng
Copy link
Contributor Author

qiulaidongfeng commented Oct 4, 2023

I am running go test ./... on gopls

@qiulaidongfeng
Copy link
Contributor Author

qiulaidongfeng commented Oct 4, 2023

@hyangah
Copy link
Contributor

hyangah commented Oct 4, 2023

Similar issue like #63363. Need to avoid the hard-coded drive name (C:)
I placed it into gopls/v0.14.0 for triage, but this is a bug in test and shouldn't affect end users.

@hyangah hyangah modified the milestones: Unreleased, gopls/v0.14.0 Oct 4, 2023
@findleyr
Copy link
Contributor

findleyr commented Oct 4, 2023

@qiulaidongfeng my apologies, I blame gopls's lack of build tag support :)
(which we're working on!)

@findleyr findleyr modified the milestones: gopls/v0.14.0, gopls/v0.14.1 Oct 9, 2023
@findleyr findleyr modified the milestones: gopls/v0.14.2, gopls/v0.15.0 Nov 14, 2023
@adonovan
Copy link
Member

adonovan commented Dec 1, 2023

The problem (as @hyangah points out) is that filepath.Abs("\\drive\\relative\\path") will prepend a drive letter based on where the x/tools repo was cloned. The test should not assume C:, but should normalize the path to replace ^[A-Z]: by C: before the assertion.

@findleyr findleyr self-assigned this Jan 17, 2024
@gopherbot
Copy link

Change https://go.dev/cl/556496 mentions this issue: gopls/internal/lsp/protocol: fix TestURIFromPath on windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants