Skip to content

Commit

Permalink
test: simplify test-api-getreport.js
Browse files Browse the repository at this point in the history
PR-URL: #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>
  • Loading branch information
cjihrig authored and rvagg committed Feb 28, 2019
1 parent bd40a12 commit a1fcde0
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions test/node-report/test-api-getreport.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
// Flags: --experimental-report
'use strict';

// Testcase for returning report as a string via API call
const common = require('../common');
common.skipIfReportDisabled();
const assert = require('assert');
if (process.argv[2] === 'child') {
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 helper = require('../common/report');

const args = ['--experimental-report', __filename, 'child'];
const child = spawnSync(process.execPath, args, { cwd: tmpdir.path });
const report_msg = 'Found report files';
const std_msg = 'Found messages on stderr';
assert.ok(child.stderr.toString().includes(
`(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);
}
common.expectWarning('ExperimentalWarning',
'report is an experimental feature. This feature could ' +
'change at any time');
helper.validateContent(process.report.getReport());
assert.deepStrictEqual(helper.findReports(process.pid, process.cwd()), []);

0 comments on commit a1fcde0

Please sign in to comment.