From 0f8d8d6262341333ed2c61d760f3ebb8656006c9 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 8 Mar 2019 11:21:05 -0500 Subject: [PATCH] test: cover triggerReport() failure case PR-URL: https://github.com/nodejs/node/pull/26524 Reviewed-By: Richard Lau Reviewed-By: Ruben Bridgewater Reviewed-By: Daijiro Wachi Reviewed-By: James M Snell --- test/report/test-report-triggerreport.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/report/test-report-triggerreport.js b/test/report/test-report-triggerreport.js index 2ce0ea3b339c43..c89959ae8754f7 100644 --- a/test/report/test-report-triggerreport.js +++ b/test/report/test-report-triggerreport.js @@ -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:')); +}