Skip to content
Permalink
Browse files

fix: Do not crash when nyc is run inside itself. (#1068)

Fixes #1067
  • Loading branch information...
coreyfarrell committed Apr 16, 2019
1 parent e21721a commit c4fcf5e3f5c8aa60c76790d691beb6cd88a48744
Showing with 37 additions and 1 deletion.
  1. +1 −1 index.js
  2. +5 −0 test/fixtures/recursive-run/package.json
  3. +31 −0 test/nyc-integration.js
@@ -437,7 +437,7 @@ NYC.prototype.writeProcessIndex = function () {
infos.forEach(info => {
if (info.parent) {
const parentInfo = infoByUid.get(info.parent)
if (parentInfo.children.indexOf(info.uuid) === -1) {
if (parentInfo && !parentInfo.children.includes(info.uuid)) {
parentInfo.children.push(info.uuid)
}
}
@@ -0,0 +1,5 @@
{
"nyc": {
"reporter": []
}
}
@@ -1839,6 +1839,37 @@ describe('the nyc cli', function () {
})
})
})

it('recursive run does not throw', done => {
const args = [
bin,
process.execPath,
bin,
process.execPath,
bin,
process.execPath,
bin,
'true'
]
const proc = spawn(process.execPath, args, {
cwd: path.resolve(__dirname, './fixtures/recursive-run')
})

let stdio = ''
proc.stderr.on('data', chunk => {
stdio += chunk
})

proc.stdout.on('data', chunk => {
stdio += chunk
})

proc.on('close', code => {
code.should.equal(0)
stdio.should.equal('')
done()
})
})
})

function stdoutShouldEqual (stdout, expected) {

0 comments on commit c4fcf5e

Please sign in to comment.
You can’t perform that action at this time.