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

Go code coverage disappears when typing a character #2551

Closed
admilazz opened this issue May 31, 2019 · 10 comments
Closed

Go code coverage disappears when typing a character #2551

admilazz opened this issue May 31, 2019 · 10 comments

Comments

@admilazz
Copy link

The Go code coverage disappears when typing a character. This is implemented in removeCodeCoverageOnFileChange in goCover.ts. I find this very annoying, since I want to run the code coverage and then go through it and update the unit tests to add the missing tests, but as soon as I type a character in the unit test, the coverage information disappears.

I suggest that the code coverage should be removed when a Go file is saved, rather than when a character is typed. After all, the comment in the source saying that the code coverage is stale when a file is changed is false. The code coverage only becomes stale when the change is committed to disk (and would thus affect the result of compilation).

Alternately, please provide an option to disable removeCodeCoverageOnFileChange.

My current workaround is to change the language of the unit test file(s) from Go to plain text so it doesn't trigger the problem and then change back to Go before running the tests. It's not very nice.

@ramya-rao-a
Copy link
Contributor

Thanks for reporting @admilazz

I suggest that the code coverage should be removed when a Go file is saved, rather than when a character is typed

That is a good suggestion, and PRs are most welcome to make this change

Code Pointers:

@alanlal
Copy link

alanlal commented Jun 4, 2019

Hi , I would like to take this one up. 😄

@ramya-rao-a
Copy link
Contributor

Go ahead @alanlal!

@alanlal
Copy link

alanlal commented Jun 5, 2019

Hi @ramya-rao-a

When I try to launch the extension as per the instructions, I'm getting the following error in the debug console.

Activating extension `ms-vscode.Go` failed: Cannot find module 'c:\Users\alanl\Documents\vscode-go\out\src\goMain'

The same error pops up in the [Extension development host] vscode window as well.

issue-1

@ramya-rao-a
Copy link
Contributor

Does that file exist?

@alanlal
Copy link

alanlal commented Jun 6, 2019

There is goMain.ts present in vscode-go/src/ but there is no directory as vscode-go/out/src/ which is causing the error.

@alanlal
Copy link

alanlal commented Jun 18, 2019

There is goMain.ts present in vscode-go/src/ but there is no directory as vscode-go/out/src/ which is causing the error.

Hi, I think the problem is that the typescript code is not getting compiled to the vscode-go/out/src/ folder. I did npm run compile manually and then launched the debug and it worked fine.

I'm not sure if this is a required step or am I doing something wrong here ??. Because it is not mentioned in page : Setting up local environment

@ramya-rao-a
Copy link
Contributor

It is not a required step. By default, there are tasks running that will compile the changes that are made. Maybe for some reason that task is not running for you.

@alanlal
Copy link

alanlal commented Jun 20, 2019

Hi, Made the changes and created a PR #2586 😄

kegsay pushed a commit to kegsay/vscode-go that referenced this issue Oct 22, 2019
This also preserves an earlier fix to keep coverage when the modifications
are only due to comment edits.

Supersedes microsoft#2586
kegsay added a commit to kegsay/vscode-go that referenced this issue Oct 22, 2019
This also preserves an earlier fix to keep coverage when the modifications
are only due to comment edits.

Supersedes microsoft#2586
kegsay added a commit to kegsay/vscode-go that referenced this issue Oct 22, 2019
This also preserves an earlier fix to keep coverage when the modifications
are only due to comment edits.

Supersedes microsoft#2586
kegsay added a commit to kegsay/vscode-go that referenced this issue Oct 22, 2019
This also preserves an earlier fix to keep coverage when the modifications
are only due to comment edits.

Supersedes microsoft#2586
@ramya-rao-a
Copy link
Contributor

The latest update 0.14.2 has the fix for this, Thanks @kegsay

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

4 participants