test: cover triggerReport() failure case

PR-URL: https://github.com/nodejs/node/pull/26524
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
cjihrig
2019-03-08 11:21:05 -05:00
parent 86aed6d332
commit d73d861665

View File

@@ -106,3 +106,19 @@ function validate() {
const report = child.stderr.toString().split('Node.js report completed')[0];
helper.validateContent(report);
}
{
// Test the case where the report file cannot be opened.
const reportDir = path.join(tmpdir.path, 'does', 'not', 'exist');
const args = ['--experimental-report',
`--diagnostic-report-directory=${reportDir}`,
'-e',
'process.report.triggerReport()'];
const child = spawnSync(process.execPath, args, { cwd: tmpdir.path });
assert.strictEqual(child.status, 0);
assert.strictEqual(child.signal, null);
assert.strictEqual(child.stdout.toString().trim(), '');
const stderr = child.stderr.toString();
assert(stderr.includes('Failed to open Node.js report file:'));
}