vscode-coverage-gutters icon indicating copy to clipboard operation
vscode-coverage-gutters copied to clipboard

Suddenly stopped working

Open robross0606 opened this issue 1 year ago • 7 comments

Describe the bug This has been working fine for at least a year if not longer. Suddenly all my projects insist there is "No Coverage" even though my user config is set to analysis/**/index.html and the following file tree exists in the project: image

And the HTML contents look normal: image

Expected behaviour Coverage would continue to be detected as it has for the last year.

Desktop (please complete the following information):

  • OS: Windows 10.0.19045.4717
  • Extension Version 2.11.1
  • VSCode Version 1.91.1

robross0606 avatar Aug 01 '24 18:08 robross0606

@robross0606 Thanks for the ticket! Are you able to check out the extension logging and see if the extension is finding any coverage in the file paths you have specified? (these logs can be found in the output tab in the terminal and then on the right hand side there is drop down and coverage-gutters should be in there)

ryanluker avatar Sep 02 '24 17:09 ryanluker

Sorry, took me a while to circle back on this in a project where it is occurring. All I get in the logs is this:

[1726668095369][coverageservice]: LOADING
[1726668095655][coverageservice]: Loading 1 file(s)
[1726668095655][coverageservice]: c:\Code\nl\node-error-utils\analysis\lcov.info
[1726668095655][coverageservice]: Loaded 1 data file(s)
[1726668095656][coverageservice]: Caching 8 coverage(s)
[1726668095656][coverageservice]: READY
[1726668095656][coverageservice]: RENDERING
[1726668095656][coverageservice]: READY
[1726668095656][coverageservice]: Listening to file system at {c:\Code\nl\node-error-utils}/**/{lcov.info,cov.xml,coverage.xml,jacoco.xml,coverage.cobertura.xml}
[1726668097810][coverageservice]: RENDERING
[1726668097810][coverageservice]: READY

Settings look like this: image

Root of project has this: image

Opening analysis/index.html shows this (which is correct): image

Coverage gutters used to work without an issue, but now keeps saying "No Coverage".

robross0606 avatar Sep 18 '24 14:09 robross0606

I just realized that the coverage indicator on the bottom bar is showing the coverage of each opened file instead of the overall test coverage. Did it always do this? It seems strange to show "No Coverage" when no files are opened instead of showing the project's overall coverage. Why not show this when no file is open?

image

robross0606 avatar Sep 18 '24 14:09 robross0606

I also noticed that the coverage numbers in the bottom are are truncating decimals instead of rounding. For example, one of my files has 96.77% coverage but coverage gutters reports 96% coverage instead of 97%.

robross0606 avatar Sep 18 '24 14:09 robross0606

@robross0606 Interesting! I would have to rack my brain but I think the bottom coverage indicator always showed the current files covered lines. There definitely could be improvements here for the rounding, total project coverage, etc but finding dev time for improvements / open source contributions is the usual bottleneck.

Sorry, took me a while to circle back on this in a project where it is occurring. All I get in the logs is this: Those logs look correct as well and you should be able to see coverages in the gutters if you open up a specific file 🤔.

Some more debugging we can do, try to check out the example project in this repo and see if the coverage is showing up correctly there. If it is, then maybe there are some settings within your other project that is preventing the visualization.

ryanluker avatar Oct 19 '24 15:10 ryanluker

Hi @ryanluker,

I've also had this stop working and display nothing in the lines or gutters.

I don't know exactly when this happened as I haven't used it since around April... but I expected to come back to it while using my same settings and not have any problems.

Currently running the latest version: 2.14.0

I went and downloaded the example files that you have, ran through the PHP example, and it ended up working just fine.

In my project, since it still wasn't working, I commented out all other workspace and user settings, and just had:

{
  "coverage-gutters.coverageBaseDir": ".coverage",
  "coverage-gutters.showLineCoverage": true,
  "coverage-gutters.coverageFileNames": [
    "cov.xml",
  ]
}

My output was showing:

[1757543404517][coverageservice]: INITIALIZING
[1757543499537][coverageservice]: LOADING
[1757543499540][coverageservice]: Loading 1 file(s)
[1757543499540][coverageservice]: /Users/rginnow/Code/myproject/.coverage/cov.xml
[1757543499542][coverageservice]: Loaded 1 data file(s)
[1757543499793][coverageservice]: Caching 328 coverage(s)
[1757543499793][coverageservice]: READY
[1757543499793][coverageservice]: RENDERING
[1757543499795][coverageservice]: READY

And when I ran the watcher:

[1757545021773][coverageservice]: Listening to file system at {/Users/rginnow/Code/myproject}/.coverage/{cov.xml}
[1757545067326][coverageservice]: LOADING
[1757545067330][coverageservice]: Loading 1 file(s)
[1757545067330][coverageservice]: /Users/rginnow/Code/myproject/.coverage/cov.xml
[1757545067366][coverageservice]: Loaded 1 data file(s)
[1757545067643][coverageservice]: Caching 328 coverage(s)
[1757545067643][coverageservice]: READY
[1757545067643][coverageservice]: RENDERING
[1757545067647][coverageservice]: READY

Nothing seems to render. Not sure what is different except the file paths....


EDIT: it was the file paths 🤦

I went and changed the cov.xml manually to use a relative path to one of the files and it started showing coverage in the file.

My code runs in a docker container, but I edit it locally (just mount the folder as a volume). So, when PHPUnit runs coverage inside docker and builds the cov.xml, it uses the absolute path to the file from the system root (/var/www/html/app/...) rather than the relative path from the project root.

Now I just need to figure out how to get relative paths instead...

rginnow avatar Sep 11 '25 02:09 rginnow

@rginnow Thanks for the message!

It is common that folks have incorrect file paths as they often have the IDE running in a different area then the code coverage generation tool.

You should be able to leverage the following settings to add your /var/www/html/app to the file path that the extension will use 🤔.

"coverage-gutters.remotePathResolve": {
          "type": "array",
          "scope": "resource",
          "default": [],
          "description": "helps with coverage generated outside the local file system by swapping fragments of remote paths with local ones (EG ['/var/www/', '/home/project/']). See https://github.com/ryanluker/vscode-coverage-gutters/issues/201 for more info."
        },
        "coverage-gutters.manualCoverageFilePaths": {
          "type": "array",
          "scope": "resource",
          "default": [],
          "description": "take manual control over the absolute path to your coverage file(s). NOTE: this path must be the full absolute path, there is no support for the predefined path variables."
        },

ryanluker avatar Sep 27 '25 15:09 ryanluker