Skip to content

Commit 5a0ed0b

Browse files
cjihrigBridgeAR
authored andcommitted
test: cover stdout/stderr usage in triggerReport()
This commit adds coverage for the cases where process.report.filename is 'stdout' or 'stderr'. PR-URL: #26522 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent ac81fd2 commit 5a0ed0b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

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

+25
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
const common = require('../common');
66
common.skipIfReportDisabled();
77
const assert = require('assert');
8+
const { spawnSync } = require('child_process');
89
const fs = require('fs');
910
const path = require('path');
1011
const helper = require('../common/report');
@@ -81,3 +82,27 @@ function validate() {
8182
process.report.triggerReport('file', error);
8283
}, { code: 'ERR_INVALID_ARG_TYPE' });
8384
});
85+
86+
{
87+
// Test the special "stdout" filename.
88+
const args = ['--experimental-report', '-e',
89+
'process.report.triggerReport("stdout")'];
90+
const child = spawnSync(process.execPath, args, { cwd: tmpdir.path });
91+
assert.strictEqual(child.status, 0);
92+
assert.strictEqual(child.signal, null);
93+
assert.strictEqual(helper.findReports(child.pid, tmpdir.path).length, 0);
94+
helper.validateContent(child.stdout.toString());
95+
}
96+
97+
{
98+
// Test the special "stderr" filename.
99+
const args = ['--experimental-report', '-e',
100+
'process.report.triggerReport("stderr")'];
101+
const child = spawnSync(process.execPath, args, { cwd: tmpdir.path });
102+
assert.strictEqual(child.status, 0);
103+
assert.strictEqual(child.signal, null);
104+
assert.strictEqual(child.stdout.toString().trim(), '');
105+
assert.strictEqual(helper.findReports(child.pid, tmpdir.path).length, 0);
106+
const report = child.stderr.toString().split('Node.js report completed')[0];
107+
helper.validateContent(report);
108+
}

0 commit comments

Comments
 (0)