0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00
nodejs/test/report/test-report-fatal-error.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

39 lines
1.1 KiB
JavaScript

'use strict';
const common = require('../common');
common.skipIfReportDisabled();
const assert = require('assert');
// Testcase to produce report on fatal error (javascript heap OOM)
if (process.argv[2] === 'child') {
const list = [];
while (true) {
const record = new MyRecord();
list.push(record);
}
function MyRecord() {
this.name = 'foo';
this.id = 128;
this.account = 98454324;
}
} else {
const helper = require('../common/report.js');
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const spawn = require('child_process').spawn;
const args = ['--experimental-report',
'--report-on-fatalerror',
'--max-old-space-size=20',
__filename,
'child'];
const child = spawn(process.execPath, args, { cwd: tmpdir.path });
child.on('exit', common.mustCall((code) => {
assert.notStrictEqual(code, 0, 'Process exited unexpectedly');
const reports = helper.findReports(child.pid, tmpdir.path);
assert.strictEqual(reports.length, 1);
const report = reports[0];
helper.validate(report);
}));
}