-
Notifications
You must be signed in to change notification settings - Fork 764
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
Testing API #1579
Comments
It looks like the first parts of the proposed testing APIs (microsoft/vscode#107467) are close to finalization and so it is good time to start thinking about integration. It would be nice if the test exploration (along with coverage, profiling, tracing ..) is integrated into the go extension - so users can use it instead of installing separate extensions. I knew the Go Test Explorer was doing a great job in this space already, and unfortunately we are currently swamped with other high priority tasks. As a result, we never put this in our top priority task and it will take time without help from contributors. Is it possible to reuse part of the Go Test Explorer implementation? |
Thanks! There are some rough spots I'm not happy about, but I know where all the flaws are shrug.
I have no objection to vscode-go using my code, and we use the same license. Mainly, the code can be separated into A) locate functions of interest and build a data model, and B) handle execution, etc. Locating functions of interest translates to executing Reusing my implementation comes down to how similar you want it to behave. In a number of aspects the implementation is fairly ugly because my extension doesn't have access to vscode-go internals. So some things could be cut out by reusing the run-test, debug-test, and config infrastructure in vscode-go. The main implementation of the test explorer hooks is... not pretty. And it will have to be rewritten anyways for the new API. Other than that, the main thing is my data model. It's main purpose is to facilitate running all tests for a package/model/file, and presenting the UI as a tree with module > pkg1 > pkg2 > file > tests. I like that way of doing things, but you may prefer something else. Also, it may be preferable to organize the data in a different structure, and construct that tree structure only when presenting. That may simplify some of the update bugs. Aside from test and debug, the only additional feature I have amounts to running go test with Once the API is stable, I would be willing to start working on integrating. Is this something you would accept a PR for? And WRT to the profiling, is that something you want in vscode-go? Given that my current approach boils down to feeding the profile to |
@firelizzard18 Thanks for the explanation. It sounds like by accessing the extension internals, tighter and cleaner implementation can be possible, which is a good thing!
Your choice of the model seems natural to me too - was there any feature request that proposes different ways organizing tests?
Sure! Our review process uses gerrit like other go projects. https://github.com/golang/vscode-go/blob/master/docs/contributing.md#mail-your-change-for-review
Yes, profiling is part of important tools so it would be nice if vscode-go can offer it as well. |
@hyangah Sounds great! I'll start poking around. No one has objected to the tree structure, so I'll stick with that. |
@hyangah Is this intended behavior? I assumed |
@firelizzard18 That sounds like a bug in
GOMOD = /dev/null means module mode is enabled but there is no go.mod file. With go1.16 that enables module mode by default, I think |
DO NOT MERGE Until the test API is finalized, and enableProposedApi is removed from package.json, this must not be merged. This takes a dynamic approach to test discovery. Tree nodes will be populated as they are expanded in the UI. Tests in open files will be added. Fixes golang#1579
This takes a dynamic approach to test discovery. Tree nodes will be populated as they are expanded in the UI. Tests in open files will be added. Fixes golang#1579
@hyangah I'm happy to use Gerrit, but it's not clear to me how I'm supposed to use |
@hyangah I have the basic implementation done. |
This takes a dynamic approach to test discovery. Tree nodes will be populated as they are expanded in the UI. Tests in open files will be added. Fixes golang#1579
@hyangah or @suzmue, have you looked at microsoft/vscode#123713? I don't know enough about Go's test coverage to know if the proposed API is sufficient for Go. |
For reference (for me): microsoft/vscode#122208 |
Thanks @firelizzard18 - Go's coverage instrumentation results are in the form of
So, I think the proposed API fits to represent one single test (or subtest) run. But maybe @pjweinb who worked on coverage feature improvement recently has a different opinion. In Go, there is a way to run multiple tests at once (all tests in a package, or in a workspace). AFAIK, the coverage data does not track hit count per individual test. So, I guess, to work with the proposed API, we need to discover all individual tests and run them individually. I think it's up to how the test api & coverage api & vscode UI is wired. |
hyangah, i think that's right. The coverage results are from a single run. |
At the moment, I'm collating a list of function names per package and executing them with If I'm reading the proposed API correctly, coverage data is per-run, not per-test. If the user triggers a run at the package or module level, that is expected to run all test within that scope, as a single TestRun. So I think my current implementation would be sufficient - once |
It sounds like most of the testing API will be finalized/released in the upcoming VSCode release |
Thanks @firelizzard18 There are many features that we need a newer vscode engine so we were planning to update our vscode engine requirements. :-) How about declaring v0.27.1 as the last version that supports vscode 1.52+. |
@hyangah Correct, to use a proposed API, you have to set a flag in Update
|
microsoft/vscode#122208 was just closed, and the API moved from |
Insiders is actually released in the European morning each work day -- so overnight in the US Sunday-Thursday 🙂 |
Ah, I saw you mention 'not until Monday' to someone, so I assumed it was always Monday. |
Due to the lack of log message support for passed tests (microsoft/vscode#129201), benchmarks may change. If I can't find a work around, I may disable them (for now). |
It appears that |
OK, my solution for now for benchmarks is:
Since there's no longer a way to attach messages to passing test runs, if a benchmark returns results I explicitly call the command that displays the test result terminal. |
The PR is updated to the finalized API and has basic support for showing cpu/mem profiles. It still needs polish (and review). |
I'm going to move profiling to its own branch and remove it from the CL. The simple implementation just shows a text profile, which isn't super useful, and this CL is already large enough. |
This takes a dynamic approach to test discovery. Tree nodes will be populated as they are expanded in the UI. Tests in open files will be added. Fixes golang#1579
This takes a dynamic approach to test discovery. Tree nodes will be populated as they are expanded in the UI. Tests in open files will be added. Fixes golang#1579
This takes a dynamic approach to test discovery. Tree nodes will be populated as they are expanded in the UI. Tests in open files will be added. Fixes golang#1579
This takes a dynamic approach to test discovery. Tree nodes will be populated as they are expanded in the UI. Tests in open files will be added. Fixes golang#1579
nice work 👍 |
Change https://golang.org/cl/330809 mentions this issue: |
Does vscode-go intend to implement/participate in the new Testing API for VSCode? I am the author of Go Test Explorer, which integrates with the Test Explorer UI.
If and when this extension implements the Testing API, I will retire my extension.
The text was updated successfully, but these errors were encountered: