Skip to content
This repository was archived by the owner on Dec 8, 2024. It is now read-only.

Merging reports fails if base report doesn't contain all files #207

Open
dmehra opened this issue May 25, 2014 · 4 comments
Open

Merging reports fails if base report doesn't contain all files #207

dmehra opened this issue May 25, 2014 · 4 comments

Comments

@dmehra
Copy link

dmehra commented May 25, 2014

I use istanbul on a node.js application where some services are started as subprocesses. To enable code coverage of those, I followed advice for issue #97.
So I start the subprocesses as "istanbul cover /index.js --dir -- " and code coverage goes into uniquely named subdirectories of ./coverage.

Then I run "istanbul report" to generate a merged coverage report. However, parsing fails if coverage on a subprocess exists for source file names which are not mentioned in the base report. This happens because my tests do not "require" js files used by subprocesses, and the base report has no coverage for those files (the filenames are not included at all), as described in issue #142.

I can work around the problem by creating a no-op test that explicitly does "require" on all the source files from my services (as advised by someone in #142), the filenames then show up in the base report with near-zero code coverage, and parsing at "istanbul report" step works fine, giving me a merged report that includes subprocess coverage. But without the "require" hack, I get this error (doesn't matter which report format is used):

$ istanbul report
Using reporter [lcov]

/usr/local/lib/node_modules/istanbul/lib/object-utils.js:58
var line = statementMap[st].start.line,
^
TypeError: Cannot read property 'start' of undefined
at /usr/local/lib/node_modules/istanbul/lib/object-utils.js:58:44
at Array.forEach (native)
at Object.addDerivedInfoForFile (/usr/local/lib/node_modules/istanbul/lib/object-utils.js:57:37)
at Object.Collector.fileCoverageFor (/usr/local/lib/node_modules/istanbul/lib/collector.js:93:15)
at /usr/local/lib/node_modules/istanbul/lib/report/html.js:517:90
at Array.forEach (native)
at HtmlReport.Report.mix.writeReport (/usr/local/lib/node_modules/istanbul/lib/report/html.js:516:27)
at LcovReport.Report.mix.writeReport (/usr/local/lib/node_modules/istanbul/lib/report/lcov.js:45:19)
at /usr/local/lib/node_modules/istanbul/lib/command/report.js:100:22
at /usr/local/lib/node_modules/istanbul/lib/util/file-matcher.js:35:9

@gotwarlost
Copy link
Owner

This doesn't seem right to me - at least the root cause is not what you think it is although it appears that way.

Is there a way you can provide a reproducible test case for this?

@dmehra
Copy link
Author

dmehra commented May 26, 2014

My setup is complex, doesn't lend itself easily to a test case. Would it help if I provided output from istanbul with --verbose? I could send that to you directly.

@gotwarlost
Copy link
Owner

Sure, I can take a look. It may not be enough though.

@BridgeAR
Copy link

I'm not certain if I ran into the same issue or if this is a issue with nyc but I just got this error:

Ping @bcoe I ran this command nyc ./node_modules/.bin/_mocha ./test/*.js ./test/commands/*.js ./test/parser/*.js --timeout=8000

/home/ruben/repos/node_redis/node_modules/nyc/node_modules/istanbul/lib/object-utils.js:59
                var line = statementMap[st].start.line,
                                           ^
TypeError: Cannot read property 'start' of undefined
    at /home/ruben/repos/node_redis/node_modules/nyc/node_modules/istanbul/lib/object-utils.js:59:44
    at Array.forEach (native)
    at Object.addDerivedInfoForFile (/home/ruben/repos/node_redis/node_modules/nyc/node_modules/istanbul/lib/object-utils.js:58:37)
    at Object.Collector.fileCoverageFor (/home/ruben/repos/node_redis/node_modules/nyc/node_modules/istanbul/lib/collector.js:94:15)
    at /home/ruben/repos/node_redis/node_modules/nyc/node_modules/istanbul/lib/report/text.js:210:27
    at Array.forEach (native)
    at TextReport.Report.mix.writeReport (/home/ruben/repos/node_redis/node_modules/nyc/node_modules/istanbul/lib/report/text.js:208:27)
    at /home/ruben/repos/node_redis/node_modules/nyc/node_modules/istanbul/lib/reporter.js:93:20
    at Array.forEach (native)
    at Object.Reporter.write (/home/ruben/repos/node_redis/node_modules/nyc/node_modules/istanbul/lib/reporter.js:87:30)

I can't reproduce it though.

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

No branches or pull requests

3 participants