|
5 | 5 | const common = require('../common');
|
6 | 6 | common.skipIfReportDisabled();
|
7 | 7 | const assert = require('assert');
|
| 8 | +const { spawnSync } = require('child_process'); |
8 | 9 | const fs = require('fs');
|
9 | 10 | const path = require('path');
|
10 | 11 | const helper = require('../common/report');
|
@@ -81,3 +82,27 @@ function validate() {
|
81 | 82 | process.report.triggerReport('file', error);
|
82 | 83 | }, { code: 'ERR_INVALID_ARG_TYPE' });
|
83 | 84 | });
|
| 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