pocesar / grunt-mocha-istanbul

Almost config-free Istanbul code coverage reporter for Mocha usage in Grunt
MIT License
75 stars 23 forks source link

Path in lcov report is incorrect #31

Closed nerdgore closed 9 years ago

nerdgore commented 9 years ago

I would expect the paths in the lcov report (and all other reports) to be relative to the root folder I define in the config. My file structure looks like this:

|-libs
| |-app.js
| |-util.js

I would expect that the lcov output looks somewhat like this: SF:libs/app.js However, I get this: SF:/Users/username/workspace/myprojects/my_fancy_project/libs/app.js

Am I missing something or is this the expected behaviour?

For reference, this is what I have in my gruntfile.js.

options: {
    coverage: true,
    coverageFolder: "reports",
    reportFormats: ["text", "cobertura", "lcovonly"],
    require: "should",
    root: "./"
}
pocesar commented 9 years ago

does it change if you set root to '.' or './libs'? the full path shouldn't be inside the lcov, it seems to have been fixed by istanbul a while ago according to https://github.com/gotwarlost/istanbul/issues/104

nerdgore commented 9 years ago

It seems I should have read the lcov spec beforehand. I was expecting the path to be relative to the root, however it seems this only controls which files are instrumented and that the absolute path in the report is correct.

pocesar commented 9 years ago

alright, I didn't even know that, thanks for clearing out

vptech20nn commented 8 years ago

Is there a option which will allow us to choose relative or absolute path ? I am getting absolute paths.

RobotLimeLtd commented 8 years ago

I would also like to know if there's an option - I'm trying to get two projects to work with SonarQube, one is producing relative paths in lcov.info, the other absolute paths. I can't tell what difference is causing this.

I generally build NPM in a separate build stage to running Sonar tests. This allows me to get instant unit test failure feedback more quickly. During the 1st build job, I zip up enough of the local directory to run Sonar and pull that into the next stage. The problem with absolute paths is that they point to the build directory of a different job, and are thus invalid in the new job!

I can work around this with a nasty sed hack, but I'd rather find out what change I can make to the karma conf file to choose relative paths.