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

Use tasks & terminals to run tests to get colorized output #2003

Closed
bandesz opened this issue Oct 13, 2018 · 16 comments
Closed

Use tasks & terminals to run tests to get colorized output #2003

bandesz opened this issue Oct 13, 2018 · 16 comments

Comments

@bandesz
Copy link

bandesz commented Oct 13, 2018

screen shot 2018-10-13 at 10 06 06

Steps to reproduce

  1. Use e.g. ginkgo for testing
  2. On a test file run "Go: Test File"
  3. The output is barely readable as it contains a lot of color escape sequences.

I disabled all other plugins which might cause an issue, but it still doesn't work. (Should this even work?)

@ramya-rao-a
Copy link
Contributor

The test output was never colorized in the first place :)

How does the test output look when you run it in a terminal?

@bandesz
Copy link
Author

bandesz commented Oct 17, 2018

@ramya-rao-a a random example:
ginkgo

@bandesz
Copy link
Author

bandesz commented Oct 17, 2018

I managed to disable the colored output in this case by using the following setting:

"go.testFlags": ["-ginkgo.noColor"]

@toaster
Copy link

toaster commented Oct 22, 2018

Hi there, what are the arguments against making colorization available here?

@ramya-rao-a
Copy link
Contributor

As mentioned in #2003 (comment), colorization never worked in the output channel for test output.

The example in #2003 (comment) is from running the tests in a terminal directly.

To show colors in the output channel, we need to provide a grammar to parse the contents first.

Another alternative is to run the tests in a terminal using tasks

@toaster
Copy link

toaster commented Oct 23, 2018

Ok, thanks for the clarification.

@ramya-rao-a
Copy link
Contributor

To achieve the colors, this extension should use tasks to run the tests and show the output in the integrated terminal which is capable of showing the colors.

@ramya-rao-a ramya-rao-a changed the title Output is not colorized when running Go tests Use tasks & terminals to run tests to get colorized output Nov 4, 2018
@segevfiner
Copy link
Contributor

It seems the current code to run Go tests rewrites package paths in the output to be full paths, I guess that's so they are clickable.

VS Code tasks currently require running a process or a shell command, and won't support this easily (Without sticking an intermediate process wrapping go test in the way, which is ugly). Custom task executors is probably on the VS Code backlog (I think they actually planned to work on it this iteration: microsoft/vscode#65570)

@oliverpool
Copy link

@segevfiner do you refer to microsoft/vscode#76492 ?

Now that it has been implemented into vscode, is it possible to solve this issue ?

@segevfiner
Copy link
Contributor

Yeah. It was possible before minus the feature that rewrites paths in the output (Without introducing a binary/script that does so and invoking a shell pipeline that runs it and go test). With this API you can handle the output from tasks in code and as such implement such rewriting. But I think it might require lifting a lot of code for how to implement an executer that executes a process with all its features from VS Code.

Personally I had trouble wrapping my head around the task API and task providers to figure out how to do this and coming up with how to introduce that to the existing code.

@segevfiner
Copy link
Contributor

Looking into this even further. I noticed that the official Python extension has a test explorer UI for running tests. Strangely enough, it is completely custom built inside the Python extension while there is also a third-party extension implementing a similar UI: https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-test-explorer for the use of other extensions. Not sure how test execution and output is handled in those test explorer implementations.

@slnt
Copy link

slnt commented Mar 13, 2020

Any updates on this? I'd give this feature request a +1. I use a tool called richgo which provides colorized test output and would benefit from being able to run a task such as the following when hitting the Run Test button.

    {
      "label": "Test Go Code",
      "type": "shell",
      "presentation": {
        "echo": true,
        "reveal": "always",
        "panel": "shared",
        "showReuseMessage": false,
        "clear": true
      },
      "command": "richgo",
      "args": [
        "test",
        "???"
      ],
    },

@ramya-rao-a
Copy link
Contributor

Hello all,

We are in the midst of a repo move, see We are moving section in our readme for more details.

Since there are no clear steps on how to implement this, I will be closing this issue.
If anybody has clues on how to move forward, please log an issue or create a PR in https://github.com/golang/vscode-go

Thanks for all the support & Happy Coding!

@segevfiner
Copy link
Contributor

@ramya-rao-a I still believe it is a good idea to improve the way tests are being run, supporting colors, etc. But not sure what the implementation should be so as to create an issue. It might take someone who is more familiar with VS Code extensions, or authors one, to help here. As I described previously the situations with the test explorers and that it is unclear what's the recommended way for extensions to handle tests.

@ramya-rao-a
Copy link
Contributor

I agree @segevfiner

@hyangah, @stamblerre, Do you want to consider having an issue to evaluate how we run tests and the possible improvements we can do there regarding displaying the output? It can include to explore how the test explorer extensions do this and take a look at tasks as well

@stamblerre
Copy link
Contributor

Yep that makes sense, thanks @segevfiner. Filed golang/vscode-go#187.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants