-
Notifications
You must be signed in to change notification settings - Fork 94
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
shebang screws up line count in coverage #24
Comments
@bcoe - a little more description on this one, how to reproduce this? |
Tested using Ubuntu 18.04.1 (with UserLAnd on an Android 6.0.1 device) both with and without a shebang in each of two scripts -- a minimal single-file script and a real project (only 110 lines, but still) being run using it's test script. With a shebang
Without a shebang 100% coverage in both the test script and real project. |
@l3laze @profnandaa here's an example of code that triggers the problem: #!/usr/bin/env node
'use strict'
const foreground = require('foreground-child')
const mkdirp = require('mkdirp')
const report = require('../lib/report')
const rimraf = require('rimraf')
const {
hideInstrumenteeArgs,
hideInstrumenterArgs,
yargs
} = require('../lib/parse-args') I'm pretty sure we pretty much just need to modify this line here to take into account the shebang when source is loaded; so a regex to detect the shebang, followed by modifying the starting point of where we start collecting coverage in the file. |
@bcoe - will definitely dig in this weekend and get back, thanks for the pointer 👍 |
I don't understand much of this, especially the module.wrapper part above, but this hack (in script.js) is working using your test script above and my real project + test script.
It would be a good idea to check for a proper shebang though, as this will of course just accept any line with Edit: forgot to mention where the hack of a kludge was. |
That was truly a hack. It's adding +1 to the line count and ruining [at least] the function counter. Spent some time trying to fix it last night, but will have another go again from a fresh copy today. This would probably be much easier with PC :-? Edit: Wasted another two days now and with zero progress over multiple attempts from fresh copies I'm ready for a break. Going to work on something of my own instead, but will try again at some point if it's not fixed by then. My black box approach is definitely not working though -- will need to find docs for the v8 coverage output and I think how to access it from script.js to be able to figure this out, if that even helps at all. Another edit: Just reread the article linked from Reddit and realized the coverage is literally sitting right there..lol. Sorry, I've been pretty sick lately and am still recovering; will give this another shot ASAP and try not to cover it in my germs. Final edit (9/30/2018): Something deeper down has now completely broken coverage for scripts with a shebang, and so everything I learned up until now about the issue has become effectively useless. Lol. IDK for sure as I'm clearly no expert, but it seems like mixing and matching parts from Istanbul/NYC with c8 and trying to maintain compatibility with each is breaking both projects. |
Seems to be fixed in istanbuljs/v8-to-istanbul#15. |
No description provided.
The text was updated successfully, but these errors were encountered: