Skip to content

Commit

Permalink
test: cover stdout/stderr usage in triggerReport()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
cjihrig authored and BridgeAR committed Mar 14, 2019
1 parent ac81fd2 commit 5a0ed0b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/report/test-report-triggerreport.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
const common = require('../common');
common.skipIfReportDisabled();
const assert = require('assert');
const { spawnSync } = require('child_process');
const fs = require('fs');
const path = require('path');
const helper = require('../common/report');
Expand Down Expand Up @@ -81,3 +82,27 @@ function validate() {
process.report.triggerReport('file', error);
}, { code: 'ERR_INVALID_ARG_TYPE' });
});

{
// Test the special "stdout" filename.
const args = ['--experimental-report', '-e',
'process.report.triggerReport("stdout")'];
const child = spawnSync(process.execPath, args, { cwd: tmpdir.path });
assert.strictEqual(child.status, 0);
assert.strictEqual(child.signal, null);
assert.strictEqual(helper.findReports(child.pid, tmpdir.path).length, 0);
helper.validateContent(child.stdout.toString());
}

{
// Test the special "stderr" filename.
const args = ['--experimental-report', '-e',
'process.report.triggerReport("stderr")'];
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(), '');
assert.strictEqual(helper.findReports(child.pid, tmpdir.path).length, 0);
const report = child.stderr.toString().split('Node.js report completed')[0];
helper.validateContent(report);
}

0 comments on commit 5a0ed0b

Please sign in to comment.