Skip to content

Commit c213469

Browse files
isaacscoreyfarrell
authored andcommitted
feat: always build the processinfo temp dir (#1061)
Always build the processinfo data directory (with index) in ${tmpdir}/processinfo. This more easily supports cases where the processinfo index may be useful for later analysis, or generating the process tree post hoc.
1 parent e597c46 commit c213469

File tree

5 files changed

+6
-85
lines changed

5 files changed

+6
-85
lines changed

bin/nyc.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ if ([
6565
), function (done) {
6666
var mainChildExitCode = process.exitCode
6767

68-
if (argv.showProcessTree || argv.buildProcessTree) {
69-
nyc.writeProcessIndex()
70-
}
68+
nyc.writeProcessIndex()
7169

7270
if (argv.checkCoverage) {
7371
nyc.checkCoverage({

index.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ function NYC (config) {
4040
this._reportDir = config.reportDir || 'coverage'
4141
this._sourceMap = typeof config.sourceMap === 'boolean' ? config.sourceMap : true
4242
this._showProcessTree = config.showProcessTree || false
43-
this._buildProcessTree = this._showProcessTree || config.buildProcessTree
4443
this._eagerInstantiation = config.eager || false
4544
this.cwd = config.cwd || process.cwd()
4645
this.reporter = [].concat(config.reporter || 'text')
@@ -293,9 +292,7 @@ NYC.prototype.createTempDirectory = function () {
293292
mkdirp.sync(this.tempDirectory())
294293
if (this.cache) mkdirp.sync(this.cacheDirectory)
295294

296-
if (this._buildProcessTree) {
297-
mkdirp.sync(this.processInfoDirectory())
298-
}
295+
mkdirp.sync(this.processInfoDirectory())
299296
}
300297

301298
NYC.prototype.reset = function () {
@@ -351,10 +348,6 @@ NYC.prototype.writeCoverageFile = function () {
351348
'utf-8'
352349
)
353350

354-
if (!this._buildProcessTree) {
355-
return
356-
}
357-
358351
this.processInfo.coverageFilename = coverageFilename
359352
this.processInfo.files = Object.keys(coverage)
360353

lib/config-util.js

-6
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,6 @@ Config.buildYargs = function (cwd) {
229229
type: 'boolean',
230230
global: false
231231
})
232-
.option('build-process-tree', {
233-
describe: 'create files for the tree of spawned processes',
234-
default: false,
235-
type: 'boolean',
236-
global: false
237-
})
238232
.option('clean', {
239233
describe: 'should the .nyc_output folder be cleaned before executing tests',
240234
default: true,

test/nyc-integration.js

+3-67
Original file line numberDiff line numberDiff line change
@@ -1090,70 +1090,6 @@ describe('the nyc cli', function () {
10901090
done()
10911091
})
10921092
})
1093-
1094-
it('doesn’t create the temp directory for process info files when not present', function (done) {
1095-
var args = [bin, process.execPath, 'selfspawn-fibonacci.js', '5']
1096-
1097-
var proc = spawn(process.execPath, args, {
1098-
cwd: fixturesCLI,
1099-
env: env
1100-
})
1101-
1102-
proc.on('exit', function (code) {
1103-
code.should.equal(0)
1104-
fs.stat(path.resolve(fixturesCLI, '.nyc_output', 'processinfo'), function (err, stat) {
1105-
err.code.should.equal('ENOENT')
1106-
done()
1107-
})
1108-
})
1109-
})
1110-
})
1111-
1112-
describe('--build-process-tree', function () {
1113-
it('builds, but does not display, a tree of spawned processes', function (done) {
1114-
var args = [bin, '--build-process-tree', process.execPath, 'selfspawn-fibonacci.js', '5']
1115-
1116-
var proc = spawn(process.execPath, args, {
1117-
cwd: fixturesCLI,
1118-
env: env
1119-
})
1120-
1121-
var stdout = ''
1122-
proc.stdout.setEncoding('utf8')
1123-
proc.stdout.on('data', function (chunk) {
1124-
stdout += chunk
1125-
})
1126-
1127-
proc.on('close', function (code) {
1128-
code.should.equal(0)
1129-
stdout.should.not.match(new RegExp('└─'))
1130-
const dir = path.resolve(fixturesCLI, '.nyc_output', 'processinfo')
1131-
fs.statSync(dir)
1132-
// make sure that the processinfo file has a numeric pid and ppid
1133-
const files = fs.readdirSync(dir).filter(f => f !== 'index.json')
1134-
const data = JSON.parse(fs.readFileSync(dir + '/' + files[0], 'utf8'))
1135-
data.pid.should.be.a('number')
1136-
data.ppid.should.be.a('number')
1137-
done()
1138-
})
1139-
})
1140-
1141-
it('doesn’t create the temp directory for process info files when not present', function (done) {
1142-
var args = [bin, process.execPath, 'selfspawn-fibonacci.js', '5']
1143-
1144-
var proc = spawn(process.execPath, args, {
1145-
cwd: fixturesCLI,
1146-
env: env
1147-
})
1148-
1149-
proc.on('exit', function (code) {
1150-
code.should.equal(0)
1151-
fs.stat(path.resolve(fixturesCLI, '.nyc_output', 'processinfo'), function (err, stat) {
1152-
err.code.should.equal('ENOENT')
1153-
done()
1154-
})
1155-
})
1156-
})
11571093
})
11581094

11591095
describe('--temp-dir', function () {
@@ -1174,7 +1110,7 @@ describe('the nyc cli', function () {
11741110
proc.on('close', function (code) {
11751111
code.should.equal(0)
11761112
var tempFiles = fs.readdirSync(path.resolve(fixturesCLI, '.nyc_output'))
1177-
tempFiles.length.should.equal(1)
1113+
tempFiles.length.should.equal(2) // the coverage file, and processinfo
11781114
var cliFiles = fs.readdirSync(path.resolve(fixturesCLI))
11791115
cliFiles.should.include('.nyc_output')
11801116
cliFiles.should.not.include('.temp_dir')
@@ -1194,7 +1130,7 @@ describe('the nyc cli', function () {
11941130
proc.on('exit', function (code) {
11951131
code.should.equal(0)
11961132
var tempFiles = fs.readdirSync(path.resolve(fixturesCLI, '.temp_directory'))
1197-
tempFiles.length.should.equal(1)
1133+
tempFiles.length.should.equal(2)
11981134
var cliFiles = fs.readdirSync(path.resolve(fixturesCLI))
11991135
cliFiles.should.not.include('.nyc_output')
12001136
cliFiles.should.not.include('.temp_dir')
@@ -1214,7 +1150,7 @@ describe('the nyc cli', function () {
12141150
proc.on('exit', function (code) {
12151151
code.should.equal(0)
12161152
var tempFiles = fs.readdirSync(path.resolve(fixturesCLI, '.temp_dir'))
1217-
tempFiles.length.should.equal(1)
1153+
tempFiles.length.should.equal(2)
12181154
var cliFiles = fs.readdirSync(path.resolve(fixturesCLI))
12191155
cliFiles.should.not.include('.nyc_output')
12201156
cliFiles.should.include('.temp_dir')

test/processinfo.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ t.teardown(() => rimraf.sync(resolve(fixturesCLI, tmp)))
1414

1515
t.test('build some processinfo', t => {
1616
var args = [
17-
bin, '-t', tmp, '--build-process-tree',
17+
bin, '-t', tmp,
1818
node, 'selfspawn-fibonacci.js', '5'
1919
]
2020
var proc = spawn(process.execPath, args, {

0 commit comments

Comments
 (0)