2020-03-13 17:45:39 +01:00
|
|
|
// Flags: --report-on-fatalerror --report-on-signal --report-uncaught-exception --report-compact
|
2019-03-03 18:05:38 +01:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
// Verify that process.report.directory behaves properly.
|
|
|
|
assert.strictEqual(process.report.directory, '');
|
|
|
|
process.report.directory = __dirname;
|
|
|
|
assert.strictEqual(process.report.directory, __dirname);
|
2019-12-25 18:02:16 +01:00
|
|
|
assert.throws(() => {
|
2019-03-03 18:05:38 +01:00
|
|
|
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');
|
2019-12-25 18:02:16 +01:00
|
|
|
assert.throws(() => {
|
2019-03-03 18:05:38 +01:00
|
|
|
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);
|
2019-12-25 18:02:16 +01:00
|
|
|
assert.throws(() => {
|
2019-03-03 18:05:38 +01:00
|
|
|
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);
|
2019-12-25 18:02:16 +01:00
|
|
|
assert.throws(() => {
|
2019-03-03 18:05:38 +01:00
|
|
|
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);
|
2019-12-25 18:02:16 +01:00
|
|
|
assert.throws(() => {
|
2019-03-03 18:05:38 +01:00
|
|
|
process.report.reportOnSignal = {};
|
|
|
|
}, { code: 'ERR_INVALID_ARG_TYPE' });
|
|
|
|
assert.strictEqual(process.report.reportOnSignal, true);
|
|
|
|
|
2020-03-13 17:45:39 +01:00
|
|
|
// Verify that process.report.reportCompact behaves properly.
|
|
|
|
assert.strictEqual(process.report.compact, true);
|
|
|
|
process.report.compact = false;
|
|
|
|
assert.strictEqual(process.report.compact, false);
|
|
|
|
process.report.compact = true;
|
|
|
|
assert.strictEqual(process.report.compact, true);
|
|
|
|
assert.throws(() => {
|
|
|
|
process.report.compact = {};
|
|
|
|
}, { code: 'ERR_INVALID_ARG_TYPE' });
|
|
|
|
assert.strictEqual(process.report.compact, true);
|
|
|
|
|
2019-03-03 18:05:38 +01:00
|
|
|
if (!common.isWindows) {
|
|
|
|
// Verify that process.report.signal behaves properly.
|
|
|
|
assert.strictEqual(process.report.signal, 'SIGUSR2');
|
2019-12-25 18:02:16 +01:00
|
|
|
assert.throws(() => {
|
2019-03-03 18:05:38 +01:00
|
|
|
process.report.signal = {};
|
|
|
|
}, { code: 'ERR_INVALID_ARG_TYPE' });
|
2019-12-25 18:02:16 +01:00
|
|
|
assert.throws(() => {
|
2019-03-03 18:05:38 +01:00
|
|
|
process.report.signal = 'foo';
|
2019-04-08 19:23:36 +02:00
|
|
|
}, {
|
|
|
|
code: 'ERR_UNKNOWN_SIGNAL',
|
2022-11-17 14:02:11 +01:00
|
|
|
message: 'Unknown signal: foo',
|
2019-04-08 19:23:36 +02:00
|
|
|
});
|
2019-12-25 18:02:16 +01:00
|
|
|
assert.throws(() => {
|
2019-04-08 19:23:36 +02:00
|
|
|
process.report.signal = 'sigusr1';
|
|
|
|
}, {
|
|
|
|
code: 'ERR_UNKNOWN_SIGNAL',
|
2022-11-17 14:02:11 +01:00
|
|
|
message: 'Unknown signal: sigusr1 (signals must use all capital letters)',
|
2019-04-08 19:23:36 +02:00
|
|
|
});
|
2019-03-03 18:05:38 +01:00
|
|
|
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);
|
|
|
|
}
|