Skip to content

Commit 0f8d8d6

Browse files
cjihrigBridgeAR
authored andcommitted
test: cover triggerReport() failure case
PR-URL: #26524 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Daijiro Wachi <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 5a0ed0b commit 0f8d8d6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Diff for: test/report/test-report-triggerreport.js

+16
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,19 @@ function validate() {
106106
const report = child.stderr.toString().split('Node.js report completed')[0];
107107
helper.validateContent(report);
108108
}
109+
110+
{
111+
// Test the case where the report file cannot be opened.
112+
const reportDir = path.join(tmpdir.path, 'does', 'not', 'exist');
113+
const args = ['--experimental-report',
114+
`--diagnostic-report-directory=${reportDir}`,
115+
'-e',
116+
'process.report.triggerReport()'];
117+
const child = spawnSync(process.execPath, args, { cwd: tmpdir.path });
118+
119+
assert.strictEqual(child.status, 0);
120+
assert.strictEqual(child.signal, null);
121+
assert.strictEqual(child.stdout.toString().trim(), '');
122+
const stderr = child.stderr.toString();
123+
assert(stderr.includes('Failed to open Node.js report file:'));
124+
}

0 commit comments

Comments
 (0)