Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

test/gopls: initial test setup for gopls and hover tests #3157

Merged
merged 1 commit into from
Apr 27, 2020

Conversation

hyangah
Copy link
Contributor

@hyangah hyangah commented Apr 6, 2020

This CL includes only HoverProvider tests, that use the same scenario
as the hover provider tests with godoc and gogetdoc in
integration/extension.test.ts.

Gopls test setup is complicated because gopls currently does not
work in a single-file mode nor support mono repos with multiple
modules. VS Code in test environment does not support dynamic
registration of workspace folders during testing. So, the
workspace folder needs to be specified before the extension
host launches (by vscode-test.runTests or launch.json extensionHost
type tasks).

As a workaround, I use an empty directory and start the extension
host with the empty directory for a testing. Then, let the test
populate the directory with necessary files. This is not ideal;
file copy is slow and the use of the single workspace directory
prevents parallelized testing.

Commiting an empty directory to use as a scratch space is not
ideal either, but no worse than what vscode dev in my opinion.
https://github.com/microsoft/vscode/blob/master/.vscode/launch.json

I also considered shelling out the extension host launch
after creating a temp directory and using it as a workspace directory.
That may work inside test/runTest.ts, but complicates debugging
when sarting the test using launch.json.

Also passes '--user-data-dir' flag to prevent the tests from
using my personal vscode settings and interfere tests.

Change-Id: I7b064441720da5c89833afab35e8273de808cfad

This CL includes only HoverProvider tests, that use the same scenario
as the hover provider tests with godoc and gogetdoc in
integration/extension.test.ts.

Gopls test setup is complicated because gopls currently does not
work in a single-file mode nor support mono repos with multiple
modules. VS Code in test environment does not support dynamic
registration of workspace folders during testing.  So, the
workspace folder needs to be specified before the extension
host launches (by vscode-test.runTests or launch.json extensionHost
type tasks).

As a workaround, I use an empty directory and start the extension
host with the empty directory for a testing. Then, let the test
populate the directory with necessary files. This is not ideal;
file copy is slow and the use of the single workspace directory
prevents parallelized testing.

Commiting an empty directory to use as a scratch space is not
ideal either, but no worse than what vscode dev in my opinion.
https://github.com/microsoft/vscode/blob/master/.vscode/launch.json

I also considered shelling out the extension host launch
after creating a temp directory and using it as a workspace directory.
That may work inside test/runTest.ts, but complicates debugging
when sarting the test using launch.json.

Also passes '--user-data-dir' flag to prevent the tests from
using my personal vscode settings and interfere tests.

Change-Id: I7b064441720da5c89833afab35e8273de808cfad
@hyangah
Copy link
Contributor Author

hyangah commented Apr 6, 2020

/cc @stamblerre @ramya-rao-a

@stamblerre
Copy link
Contributor

Thanks for working on this, @hyangah! It looks good to me, and I'm sorry you had to jump through so many hoops to get gopls to run in the test framework. I'll aim to support single-file mode for the next release so that we can avoid some of this, but I do still think it's good for us to have single-file, GOPATH, and Go modules-style tests.

@ramya-rao-a ramya-rao-a merged commit f3dd04b into microsoft:master Apr 27, 2020
gopherbot pushed a commit to golang/vscode-go that referenced this pull request Apr 27, 2020
The lint rule was changed since PR microsoft/vscode-go#3157
so the newly added code broke the lint test.

Change-Id: Ic58dfa62e19cb61600b45fe10b43811eb00bc28d
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/230297
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
hyangah added a commit to hyangah/vscode-go-old that referenced this pull request Apr 27, 2020
The lint rule was changed since PR microsoft#3157
so the newly added code broke the lint test.

Change-Id: Ic58dfa62e19cb61600b45fe10b43811eb00bc28d
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/230297
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
ramya-rao-a pushed a commit that referenced this pull request Apr 28, 2020
The lint rule was changed since PR #3157
so the newly added code broke the lint test.

Change-Id: Ic58dfa62e19cb61600b45fe10b43811eb00bc28d
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/230297
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants