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 Istanbul reporting #8

Merged
merged 6 commits into from
Dec 5, 2017
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
chore: dogfood
Benjamin Coe committed Dec 1, 2017
commit 601eec59157cd932cba9c6a0f5a44a8ef0d16fc7
2 changes: 1 addition & 1 deletion bin/c8.js
Original file line number Diff line number Diff line change
@@ -79,7 +79,7 @@ const exclude = Exclude({

async function collectV8Coverage (Profiler) {
let {result} = await Profiler.takePreciseCoverage()
result = result.filter({url} => {
result = result.filter(({url}) => {
return isAbsolute(url) && exclude.shouldInstrument(url)
})
return result
2 changes: 1 addition & 1 deletion lib/parse-args.js
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ function hideInstrumenteeArgs () {
if (!yargv._.length) return argv

// drop all the arguments after the bin being
// instrumented by nyc.
// instrumented by c8.
argv = argv.slice(0, argv.indexOf(yargv._[0]))
argv.push(yargv._[0])

2 changes: 2 additions & 0 deletions lib/spawn.js
Original file line number Diff line number Diff line change
@@ -27,6 +27,8 @@ module.exports = function (execPath, args = []) {
proc.on('close', (code) => {
if (info.port === -1) {
return reject(Error('could not connect to inspector'))
} else {
process.exitCode = code
}
})
})
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -5,13 +5,13 @@
"main": "index.js",
"bin": "./bin/c8.js",
"scripts": {
"test": "nyc mocha ./test/*.js",
"test": "./bin/c8.js node ./node_modules/.bin/_mocha ./test/*.js",
"posttest": "standard",
"release": "standard-version"
},
"c8": {
"exclude": [
"test/integration.js"
"test/*.js"
]
},
"standard": {
@@ -49,7 +49,6 @@
"devDependencies": {
"chai": "^4.1.2",
"mocha": "^4.0.1",
"nyc": "^11.3.0",
"standard": "^10.0.3",
"standard-version": "^4.2.0"
}
14 changes: 12 additions & 2 deletions test/integration.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
/* global describe, it */

describe('c8', () => {
it('is a program', () => {
const {spawnSync} = require('child_process')
const c8Path = require.resolve('../bin/c8')

describe('c8', () => {
it('reports coverage for script that exits normally', () => {
// won't work until we figure out the spawn-wrap flow.
spawnSync(c8Path, [
process.execPath,
require.resolve('./fixtures/a')
], {
env: process.env,
cwd: process.cwd()
})
})
})
9 changes: 9 additions & 0 deletions test/parse-args.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* global describe, it */

const parseArgs = require('../lib/parse-args')

describe('parse-args', () => {
it('outputs some coverage information', () => {
parseArgs.hideInstrumenteeArgs()
})
})