Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remotePathResolve not working on VS Code Windows with a coverage.xml file using Unix paths #400

Open
denisrossetre opened this issue Apr 3, 2023 · 5 comments

Comments

@denisrossetre
Copy link

Describe the bug

remotePathResolve does not seem to work when having a coverage.xml file with Unix paths and the VS Code Coverage Gutters extension running on Windows.

To Reproduce

  1. Run the tests of a Python project in a Docker container using Linux, which produces a coverage.xml file. The coverage file has a line <sources><source>/opt/myproject</source></sources> and the rest of the paths are relative (in the <package name="src.module"> XML entities).
  2. Have a line with "coverage-gutters.remotePathResolve": ["/opt/local", "c:/Users/myusername/projects/myprojectname"], in the VS Code settings.json file.
  3. Open any source code file which has coverage.
  4. Click on the coverage bottom bar button to refresh the coverage, the result is an empty circle with "No Coverage".

Note that the extension works when replacing <sources><source>/opt/myproject</source></sources> by <sources><source>.</source></sources> and removing the remotePathResolve setting.

Expected behaviour

Coverage shows.

Screenshots

No screenshots because of nature of the code. I could provide a reproducible example if needed.

Desktop (please complete the following information):

  • OS: Windows 10 for VS Code, the coverage file is produced on Debian 11, pytest 6.2.5, coverage 7.1.0 and pytest-cov 3.0.0
  • Extension Version 2.10.4
  • VSCode Version 1.76.2

Additional context

I'd be very happy to get extra logs about how the coverage.xml path is interpreted and when/if it is translated by remotePathResolve. Right now, I'm debugging in the dark.

@ryanluker
Copy link
Owner

@denisrossetre Thanks for the ticket! Are you able to grab more logs from the extension output log area?
Screenshot from 2023-04-08 14-43-12

In terms of extra logging, check out this area, and you could maybe remove the .size to print the whole cache and that would assist us in figuring out what is inside (this should really be an extension setting to enable "verbose" logging mode but sadly haven't got to that yet 😓).

const dataCoverage = await this.coverageParser.filesToSections(dataFiles);
this.outputChannel.appendLine(
`[${Date.now()}][coverageservice]: Caching ${dataCoverage.size} coverage(s)`,
);
this.cache = dataCoverage;

@denisrossetre
Copy link
Author

denisrossetre commented Apr 17, 2023

Actually, I solved the problem! The thing is that the path parsing will be done on a Unix path in a Windows system.

By changing the value
"coverage-gutters.remotePathResolve": ["/opt/local", "c:/Users/myusername/projects/myprojectname"]
to
"coverage-gutters.remotePathResolve": ["\\opt\\local", "."]
the problem disappeared (the second value "." does not matter so much, but I prefer relative paths for the local dev system as they are more stable).

To close this issue, I'd like to write a bit of documentation for the remotePathResolve setting. Would you accept a PR, and if so, where should I put the documentation?

@ryanluker
Copy link
Owner

ryanluker commented Apr 17, 2023

Actually, I solved the problem! The thing is that the path parsing will be done on a Unix path in a Windows system.

By changing the value "coverage-gutters.remotePathResolve": ["/opt/local", "c:/Users/myusername/projects/myprojectname"] to "coverage-gutters.remotePathResolve": ["\\opt\\local", "."] the problem disappeared (the second value "." does not matter so much, but I prefer relative paths for the local dev system as they are more stable.

To close this issue, I'd like to write a bit of documentation for the remotePathResolve setting. Would you accept a PR, and if so, where should I put the documentation?

I am glad you got it figured out 👍🏻 !
More documentation is always welcome, so PR will definitely be accepted, thanks.

I think the tips and tricks section would be a good fit? It gets great SEO from being on the front page + in the marketplace.
https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters
https://github.com/ryanluker/vscode-coverage-gutters#tips-and-tricks

@ralittl
Copy link

ralittl commented Oct 24, 2023

@denisrossetre I'm encountering the same issue that you were -- I'm using Windows 10, and I have a docker container running Linux, but coverage gutters isn't showing the code coverage in VSC.

I tried using your fix, here is my settings.json

"coverage-gutters.coverageFileNames": [
        "coverage.xml",
        "lcov.info",
        "cov.xml",
        "jacoco.xml"
    ],
    "coverage-gutters.remotePathResolve": [
        
        [
            "\\home\\dev\\Mxxxx",
            "."
        ]
    ]

The /home/dev/M... path is what I'm using in the container.

In the CG log I see this:

[1698181260483][coverageservice]: c:\Users\Exxxxxxxx\gitlab\Mxxxx\coverage.xml
[1698181260483][coverageservice]: Loaded 1 data file(s)
[1698181260488][coverageservice]: Caching 6 coverage(s)
[1698181260488][coverageservice]: READY
[1698181260488][coverageservice]: RENDERING
[1698181260488][coverageservice]: READY

so I know that it's picking up my coverage file, but there's just still no visual indication on the file, and the bottom bar still shows "No coverage".

Did you end up having to do anything else other than changing this setting, to fix the issue? I'm running Coverage Gutters v2.11.0

@ryanluker
Copy link
Owner

@denisrossetre I'm encountering the same issue that you were -- I'm using Windows 10, and I have a docker container running Linux, but coverage gutters isn't showing the code coverage in VSC.

I tried using your fix, here is my settings.json

"coverage-gutters.coverageFileNames": [
        "coverage.xml",
        "lcov.info",
        "cov.xml",
        "jacoco.xml"
    ],
    "coverage-gutters.remotePathResolve": [
        
        [
            "\\home\\dev\\Mxxxx",
            "."
        ]
    ]

The /home/dev/M... path is what I'm using in the container.

In the CG log I see this:

[1698181260483][coverageservice]: c:\Users\Exxxxxxxx\gitlab\Mxxxx\coverage.xml
[1698181260483][coverageservice]: Loaded 1 data file(s)
[1698181260488][coverageservice]: Caching 6 coverage(s)
[1698181260488][coverageservice]: READY
[1698181260488][coverageservice]: RENDERING
[1698181260488][coverageservice]: READY

so I know that it's picking up my coverage file, but there's just still no visual indication on the file, and the bottom bar still shows "No coverage".

Did you end up having to do anything else other than changing this setting, to fix the issue? I'm running Coverage Gutters v2.11.0

@ralittl Hmm I think you might want to try one level of array instead?
"coverage-gutters.remotePathResolve": ["\\home\\dev\\Mxxxx", "."]

Also, once you get the system working, try out the watch button in the bottom status bar and you should get an output similar to the following:

[1699830894119][coverageservice]: INITIALIZING
[1699830925569][coverageservice]: LOADING
[1699830925644][coverageservice]: Loading 7 file(s)
[1699830925644][coverageservice]: /home/ryan/Dev/vscode-coverage-gutters/example/node/lcov.info,/home/ryan/Dev/vscode-coverage-gutters/example/remote-node/lcov.info,/home/ryan/Dev/vscode-coverage-gutters/example/ruby/lcov.info,/home/ryan/Dev/vscode-coverage-gutters/example/java/my-app/cov.xml,/home/ryan/Dev/vscode-coverage-gutters/example/php/cov.xml,/home/ryan/Dev/vscode-coverage-gutters/example/python/cov.xml,/home/ryan/Dev/vscode-coverage-gutters/example/multimodule-java/jacoco.xml
[1699830925646][coverageservice]: Loaded 7 data file(s)
[1699830925670][coverageservice]: Caching 19 coverage(s)
[1699830925670][coverageservice]: READY
[1699830925670][coverageservice]: RENDERING
[1699830925670][renderer][section file path]: ./node/test.js
[1699830925671][renderer][section file path]: ./node/test.js
[1699830925671][coverageservice]: READY
[1699830925671][coverageservice]: Listening to file system at {/home/ryan/Dev/vscode-coverage-gutters/example}/**/{lcov.info,cov.xml,coverage.xml,jacoco.xml,coverage.cobertura.xml}
[1699830933310][coverageservice]: RENDERING
[1699830933311][renderer][section file path]: ./node/test.js
[1699830933311][coverageservice]: READY

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

No branches or pull requests

3 participants