mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
One test per each API, so that additional tests in future are modular. test/common/report.js contain common functions that tests leverage. PR-URL: https://github.com/nodejs/node/pull/22712 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <Michael_Dawson@ca.ibm.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
30 lines
1.0 KiB
JavaScript
30 lines
1.0 KiB
JavaScript
'use strict';
|
|
|
|
// Testcase to produce report via API call
|
|
const common = require('../common');
|
|
common.skipIfReportDisabled();
|
|
if (process.argv[2] === 'child') {
|
|
process.report.triggerReport();
|
|
} else {
|
|
const helper = require('../common/report.js');
|
|
const spawn = require('child_process').spawn;
|
|
const assert = require('assert');
|
|
const tmpdir = require('../common/tmpdir');
|
|
tmpdir.refresh();
|
|
|
|
const child = spawn(process.execPath,
|
|
['--experimental-report', __filename, 'child'],
|
|
{ cwd: tmpdir.path });
|
|
child.on('exit', common.mustCall((code) => {
|
|
const report_msg = 'No reports found';
|
|
const process_msg = 'Process exited unexpectedly';
|
|
assert.strictEqual(code, 0, process_msg + ':' + code);
|
|
const reports = helper.findReports(child.pid, tmpdir.path);
|
|
assert.strictEqual(reports.length, 1, report_msg);
|
|
const report = reports[0];
|
|
helper.validate(report, { pid: child.pid,
|
|
commandline: child.spawnargs.join(' ')
|
|
});
|
|
}));
|
|
}
|