Skip to content
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

feat: implement coverage details for process tree #416

Merged
merged 2 commits into from
Oct 30, 2016

Conversation

addaleax
Copy link
Member

@addaleax addaleax commented Oct 8, 2016

Show line coverage for each subtree of the tree of spawned processes.

This is just a start, but while I definitely wanted to begin working in that direction as planned, I’m not too certain about how this is best implemented when it comes to visual display… In theory, a full per-file coverage table could be shown for each subtree, but that seems like overkill, so I’ve just implemented something small. Also, maybe printing this extra information should be optional/configurable, too?

What do you think?

Show line coverage for each subtree of the tree of spawned processes.
@coveralls
Copy link

coveralls commented Oct 8, 2016

Coverage Status

Changes Unknown when pulling ce440a9 on addaleax:process-tree-per-subtree-coverage into * on istanbuljs:master*.

Copy link
Member

@bcoe bcoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome @addaleax.

I think that starting with just the overall coverage per branch is sufficient; it's nice to know how much coverage your seeing in your integration vs. true unit-tests, as an example.

I don't think we need an extra configuration option for this; seems like a lovely thing to always have enabled as soon as you start printing the process tree.

@@ -460,7 +460,24 @@ NYC.prototype.checkCoverage = function (thresholds) {
}

NYC.prototype._loadProcessInfoTree = function () {
return ProcessInfo.buildProcessTree(this._loadProcessInfos())
var _this = this
var processTree = ProcessInfo.buildProcessTree(this._loadProcessInfos())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be tempted to encapsulate this logic inside process.js; and all that index.js would need to do would be:

console.log(processInfo.render()).

processTree.getCoverageMap(function (filenames, maps) {
var map = libCoverage.createCoverageMap({})

_this._loadReports(filenames).forEach(function (report) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can rename _loadReports to loadReports, and process.js can call this method on index.js.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bcoe I just updated this PR which what I think you had in mind – maybe you meant something totally different, this feels a bit icky now (as in, this doesn’t seem quite right from a separation of concerns pov?).

@@ -57,6 +63,20 @@ ProcessInfo.buildProcessTree = function (infos) {
return treeRoot
}

ProcessInfo.prototype.getCoverageMap = function (merger) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cool! it works because we already output the coverage for each subprocess to a separate file named after the pid?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep – the coverage filename is included in the file containing the process info. I thought about magically inferring the filename from the PID, but I wanted to keep the flexibility – mostly because I’ve been hearing Bad Things™ about assuming uniqueness of PIDs on Windows. 😄

@coveralls
Copy link

coveralls commented Oct 18, 2016

Coverage Status

Changes Unknown when pulling 6a3b4b9 on addaleax:process-tree-per-subtree-coverage into * on istanbuljs:master*.

@bcoe
Copy link
Member

bcoe commented Oct 29, 2016

@addaleax love this refactor 👍

@bcoe bcoe merged commit 92dedda into istanbuljs:master Oct 30, 2016
@bcoe
Copy link
Member

bcoe commented Oct 30, 2016

@addaleax give this a spin when you have a sec:

npm cache clear; npm i nyc@next

8.4.0 is a pretty big change to how the underlying instrumentation works, so I would appreciate extra eyes.

@addaleax addaleax deleted the process-tree-per-subtree-coverage branch October 30, 2016 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants