-
Notifications
You must be signed in to change notification settings - Fork 91
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
chore: add support for subprocess spawning #11
Conversation
I'm not sure what the specific timing is in your case. As long as block coverage is enabled prior to a function being parsed, we can provide block-granularity data. This could also be due to things like lazy parsing of non top-level functions. Awesome that it works here :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about the late review. I seem to have forgotten about this 😐 Nonetheless, I’ve attached two comments.
try { | ||
// bootstrap the inspector before kicking | ||
// off the user's code. | ||
inspector.open(0, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn’t necessary. The in-process Inspector implementation works without launching the WebSocket server, which is what inspector.open
does.
return isAbsolute(url) && | ||
exclude.shouldInstrument(url) && | ||
url !== __filename | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This filtering mechanism generally doesn’t work very well for Windows, but I don’t really have any easy way to fix that. I’ve been wanting to publish a module that does this conversion the same way Node.js core does it, and I’ll report back when I do.
using the spawn-wrap library, this pull request adds support for tracking coverage in applications that spawn subprocesses (this is important in unit testing since many test frameworks immediately spawn a subprocess for executing tests).
I was shocked when I pulled this feature together by the fact that everything just worked
This raises a couple mysteries:
Mystery 1
I'm able to output coverage information in the
process.on('exit')
handler:I was pleasantly surprised to find out that I'm able to call
Profiler.takePreciseCoverage
from within an exit handler; this is a bit shocking to me because you're generally not able to perform async operations within this context (was a workaround for this introduced, in relation to the inspector?).Mystery 2
block-level test coverage seems to be working on the canary build of Node.js:
☝️ I'm ecstatic that this is working; but shouldn't it not be working since I'm not spawning with
--inspect-brk
? I was under the impression once the Node process starts we're not able to enable block level coverage.@hashseed, @TimothyGu @schuay @eugeneo, perhaps you can provide some insight into these mysteries?
If things are working as expected, it would seem that we're at the point where we can use v8's built-in test coverage in Node.js pretty effectively 🎉