gotwarlost / istanbul

Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale.
Other
8.7k stars 786 forks source link

Repeated relative part of path in lcov.info #671

Open gadicc opened 8 years ago

gadicc commented 8 years ago

I have the weirdest issue. Istanbul (1.1.0-alpha.1) is working great both locally and on all of my Circle CI deployments, except for one. Just one. That same project works fine locally. On the CI instance, the relative path is repeated inside of the absolute path, like this:

$ grep SF: coverage/lcov.info
SF:/home/ubuntu/local/src/client/src/client/index.js
SF:/home/ubuntu/local/src/client/src/client/index.spec.js
SF:/home/ubuntu/local/src/db/rethinkdbdash/src/db/rethinkdbdash/verify.js
SF:/home/ubuntu/local/src/db/rethinkdbdash/src/db/rethinkdbdash/verify.spec.js
SF:/home/ubuntu/local/src/src/resolvers.js
SF:/home/ubuntu/local/src/src/resolvers.spec.js

You can see e.g. src/client/src/client and src/src, which should be src/client and src respectively.

For now I'm just working around this with sed:

sed -r 's/SF:(.*)+(src\\/.*)\\2(.*)/SF:\\1\\2\\3/g'

I can't reproduce the issue in the same project on my own system, and all my other projects with similar configs all work fine on circle ci. Tried different node versions, OS images, etc. Guess I'm missing something. Anyway, opening this issue in case anyone else comes across this, and if perhaps the sed line might help them.

NullDivision commented 8 years ago

Can reproduce the issue using same version as of this morning.

gadicc commented 8 years ago

Oh wow, really? Is that:

NullDivision commented 8 years ago

Local system with istanbul installed in node modules. It's an existing project but only started to happen today after clearing npm-shrinkwrap.

Full command for npm run test:unit is:

istanbul cover
        --dir coverage/unit
        --report html
        --report lcov
        --report text-summary
        node_modules/mocha/bin/_mocha --
                --compilers js:babel-core/register
                --require test/unit/fixtures/globals.js
                --require test/jsdomSetup.js
                --require test/unit/fixtures/ignoreExtension.js
                --reporter mocha-jenkins-reporter
                --reporter-options junit_report_name=Tests,junit_report_path=./coverage/unit/report.xml,junit_report_stack=1
                --recursive \"test/unit/**/*.js\"

The command used to work fine up until recently with the exact same versions and command args.

mjbader commented 8 years ago

I can confirm that I am encountering the same issue. The specific option for me that is causing it is --reporter=lcov . If I do not generate an lcov report, I do not encounter this issue. Other reports I have tried work fine.

gadicc commented 8 years ago

New builds are working again for me. In light of all the info above (thanks, everyone!) I'm guessing it was an update in an deep dependency somewhere, which has since been fixed. Regrettably I didn't save the output of npm list or do a shrinkwrap when things weren't working (if anyone else can do this, might still be interesting to know what actually happened).

All, if you run:

$ rm -rf node_modules && npm i

do things start working again? (Assuming it's safe for you to do that; perhaps do an npm shrinkwrap first and then move npm-shrinkwrap.json outside of your project dir before npm i)

NullDivision commented 8 years ago

Worked for me as well. Issue seems to be resolved.