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

Error Failed to parse string #150

Closed Licen-it closed 5 years ago

Licen-it commented 6 years ago

I'm always getting this error when i try to use the extension. I tried adding the watch on lcov.info and cobertura-coverage.xml, but the error is the same and nothing get displayed on the source code.

Here is the screenshot of the extension output: image

ryanluker commented 6 years ago

@Licen-it thanks for submitting an issue! this is related to the score logic that was added recently and should be fixed in the next version of the extension I am working on (2.1.0). In the meantime you could try just loading lcov.info to see if that will help you til next release.

Licen-it commented 6 years ago

@ryanluker Thanks for your answer. Would you guide me on how to load lcov.info? Because using the watch button it produces the same error

ryanluker commented 6 years ago

@Licen-it hmm the only other thing i would try before 2.1.0 would be to open the example workspace project here in this repo and see if the coverage shows up for you or not.

ryanluker commented 6 years ago

@Licen-it 2.1.0 is being released this afternoon (pst) to the marketplace. let me know if this release doesn't fix your issue and we can reopen the ticket and do some more investigating.

Licen-it commented 6 years ago

@ryanluker i can still reproduce both with lcov.info and cobertura-coverage.xml

I'm wondering, is there any specific structure the plugin is expecting to find? because in the example project it's working fine, but i see that all the files are in the same folder, there is no hierarchy (I can't find any mention of a specific folder structure in the plugin description).

ryanluker commented 6 years ago

@Licen-it ahh yes the plugin does not look outside the project / workspace folder when it does the collection phase https://github.com/ryanluker/vscode-coverage-gutters/blob/master/src/filesloader.ts#L86 this is mainly to prevent looking everywhere in your computer for coverage files but I could imagine a feature where you say where your coverage folder is located and it wouldnt use the glob find in that case. Let me think about this for the 2.1.1 release but in the meantime can you not include your coverage inside your project folder?

Licen-it commented 6 years ago

@ryanluker ok...but i was wondering why aren't you using the paths in the coverage files (i can see lcov.info for each file provides the full path while cobertura-coverage.xml provides the top level folder path and then relative paths to each file)

Licen-it commented 6 years ago

Anyway i just checked putting the coverage file on top level folder and still not working...i'm still getting the Failed to parse string error

ryanluker commented 6 years ago

@Licen-it the reasoning for not using the full paths in the cobertura one is that it has an absPath value that you send in to allow the parser to attach the absolute path when it returns you the coverage objects (https://github.com/ryanluker/vscode-coverage-gutters/commit/deee3d123769ea16c267d10e13290107dd8cbcfa#diff-3661d843d67f46cb9cfd476ad7e1920cR37). when you moved the coverage file (cobertura-coverage.xml to inside the workspace folder did you also set the xmlname setting and restart your IDE? temp2

Licen-it commented 6 years ago

@ryanluker nope. I moved the lcov.info top level...but maybe it's because i have multiple projects in my workspace and each of them have an lcov.info

ryanluker commented 6 years ago

@Licen-it thanks for getting back so quickly. hmm well I will take a look at this with the 2.1.1 bug fix release, the only other thing you could do is make an example repository with the reproducible bug to assist me in figuring out the issue or you could also run the extension in development mode locally and debug your project to see where that failed to parse string is coming from 😄 https://code.visualstudio.com/docs/extensions/developing-extensions#_running-and-debugging-your-extension

Licen-it commented 6 years ago

@ryanluker so workspace is structured as follows:

workspace
|___project1
|     |___coverage
|     |     |___lcov-report (dir with html report)
|     |     |___cobertura-coverage.xml
|     |     |___coverage-final.json
|     |     |___lcov.info
|     |___src (dir with all the code)
|     |___tests (dir with all tests)
|___project2
|     |___coverage
|     |     |___lcov-report (dir with html report)
|     |     |___cobertura-coverage.xml
|     |     |___coverage-final.json
|     |     |___lcov.info
|     |___src (dir with all the code)
|     |___tests (dir with all tests)
|___project3
|     |___coverage
|     |     |___lcov-report (dir with html report)
|     |     |___cobertura-coverage.xml
|     |     |___coverage-final.json
|     |     |___lcov.info
|     |___src (dir with all the code)
|     |___tests (dir with all tests)
ryanluker commented 6 years ago

@Licen-it I have done some rework on the coverage parsing and this maybe fixed in the next release (2.2.0) once it is out let me know if this is still an issue!

Licen-it commented 6 years ago

@ryanluker sorry for the long wait, i was able to check this just now, and i can still reproduce the issue

ryanluker commented 5 years ago

@Licen-it with the latest release (2.2.2) can you try to run the watch command on your project workspace again and paste the output from the gutters console tab like you did in the original ticket?

Licen-it commented 5 years ago

@ryanluker here you are...i noticed it's taking longer before falling into the error

image

ryanluker commented 5 years ago

@Licen-it thanks for the further info, we are getting closer. Can you install the (in development) 2.3.0 version of the extension below and paste the results from that? vscode-coverage-gutters-2.3.0.zip

Licen-it commented 5 years ago

@ryanluker same output: image

ryanluker commented 5 years ago

@Licen-it thanks for the continual assistance on this one, looks like @DW8Reaper has a new fix (https://github.com/ryanluker/vscode-coverage-gutters/pull/191) that may also help with your issues. I will message again once I have a new 2.3.0 pre-release for you to try.

ryanluker commented 5 years ago

@Licen-it the fix mentioned above has been added to the 2.3.0 release, I have include a pre-release version of that below for you to try when you have some free time. The fix will only work for lcov files currently but I plan to use the same fix @DW8Reaper applied but for the other coverage types as well.

vscode-coverage-gutters-2.3.0.zip

Licen-it commented 5 years ago

@ryanluker with this version there is no error like the one in the console, the log stops at Loaded 30 data file(s) but no coverage appears in the files and removing the watch i'm getting this error message but still nothing in the output: image

DW8Reaper commented 5 years ago

@Licen-it check if any of your coverage filenames in vscode settings are empty. I had an issue where I cleared the xml config path which ended up trying to read every file in my repo as a coverage file. I actually got an error message though so might not be the same issue (https://github.com/ryanluker/vscode-coverage-gutters/pull/192)

orsaz commented 5 years ago

image I still get this error. Does lcov.info and cov.xml files have to be empty or i need to write something there?

DW8Reaper commented 5 years ago

Looks better now the Loading 2 file(s) vs Loading 30 file(s) you had before. Now the fix I put in was only for lcov files not xml but @ryanluker was going to add it to the other types as well. If you have an lcov you can use perhaps put an invalid filename in to the xml field that way the file won't be found and won't load. This again is just a work around to try till the issue is fixed.

Licen-it commented 5 years ago

@DW8Reaper no i don't have any empty coverage filename in the settings

DW8Reaper commented 5 years ago

Shucks, must be a different issue then was hoping it would be the same one I had.

ryanluker commented 5 years ago

@Licen-it @orsaz Thanks for keeping this ticket active! I have a new version below that has @DW8Reaper 's changes plus a couple of other refinements to the error handling in the parsers. Let me know how it looks! vscode-coverage-gutters-2.3.0.zip

Licen-it commented 5 years ago

@ryanluker i'm getting the same error i mentioned in my comment above and still no gutters showing the code coverage.

image

Licen-it commented 5 years ago

@ryanluker any update on this?

ryanluker commented 5 years ago

@Licen-it sorry this must have slipped through the cracks... it is still an issue with the latest version of the extension? Also can you paste the output from the extension log, when it has errored, as well?

Licen-it commented 5 years ago

@ryanluker same issues as before with version 2.3.0...the screenshots above are still valid (i'm getting the same errors/logs). So when i hit Watch having lcov.info selected it loads correctly as showed below, but no gutters showing the code coverage. When i hit Remove Watch the error message in the picture in my comment on Dec 5th appears.

image

ryanluker commented 5 years ago

@Licen-it still looking into this one but I cannot reproduce it myself locally still, sadly. I have added additional logging here 4298597cba57e73cd22d3bf6aaf5edf6cea54a00 and it will be in the 2.3.1 release coming shortly. Hopefully in that new version we will get more insight where your error message is coming from.

Licen-it commented 5 years ago

@ryanluker here is the exception log when i remove the watch:

[1551281968268][coverageservice]: INITIALIZING
[1551284657194][coverageservice]: LOADING
[1551284674657][coverageservice]: Loading 38 file(s)
[1551284674680][coverageservice]: Loaded 38 data file(s)
[1551284706323][removeWatch]: Cannot read property 'dispose' of undefined
[1551284706323][removeWatch]: TypeError: Cannot read property 'dispose' of undefined
    at CoverageService.dispose (/Users/licen/.vscode/extensions/ryanluker.vscode-coverage-gutters-2.3.1/out/src/coverage-system/coverageservice.js:37:30)
    at Gutters.removeWatch (/Users/licen/.vscode/extensions/ryanluker.vscode-coverage-gutters-2.3.1/out/src/extension/gutters.js:72:34)
    at vscode.commands.registerCommand (/Users/licen/.vscode/extensions/ryanluker.vscode-coverage-gutters-2.3.1/out/src/extension.js:28:17)
    at e._executeContributedCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:485:959)
    at e.$executeContributedCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:486:443)
    at t._doInvokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:644:118)
    at t._invokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:643:744)
    at t._receiveRequest (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:642:322)
    at t._receiveOneMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:641:155)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:638:960
    at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:38:994
    at e.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:44:113)
    at a (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:170:213)
    at Socket.f._socketDataListener (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:170:434)
    at Socket.emit (events.js:182:13)
    at Socket.EventEmitter.emit (domain.js:442:20)
    at addChunk (_stream_readable.js:279:12)
    at readableAddChunk (_stream_readable.js:264:11)
    at Socket.Readable.push (_stream_readable.js:219:10)
    at Pipe.onread (net.js:636:20)

And still no gutters appearing

ryanluker commented 5 years ago

@Licen-it it is odd you see the loaded data files message but nothing related to caching :thinking: see my local example run below.

[1553982083011][coverageservice]: INITIALIZING
[1553982096718][coverageservice]: LOADING
[1553982096789][coverageservice]: Loading 4 file(s)
[1553982096790][coverageservice]: Loaded 4 data file(s)
[1553982096813][coverageservice]: Caching 11 coverage(s)
[1553982096813][printDataCoverage]: Coverage ->
[1553982096813][printDataCoverage]: {
    "lines": {
         <coverage omitted>
    }

This usually means that one of the parsers encountered an error or is very slow (can you try again but wait for a while to see if anything finishes?). Also I recently did some cleanup of the cobertura-parse (which you would be using behind the scenes, based on some of the previous pictures in this thread) so maybe try the build below and get back to me if anything changes!

vscode-coverage-gutters-2.4.0.zip

Licen-it commented 5 years ago

@ryanluker after 2h still nothing after Loaded 38 data file(s)

ermshiperete commented 5 years ago

Same for me. Gutters not showing. In the developer tools console I see the following exception:

mainThreadExtensionService.ts:49 [[object Object]]Cannot create property 'message' on string 'Failed to parse string'
mainThreadExtensionService.ts:50 TypeError: Cannot create property 'message' on string 'Failed to parse string'
    at checkError (/home/user/.vscode/extensions/ryanluker.vscode-coverage-gutters-2.3.1/out/src/files/coverageparser.js:134)
    at CoverageParser.<anonymous> (/home/user/.vscode/extensions/ryanluker.vscode-coverage-gutters-2.3.1/out/src/files/coverageparser.js:141)
    at Generator.next (<anonymous>)
    at __awaiter (/home/user/.vscode/extensions/ryanluker.vscode-coverage-gutters-2.3.1/out/src/files/coverageparser.js:7)
    at new Promise (<anonymous>)
    at __awaiter (/home/user/.vscode/extensions/ryanluker.vscode-coverage-gutters-2.3.1/out/src/files/coverageparser.js:3)
    at lcovExtract.lcov_parse_1.source (/home/user/.vscode/extensions/ryanluker.vscode-coverage-gutters-2.3.1/out/src/files/coverageparser.js:140)
    at Function.walkFile [as source] (/home/user/.vscode/extensions/ryanluker.vscode-coverage-gutters-2.3.1/node_modules/lcov-parse/lib/index.js:108)
    at lcovExtract.Promise (/home/user/.vscode/extensions/ryanluker.vscode-coverage-gutters-2.3.1/out/src/files/coverageparser.js:140)
    at new Promise (<anonymous>)
    at CoverageParser.lcovExtract (/home/user/.vscode/extensions/ryanluker.vscode-coverage-gutters-2.3.1/out/src/files/coverageparser.js:131)
    at CoverageParser.<anonymous> (/home/user/.vscode/extensions/ryanluker.vscode-coverage-gutters-2.3.1/out/src/files/coverageparser.js:48)
    at Generator.next (<anonymous>)
    at fulfilled (/home/user/.vscode/extensions/ryanluker.vscode-coverage-gutters-2.3.1/out/src/files/coverageparser.js:4)

(same exception happens with 2.4.0)

ryanluker commented 5 years ago

@Licen-it opps I should have given you a time range to wait for (2min was more my thinking, sorry!). We might be getting closer with @ermshiperete comment (thanks for this!) showing the more extensive stack trace. I will continue looking into this over the weekend!

ermshiperete commented 5 years ago

PR #215 fixes things, at least in my case.

ryanluker commented 5 years ago

@Licen-it can you try this new version below that includes @ermshiperete 's fix? vscode-coverage-gutters-2.4.0-apr4.zip

Licen-it commented 5 years ago

@ryanluker this is working now. I have my coverage appearing finally. Thanks @ermshiperete for your PR. The only thing different from the video shown is that the gutters are appearing only at left side of row numbers and not in the code itself.

ryanluker commented 5 years ago

@Licen-it sweet this one is finally fixed, thanks for running the (almost 8 month long) marathon with me :laughing: ! You can modify where the coverage is displayed by turning off and of some settings, by default it is just the gutters but you can had the coverage show up inline and on the edges.

        "coverage-gutters.showLineCoverage": {
          "type": "boolean",
          "default": false,
          "description": "show or hide the line coverage"
        },
        "coverage-gutters.showRulerCoverage": {
          "type": "boolean",
          "default": false,
          "description": "show or hide the ruler coverage"
        },
        "coverage-gutters.showGutterCoverage": {
          "type": "boolean",
          "default": true,
          "description": "show or hide the gutter coverage"
        },