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

fix: file URL to system path conversion #46

Merged
merged 2 commits into from
Dec 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions lib/report.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const Exclude = require('test-exclude')
const furi = require('furi')
const libCoverage = require('istanbul-lib-coverage')
const libReport = require('istanbul-lib-report')
const reports = require('istanbul-reports')
Expand Down Expand Up @@ -74,7 +75,7 @@ class Report {
_getMergedProcessCov () {
const v8ProcessCovs = []
for (const v8ProcessCov of this._loadReports()) {
v8ProcessCovs.push(this._filterProcessCov(v8ProcessCov))
v8ProcessCovs.push(this._normalizeProcessCov(v8ProcessCov))
}
return mergeProcessCovs(v8ProcessCovs)
}
Expand All @@ -101,21 +102,26 @@ class Report {
}

/**
* Returns a filtered process coverage.
* Normalizes a process coverage.
*
* This function replaces file URLs (`url` property) by their corresponding
* system-dependent path and applies the current inclusion rules to filter out
* the excluded script coverages.
*
* The result is a copy of the input, with script coverages filtered based
* on their `url` and the current inclusion rules.
* There is no deep cloning.
*
* @param v8ProcessCov V8 process coverage to filter.
* @return {v8ProcessCov} Filtered V8 process coverage.
* @param v8ProcessCov V8 process coverage to normalize.
* @return {v8ProcessCov} Normalized V8 process coverage.
* @private
*/
_filterProcessCov (v8ProcessCov) {
_normalizeProcessCov (v8ProcessCov) {
const result = []
for (const v8ScriptCov of v8ProcessCov.result) {
// TODO: implement real fix from https://github.com/nodejs/node/issues/23783
v8ScriptCov.url = v8ScriptCov.url.replace(/^file:\/\//, '')
if (/^file:\/\//.test(v8ScriptCov.url)) {
v8ScriptCov.url = furi.toSysPath(v8ScriptCov.url)
}
if (this.exclude.shouldInstrument(v8ScriptCov.url) &&
(!this.omitRelative || isAbsolute(v8ScriptCov.url))) {
result.push(v8ScriptCov)
Expand Down
19 changes: 19 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@c88/v8-coverage": "^0.1.0",
"find-up": "^3.0.0",
"foreground-child": "^1.5.6",
"furi": "^1.0.0",
"istanbul-lib-coverage": "^2.0.1",
"istanbul-lib-report": "^2.0.1",
"istanbul-reports": "^2.0.0",
Expand Down