0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00
nodejs/test/report/test-report-signal.js
Joyee Cheung 94adfe9831
lib: replace --diagnostic-report-* with --report-*
In the code base the word `report` is almost only used to refer to
the diagnostic report when it's a noun, and it's programmable
interface `process.report()` it not prefixed, so `report` should be
unambiguous enough to use without `diagnostic`.

PR-URL: https://github.com/nodejs/node/pull/27312
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-04-22 19:09:52 +08:00

37 lines
1.2 KiB
JavaScript

// Flags: --experimental-report --report-on-signal
'use strict';
// Test producing a report via signal.
const common = require('../common');
common.skipIfReportDisabled();
if (common.isWindows)
return common.skip('Unsupported on Windows.');
if (!common.isMainThread)
common.skip('Signal reporting is only supported in the main thread');
const assert = require('assert');
const helper = require('../common/report');
const tmpdir = require('../common/tmpdir');
common.expectWarning('ExperimentalWarning',
'report is an experimental feature. This feature could ' +
'change at any time');
tmpdir.refresh();
process.report.directory = tmpdir.path;
assert.strictEqual(process.listenerCount('SIGUSR2'), 1);
process.kill(process.pid, 'SIGUSR2');
// Asynchronously wait for the report. In development, a single setImmediate()
// appears to be enough. Use an async loop to be a bit more robust in case
// platform or machine differences throw off the timing.
(function validate() {
const reports = helper.findReports(process.pid, tmpdir.path);
if (reports.length === 0)
return setImmediate(validate);
assert.strictEqual(reports.length, 1);
helper.validate(reports[0]);
})();