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

Background of covered and not covered code cannot be removed after running package test #3252

Closed
xhit opened this issue May 18, 2020 · 9 comments

Comments

@xhit
Copy link

xhit commented May 18, 2020

What version of Go, VS Code & VS Code Go extension are you using?

  • Run go version to get version of Go
    • go version go1.14.3 windows/amd64
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders
1.45.1
5763d909d5f12fe19f215cbfdd29a91c0fa9208a
x64
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.14.2
  • Run go env to get the go development environment details
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\sdelacruz\AppData\Local\go-build
set GOENV=C:\Users\sdelacruz\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\sdelacruz\Documents\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Users\sdelacruz\sdk\go1.14.3
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Users\sdelacruz\sdk\go1.14.3\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\sdelacruz\Documents\go\src\sdi\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\SDELAC~1\AppData\Local\Temp\go-build095799566=/tmp/go-build -gno-record-gcc-switches

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.

{
    "go.goroot": "C:/Users/sdelacruz/sdk/go1.14.3"
}

Describe the bug

Before Go extension 0.14.2, when I executed the run package test the covered and not covered code showed in green and red background can be restored to code without the background only editing a file. Now is not possible. I need to restart vscode to remove that background.

Steps to reproduce the behavior:

  1. Execute run package test
  2. Edit a go file in the package with covered or not covered code
@xhit
Copy link
Author

xhit commented May 18, 2020

I notice that issue #2551 is related and the PR #2853 is the root cause, so:

  • There are options to returns back to previously behavior?
  • Why maintain this background of covered code always even when new code is added and file edited?

@hyangah
Copy link
Contributor

hyangah commented May 18, 2020

@xhit does the coverage info still remain if the edited file is saved?
I believe the issue #2551 is a feature request to preserve the coverage info while typing because otherwise, it is difficult to fix code based on the coverage feedback.

@xhit
Copy link
Author

xhit commented May 18, 2020

does the coverage info still remain if the edited file is saved?

Yes.

@hyangah
Copy link
Contributor

hyangah commented May 19, 2020

Thanks. I could reproduce this as well.
@ramya-rao-a @kegsay Is this intended behavior?

@bconway
Copy link

bconway commented May 19, 2020

I would strongly support reverting this change. I thought my IDE was broken because changing code and saving would no longer remove the coverage highlighting, as it has for literally years prior.

If not, please give us a toggle to support the original behavior. I know I can bring up the menu and toggle test coverage (or set a keybinding, etc, etc), but that's a slew of new steps that weren't needed before.

@ptiger10
Copy link

I had the same experience, @blocknonip. I thought I was going crazy for about an hour - went through restarting/reinstalling everything multiple times, modifying all the coverage-related settings...

I understand the motivation for this, and can see how maintaining the highlighting during typing is potentially helpful. But from my reading of the PR, I also assumed that the coverage info would disappear if the file was saved. Instead, for me, new text is highlighted in a grayer shade of green, and I can only turn it off with the menu > toggle.

@kegsay
Copy link
Contributor

kegsay commented May 19, 2020

One of the conditionals on https://github.com/microsoft/vscode-go/pull/2853/files#diff-44e85398a1742b4d78705053c4a98671R300 must be failing - there was a long period between me making that PR and asserting its behaviour and it ended up getting merged in, so it's possible something has changed in the intervening months which breaks the PR.

hyangah added a commit to hyangah/vscode-go-old that referenced this issue May 19, 2020
This is a fix for the regression in ms-vscode.Go@0.14.2

The `isDirty` bit of the TextDocument when vscode.workspace.onDidSaveTextDocument is
already false.  Adjust the condition for clearing cache not to check it.
Modification should be tracked already by trackCodeCoverageRemovalOnFileChange.

And let modifiedFiles start with an empty value rather than as undefined.

Fixes github.com/microsoft/issues/3252.
@hyangah
Copy link
Contributor

hyangah commented May 19, 2020

@kegsay thanks for the pointer. I don't know why but I observed isDirty is never true when the callback is invoked. Can you please take a look at the linked PR?

@ramya-rao-a I sent my PR for the fix in golang/vscode-go. How do you want to handle PRs for minor bug fixes like this during the repo migration?

@ramya-rao-a
Copy link
Contributor

Sorry about this folks and thanks for the pointer to the PR @hyangah

I consider this more than a minor bug, so I went ahead with the fix and have released an update (version 0.14.3). The code coverage should be cleared on file save now.

Thanks for reporting @xhit!

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

Successfully merging a pull request may close this issue.

6 participants