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: set processinfo pid/ppid to actual numbers #1057

Merged
merged 1 commit into from
Apr 6, 2019
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
6 changes: 2 additions & 4 deletions bin/wrap.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
var sw = require('spawn-wrap')
var NYC = require('../index.js')

var parentPid = process.env.NYC_PARENT_PID || '0'
process.env.NYC_PARENT_PID = process.pid

var config = {}
if (process.env.NYC_CONFIG) config = JSON.parse(process.env.NYC_CONFIG)
config.isChildProcess = true

config._processInfo = {
ppid: parentPid,
pid: process.pid,
ppid: process.ppid,
root: process.env.NYC_ROOT_ID
}

Expand Down
8 changes: 7 additions & 1 deletion test/nyc-integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,13 @@ describe('the nyc cli', function () {
proc.on('close', function (code) {
code.should.equal(0)
stdout.should.not.match(new RegExp('└─'))
fs.statSync(path.resolve(fixturesCLI, '.nyc_output', 'processinfo'))
const dir = path.resolve(fixturesCLI, '.nyc_output', 'processinfo')
fs.statSync(dir)
// make sure that the processinfo file has a numeric pid and ppid
const files = fs.readdirSync(dir).filter(f => f !== 'index.json')
const data = JSON.parse(fs.readFileSync(dir + '/' + files[0], 'utf8'))
data.pid.should.be.a('number')
data.ppid.should.be.a('number')
done()
})
})
Expand Down