test: simplify test-api-getreport.js

PR-URL: https://github.com/nodejs/node/pull/26169
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
cjihrig 2019-02-17 13:36:22 -05:00
parent 7b198935d6
commit 1aadfa8700
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5

View File

@ -1,25 +1,12 @@
// Flags: --experimental-report
'use strict'; 'use strict';
// Testcase for returning report as a string via API call
const common = require('../common'); const common = require('../common');
common.skipIfReportDisabled(); common.skipIfReportDisabled();
const assert = require('assert'); const assert = require('assert');
if (process.argv[2] === 'child') { const helper = require('../common/report');
console.log(process.report.getReport());
} else {
const helper = require('../common/report.js');
const spawnSync = require('child_process').spawnSync;
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const args = ['--experimental-report', __filename, 'child']; common.expectWarning('ExperimentalWarning',
const child = spawnSync(process.execPath, args, { cwd: tmpdir.path }); 'report is an experimental feature. This feature could ' +
const report_msg = 'Found report files'; 'change at any time');
const std_msg = 'Found messages on stderr'; helper.validateContent(process.report.getReport());
assert.ok(child.stderr.toString().includes( assert.deepStrictEqual(helper.findReports(process.pid, process.cwd()), []);
`(node:${child.pid}) ExperimentalWarning: report is an` +
' experimental feature. This feature could change at any time'), std_msg);
const reportFiles = helper.findReports(child.pid, tmpdir.path);
assert.deepStrictEqual(reportFiles, [], report_msg);
helper.validateContent(child.stdout);
}