node/test/report/test-report-config.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

97 lines
3.9 KiB
JavaScript

// Flags: --experimental-report --report-on-fatalerror --report-on-signal --report-uncaught-exception
'use strict';
const common = require('../common');
common.skipIfReportDisabled();
const assert = require('assert');
common.expectWarning('ExperimentalWarning',
'report is an experimental feature. This feature could ' +
'change at any time');
// Verify that process.report.directory behaves properly.
assert.strictEqual(process.report.directory, '');
process.report.directory = __dirname;
assert.strictEqual(process.report.directory, __dirname);
common.expectsError(() => {
process.report.directory = {};
}, { code: 'ERR_INVALID_ARG_TYPE' });
assert.strictEqual(process.report.directory, __dirname);
// Verify that process.report.filename behaves properly.
assert.strictEqual(process.report.filename, '');
process.report.filename = 'test-report.json';
assert.strictEqual(process.report.filename, 'test-report.json');
common.expectsError(() => {
process.report.filename = {};
}, { code: 'ERR_INVALID_ARG_TYPE' });
assert.strictEqual(process.report.filename, 'test-report.json');
// Verify that process.report.reportOnFatalError behaves properly.
assert.strictEqual(process.report.reportOnFatalError, true);
process.report.reportOnFatalError = false;
assert.strictEqual(process.report.reportOnFatalError, false);
process.report.reportOnFatalError = true;
assert.strictEqual(process.report.reportOnFatalError, true);
common.expectsError(() => {
process.report.reportOnFatalError = {};
}, { code: 'ERR_INVALID_ARG_TYPE' });
assert.strictEqual(process.report.reportOnFatalError, true);
// Verify that process.report.reportOnUncaughtException behaves properly.
assert.strictEqual(process.report.reportOnUncaughtException, true);
process.report.reportOnUncaughtException = false;
assert.strictEqual(process.report.reportOnUncaughtException, false);
process.report.reportOnUncaughtException = true;
assert.strictEqual(process.report.reportOnUncaughtException, true);
common.expectsError(() => {
process.report.reportOnUncaughtException = {};
}, { code: 'ERR_INVALID_ARG_TYPE' });
assert.strictEqual(process.report.reportOnUncaughtException, true);
// Verify that process.report.reportOnSignal behaves properly.
assert.strictEqual(process.report.reportOnSignal, true);
process.report.reportOnSignal = false;
assert.strictEqual(process.report.reportOnSignal, false);
process.report.reportOnSignal = true;
assert.strictEqual(process.report.reportOnSignal, true);
common.expectsError(() => {
process.report.reportOnSignal = {};
}, { code: 'ERR_INVALID_ARG_TYPE' });
assert.strictEqual(process.report.reportOnSignal, true);
if (!common.isWindows) {
// Verify that process.report.signal behaves properly.
assert.strictEqual(process.report.signal, 'SIGUSR2');
common.expectsError(() => {
process.report.signal = {};
}, { code: 'ERR_INVALID_ARG_TYPE' });
common.expectsError(() => {
process.report.signal = 'foo';
}, {
code: 'ERR_UNKNOWN_SIGNAL',
message: 'Unknown signal: foo'
});
common.expectsError(() => {
process.report.signal = 'sigusr1';
}, {
code: 'ERR_UNKNOWN_SIGNAL',
message: 'Unknown signal: sigusr1 (signals must use all capital letters)'
});
assert.strictEqual(process.report.signal, 'SIGUSR2');
process.report.signal = 'SIGUSR1';
assert.strictEqual(process.report.signal, 'SIGUSR1');
// Verify that the interaction between reportOnSignal and signal is correct.
process.report.signal = 'SIGUSR2';
process.report.reportOnSignal = false;
assert.strictEqual(process.listenerCount('SIGUSR2'), 0);
process.report.reportOnSignal = true;
assert.strictEqual(process.listenerCount('SIGUSR2'), 1);
process.report.signal = 'SIGUSR1';
assert.strictEqual(process.listenerCount('SIGUSR2'), 0);
assert.strictEqual(process.listenerCount('SIGUSR1'), 1);
process.report.reportOnSignal = false;
assert.strictEqual(process.listenerCount('SIGUSR1'), 0);
}