Skip to content
This repository was archived by the owner on Jun 18, 2021. It is now read-only.

Commit f170edf

Browse files
richardlaurnchamberlain
authored andcommitted
test: fix test-api-getreport.js
process.argv0 was added in Node.js v6.4.0 and doesn't exist in Node.js v4. PR-URL: #58 Reviewed-By: Richard Chamberlain <richard_chamberlain@uk.ibm.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent 76fa628 commit f170edf

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

test/test-api-getreport.js

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
'use strict';
22

3-
// Testcase for returning NodeReport as a string via API call
3+
// Testcase for returning report as a string via API call
44

5-
const common = require('./common.js');
6-
const tap = require('tap');
7-
const nodereport = require('../');
8-
var report_str = nodereport.getReport();
9-
common.validateContent(report_str, tap, {pid: process.pid,
10-
commandline: [process.argv0, 'test/test-api-getreport.js'].join(' ')
11-
});
5+
if (process.argv[2] === 'child') {
6+
const nodereport = require('../');
7+
console.log(nodereport.getReport());
8+
} else {
9+
const common = require('./common.js');
10+
const spawnSync = require('child_process').spawnSync;
11+
const tap = require('tap');
12+
13+
const args = [__filename, 'child'];
14+
const child = spawnSync(process.execPath, args);
15+
tap.plan(3);
16+
tap.strictSame(child.stderr.toString(), '',
17+
'Checking no messages on stderr');
18+
const reportFiles = common.findReports(child.pid);
19+
tap.same(reportFiles, [], 'Checking no report files were written');
20+
tap.test('Validating report content', (t) => {
21+
common.validateContent(child.stdout, t, { pid: child.pid,
22+
commandline: process.execPath + ' ' + args.join(' ')
23+
});
24+
});
25+
}

0 commit comments

Comments
 (0)