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 <anna@addaleax.net> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent ac81fd2 commit 5a0ed0b

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

‎test/report/test-report-triggerreport.js‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
constcommon=require('../common');
66
common.skipIfReportDisabled();
77
constassert=require('assert');
8+
const{ spawnSync }=require('child_process');
89
constfs=require('fs');
910
constpath=require('path');
1011
consthelper=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+
constargs=['--experimental-report','-e',
89+
'process.report.triggerReport("stdout")'];
90+
constchild=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+
constargs=['--experimental-report','-e',
100+
'process.report.triggerReport("stderr")'];
101+
constchild=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+
constreport=child.stderr.toString().split('Node.js report completed')[0];
107+
helper.validateContent(report);
108+
}

0 commit comments

Comments
 (0)