ryanluker / vscode-coverage-gutters

Display test coverage generated by lcov and xml - works with many languages
https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters
MIT License
460 stars 88 forks source link

Coverage is not visible on VSCode - Flutter #160

Closed diegoveloper closed 5 years ago

diegoveloper commented 6 years ago

I was using this plugin months ago and It was working perfect, now I can't see the coverage of my code. Flutter - Dart. I'm using the latest version v2.1.1 The coverage is generated under the folder /coverage/lcov.info

diegoveloper commented 6 years ago

Log:

[1533879408910][coverageservice]: Loading 1 file(s) [1533879408922][coverageservice]: Caching 66 coverage(s)

[1533879428404][coverageservice]: Loading 1 file(s) [1533879428409][coverageservice]: Caching 72 coverage(s)

[1533879442636][coverageservice]: Loading 1 file(s) [1533879442639][coverageservice]: Caching 72 coverage(s)

looking the log seems like it is working but nothing happens on the IDE

ghost commented 6 years ago

I have the same issue but with Javascript.

Downgrading to 2.0.1 restores functionality.

ryanluker commented 6 years ago

@diegoveloper thanks for the issue and the extra information, I will hopefully get some free time to take a look at this in the near future. In the meantime (like @MoxyFruzy said) you can manually install one of the previous releases using the vsix isntall method https://code.visualstudio.com/docs/editor/extension-gallery#_install-from-a-vsix . Also if you are able to confirm that you can see the coverage in the example folder (for this project) that will help narrow down the possibilities. Finally any examples of your coverage files (lcov.info or xml ones) would assist in the investigation too.

diegoveloper commented 6 years ago

Ok, looks like version 2.0.0 is working fine for me. >= 2.0.1 not working at all. info file attached lcov.info.zip

kevcunnane commented 6 years ago

+1 on this issue. Installing v2.0.0 as a workaround solved it. In my case the coverage files are under a ./coverage/lcov.info path relative to the project root. I'm also using a workspace (2 folders) rather than a simple single folder. I hope some of this helps in finding the root cause.

kevcunnane commented 6 years ago

An update: I believe the error is caused (for me) by stricter path checking implemented in #159. What's happening:

So, for me at least it's an incorrect coverage file, but this used to work on 2.0.0. I successfully fixed this in my own code, but it'd be great if the "just works" functionality in the older version was preserved since it seems a common issue.

ryanluker commented 6 years ago

@kevcunnane thanks for the extra info! The trade off between "just works" and works correctly was something that was troubling me with the 2.0 release. I also got quite a few tickets related to the naive relative comparison version that was in 2.0 ( #157 , #156 , #155 ).

The more I think about it, we almost need an absolute path option that people can set, in their settings conf, that would cause the extension to just load those files in question (would be an opt in feature though as the majority of users seem to do fine with the files being auto found).

That has other issues though as well, in that vscode is optimized for file access when those files live inside a folder or workspace that you have open in the IDE (this is how the watch api works nicely https://github.com/ryanluker/vscode-coverage-gutters/blob/master/src/coverageservice.ts#L121-L135).

Anyways hopefully I can get some time soon to do another release (2.2.0) with an absolute file path option...

ryanluker commented 6 years ago

@kevcunnane @diegoveloper @MoxyFruzy Figured out a way to deal with the partial files inside the coverage parser (if you are curious https://github.com/ryanluker/vscode-coverage-gutters/pull/165/files#diff-dcbb46bda55c6e4bdd02baa111139b40R90) in the next release (2.2.0) this should be fixed!

diegoveloper commented 6 years ago

@ryanluker I updated to 2.2.0, but it doesn't work :(

Log:

[1537203849570][coverageservice]: Loading 1 file(s) [1537203849570][coverageservice]: Loading 1 file(s) [1537203849576][coverageservice]: Caching 133 coverage(s)

[1537203849583][coverageservice]: Caching 133 coverage(s)

diegoveloper commented 6 years ago

@ryanluker Should I create a new issue?

ryanluker commented 6 years ago

@diegoveloper I can re-open this one seeming it isn't fixed yet. Can you run through the instructions here https://github.com/ryanluker/vscode-coverage-gutters/issues/161#issuecomment-422627177 and paste the results you get? I am thinking it isn't something related to dart specifically but it would help if I could get it to reliable fail so I may need to setup a basic dart project and generate some coverage. In addition to the extra logs, could you also send me your settings for the extension (coverage-gutters.xmlname and coverage-gutters.lcovname)?

diegoveloper commented 6 years ago

JAVA

[1537415902909][coverageservice]: Loading 4 file(s) [1537415902956][lcovparser][convertPartialPathsToAbsolute]: Error: Found too many files with partial path init.py [1537415903006][coverageservice]: Caching 11 coverage(s)

NODE

Settings

` // DEPRECATED: uses a relative method of comparing lcov source file paths "coverage-gutters.altSfCompare": true,

// enable or disable the keybinding shortcut for enabling coverage on the active file "coverage-gutters.customizable.keybindings-displayCoverage-enabled": true,

// enable or disable the keybinding shortcut for previewing the lcov report "coverage-gutters.customizable.keybindings-previewCoverageReport-enabled": true,

// enable or disable the keybinding shortcut for removing the coverage on the active file "coverage-gutters.customizable.keybindings-removeCoverage-enabled": true,

// enable or disable the keybinding shortcut for removing the watch on lcov and editors "coverage-gutters.customizable.keybindings-removeWatch-enabled": true,

// enable or disable the keybinding shortcut for watching the lcov file and visible editors "coverage-gutters.customizable.keybindings-watchCoverageAndVisibleEditors-enabled": true,

// enable or disable the displayCoverage command in the editor/context menu "coverage-gutters.customizable.menus-editor-context-displayCoverage-enabled": true,

// enable or disable the previewCoverageReport command in the editor/context menu "coverage-gutters.customizable.menus-editor-context-previewCoverageReport-enabled": true,

// enable or disable the removeCoverage command in the editor/context menu "coverage-gutters.customizable.menus-editor-context-removeCoverage-enabled": true,

// enable or disable the removeWatch command in the editor/context menu "coverage-gutters.customizable.menus-editor-context-removeWatch-enabled": true,

// enable or disable the watchCoverageAndVisibleEditors command in the editor/context menu "coverage-gutters.customizable.menus-editor-context-watchCoverageAndVisibleEditors-enabled": true,

// enable or disable the status bar item "coverage-gutters.customizable.status-bar-toggler-watchCoverageAndVisibleEditors-enabled": true,

// path to an icon (svg, png, etc) for displaying in the gutter for full coverage "coverage-gutters.gutterIconPathDark": "./app_images/gutter-icon-dark.svg",

// path to an icon (svg, png, etc) for displaying in the gutter for full coverage "coverage-gutters.gutterIconPathLight": "./app_images/gutter-icon-light.svg",

// dark themed highlight for code coverage "coverage-gutters.highlightdark": "rgba(45, 121, 10, 0.75)",

// light themed highlight for code coverage "coverage-gutters.highlightlight": "rgba(166, 220, 142, 0.75)",

// name of your lcov file "coverage-gutters.lcovname": "lcov.info",

// path to an icon (svg, png, etc) for displaying in the gutter for no coverage "coverage-gutters.noGutterIconPathDark": "./app_images/no-gutter-icon-dark.svg",

// path to an icon (svg, png, etc) for displaying in the gutter for no coverage "coverage-gutters.noGutterIconPathLight": "./app_images/no-gutter-icon-light.svg",

// dark theme partial highlight for code coverage "coverage-gutters.noHighlightDark": "rgba(121, 31, 10, 0.75)",

// light theme partial highlight for code coverage "coverage-gutters.noHighlightLight": "rgba(220, 143, 143, 0.75)",

// path to an icon (svg, png, etc) for displaying in the gutter for partial coverage "coverage-gutters.partialGutterIconPathDark": "./app_images/partial-gutter-icon-dark.svg",

// path to an icon (svg, png, etc) for displaying in the gutter for partial coverage "coverage-gutters.partialGutterIconPathLight": "./app_images/partial-gutter-icon-light.svg",

// dark theme partial highlight for code coverage "coverage-gutters.partialHighlightDark": "rgba(121, 86, 10, 0.75)",

// light theme partial highlight for code coverage "coverage-gutters.partialHighlightLight": "rgba(220, 213, 143, 0.75)",

// show or hide the gutter coverage "coverage-gutters.showGutterCoverage": true,

// show or hide the line coverage "coverage-gutters.showLineCoverage": false,

// show or hide the ruler coverage "coverage-gutters.showRulerCoverage": false,

// name of your xml file "coverage-gutters.xmlname": "cov.xml"`

ryanluker commented 6 years ago

@diegoveloper thanks looks like the example projects are working for you, I will have a look at setting up a simple dart flutter project and hopefully replicate your issue then include that in the next release 2.2.1 or 2.3.0

diegoveloper commented 6 years ago

@ryanluker thank you!!

ryanluker commented 6 years ago

@diegoveloper I couldn't reproduce the issue locally with a simple flutter project and using flutter test --coverage. Lets not give up yet though! Go through the steps below and paste the results for me: 1) run the extension in debug mode using the repository you cloned earlier [0a] [0b] and add a breakpoint at this file location (sectionFinder.ts: line 39) [2]. 2) in the debug vscode window (the one that opens when you click launch extension) open your flutter project and navigate to a file that you know has test coverage. 3) start the watch command to activate the extension. 4) when the debugger pauses on line 39 look in the debug tab and copy the variables related to the files being compared then paste them here (you maybe have to advance to the next breakpoint a few times until you get to some that match the file you have open) [1]. 5) paste these values (editorFile, sectionFile) here so we can see what is being compared and why they are not matching for you.

Let me know if you need more instructions around grabbing these debug values.

[0a] https://code.visualstudio.com/docs/extensions/developing-extensions#_running-and-debugging-your-extension

[0b] screenshot from 2018-09-23 09-31-38

[1] screenshot from 2018-09-23 09-47-34

[2] https://github.com/ryanluker/vscode-coverage-gutters/blob/master/src/coverage-system/sectionFinder.ts#L39

apaatsio commented 6 years ago

I have the same problem and I'm seeing values like:

workspaceFolder.name: my_project
sectionFile:          lib###bloc###model.dart
editorFile:           ###home###antti###projects###my_project###lib###bloc###model.dart

Coverage Gutters: 2.2.0 VSCode: 1.27.2 Flutter: 0.8.2 OS: Linux

ryanluker commented 6 years ago

@apaatsio ahh I think this is due to not having the lcov parser use the new relative path attacher I made in the last release [0]. I can clean this up and put it into 2.1.1! [0] https://github.com/ryanluker/vscode-coverage-gutters/blob/master/src/files/coverageparser.ts#L124

karn09 commented 5 years ago

I opened a PR https://github.com/ryanluker/vscode-coverage-gutters/pull/173, as I was seeing similar issues and went down a bit of a rabbit hole. If anyone seeing this issue still could post a piece of their LCOV file, that could be super helpful as the path definition in there was the source of the issue for me.

Good lcov.info path => SF:/home/ryanluker/dev/vscode-coverage-gutters/example/node/test-coverage.js

Bad lcov.info path => SF:./example/node/test-coverage.js

ryanluker commented 5 years ago

@diegoveloper @karn09 @apaatsio @kevcunnane @MoxyFruzy The next release (2.2.1) will be going out today, it will have improvements to the partial path resolution for all code languages and should solve this issue! I will close it for now but if new / similar issues appear I am more then happy to reopen this.

Syntactical01 commented 4 years ago

It appears I am still having this issue for python. I don't have any special settings specified and the logs appear to be normal but none of the lines highlight. It works if I roll back to 2.0.0. I have a cov.xml file at the top level which it should find easily.

[1581688014703][coverageservice]: INITIALIZING
[1581688020981][coverageservice]: LOADING
[1581688027766][coverageservice]: Loading 1 file(s)
[1581688027767][coverageservice]: Loaded 1 data file(s)
[1581688027792][coverageservice]: Caching 22 coverage(s)
[1581688027792][printDataCoverage]: Coverage -> 22
[1581688027792][coverageservice]: READY
[1581688027792][coverageservice]: RENDERING
[1581688027793][coverageservice]: READY

2.0.0: image

2.4.3: image

ryanluker commented 4 years ago

@Syntactical01 it will be easier to diagnose your issue if you open a new ticket please :grin: . it would also help to see some example paths from your cov.xml to help with figuring out the issue.