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

improve formatting of test output #187

Open
stamblerre opened this issue Jun 8, 2020 · 12 comments
Open

improve formatting of test output #187

stamblerre opened this issue Jun 8, 2020 · 12 comments
Assignees
Labels
FeatureRequest Go Companion Issues relating to the Go Companion extension go-test issues related to go test support (test output, test explorer, ...) NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@stamblerre
Copy link
Contributor

See the original issue (microsoft/vscode-go#2003).
We should add colorization for test output. We can also look at other ways to improve the UI.

@stamblerre stamblerre added FeatureRequest NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jun 8, 2020
@hyangah
Copy link
Contributor

hyangah commented Jun 8, 2020

Or more generally, https://code.visualstudio.com/docs/editor/tasks

@oliverpool
Copy link

oliverpool commented Jun 8, 2020

@firelizzard18 has done an extension which seems to supports the tasks of vs-code:
https://marketplace.visualstudio.com/items?itemName=ethan-reesor.vscode-go-test-adapter

Source code (MIT License):
https://gitlab.com/firelizzard/vscode-go-test-adapter

@firelizzard18
Copy link
Contributor

firelizzard18 commented Jun 8, 2020

My extension is a Test Adapter that plugs into the Test Explorer UI extension. I wrote/adapted the code to identify, execute, and collect the output of tests. The infrastructure is @hbenl’s work. My extension is somewhat barebones and does not integrate with tasks. I would be happy to work with the Go and/or VSCode team on improvements or on integrating the test adapter into vscode-go.

A lot of the limitations stem from go test and go tool test2json. Go’s test infrastructure is not built for post processing. There are some issues that may improve the situation, but that doesn’t help users of older versions of Go.

@oliverpool
Copy link

I investigated a bit the PHPunit extension, which has a colorized output.

It uses a vscode.Task with a ShellExecution to have a terminal which has colored output:
https://github.com/elonmallin/vscode-phpunit/blob/516ac9d/src/extension.ts#L57-L64

With the help of problemMatchers (https://github.com/elonmallin/vscode-phpunit/blob/fc63dff67ebc7cea834292ac86c55a0882c0bea9/package.json#L145) the error gets reported to the editor.


The tricky part would be to adapt the post-processing of the output that is currently done (expandFilePathInOutput & co.): https://github.com/golang/vscode-go/blob/6a61856/src/testUtils.ts#L339-L355

@PhilHarnish
Copy link

I love that colorization works with the test explorer but I noticed the command palette (and several other sources) still use the terminal. As far as I can tell, the test explorer version is feature complete (e.g. clickable links to source files).

Is it feasible to route everything through the test explorer implementation? (Of course, you'd need to honor go.testExplorer.enable which makes the request kinda expensive to maintain...)

@firelizzard18
Copy link
Contributor

The plan is to rework the old test capabilities into the new test explorer framework. At that point, go.testExplorer.enable would control whether the test resolver was registered with VSCode's test explorer system, but even if that was disabled the test resolver would still be active.

As long as go.testExplorer.enable is disabled, the only thing the test resolver would do is scan files as you open them, so it's impact would be relatively low.

@ysmood
Copy link

ysmood commented Mar 28, 2022

We should strip the special color chars if it's hard to support it for now:

image

Now the terminal output is correct, but other parts are not.

@firelizzard18
Copy link
Contributor

@ysmood That is a change that needs to be made in VSCode. The test API provides a method to record output. That output goes to both the terminal and the peek view. There is no way to make different output show up in those two places.

@hyangah hyangah added the go-test issues related to go test support (test output, test explorer, ...) label Jun 7, 2022
@deefdragon
Copy link

Atleast for tests, would a viable solution to be to have the Run[Package|Tile] Tests helpers above the functions execute the test via the Test Explorer to get coloring? It feels weird to have 2 different ways to run a tests that output like it currently does.

@firelizzard18
Copy link
Contributor

@deefdragon That was my plan. First add test explorer support (which I’ve done), then incrementally refactor the original test support to use the new system. But I was contributing in my free time and I no longer have the time to work on this.

@firelizzard18
Copy link
Contributor

This will be OBE if #3523 is merged, given that the plan is to replace the code lenses with the new test explorer system, as that would mean all test runs will go through vscode's testing API.

@firelizzard18
Copy link
Contributor

#3523 provides opt-in code lenses (as in, disabled by default) that replace the existing ones and are integrated with the test explorer.

@firelizzard18 firelizzard18 added the Go Companion Issues relating to the Go Companion extension label Oct 3, 2024
@firelizzard18 firelizzard18 self-assigned this Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest Go Companion Issues relating to the Go Companion extension go-test issues related to go test support (test output, test explorer, ...) NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
Status: Done
Development

No branches or pull requests

7 participants