This repository has been archived by the owner on Jun 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix version reporting in NodeReport section
Report the versions of Node.js and its components based on the runtime and not compile time constants. Report NodeReport version and the version of Node.js it was built against. Extend the tests to validate the versions reported in the report. Fixes: #29 PR-URL: #30 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: George Adams <george.adams@uk.ibm.com>
- Loading branch information
1 parent
d988b6c
commit 368f253
Showing
13 changed files
with
269 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
// Testcase to check NodeReport succeeds if process.versions is damaged | ||
if (process.argv[2] === 'child') { | ||
// Tamper with the process object | ||
Object.defineProperty(process, 'versions', {get() { throw 'boom'; }}); | ||
const nodereport = require('../'); | ||
nodereport.triggerReport(); | ||
} else { | ||
const common = require('./common.js'); | ||
const spawn = require('child_process').spawn; | ||
const tap = require('tap'); | ||
|
||
const child = spawn(process.execPath, [__filename, 'child']); | ||
child.on('exit', (code) => { | ||
tap.plan(3); | ||
tap.equal(code, 0, 'Process exited cleanly'); | ||
const reports = common.findReports(child.pid); | ||
tap.equal(reports.length, 1, 'Found reports ' + reports); | ||
const report = reports[0]; | ||
const validateOpts = { pid: child.pid, expectedVersions: [] }; | ||
common.validate(tap, report, validateOpts); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
// Testcase to check NodeReport succeeds if process.version is damaged | ||
if (process.argv[2] === 'child') { | ||
// Tamper with the process object | ||
delete process['version']; | ||
const nodereport = require('../'); | ||
nodereport.triggerReport(); | ||
} else { | ||
const common = require('./common.js'); | ||
const spawn = require('child_process').spawn; | ||
const tap = require('tap'); | ||
|
||
const child = spawn(process.execPath, [__filename, 'child']); | ||
child.on('exit', (code) => { | ||
tap.plan(3); | ||
tap.equal(code, 0, 'Process exited cleanly'); | ||
const reports = common.findReports(child.pid); | ||
tap.equal(reports.length, 1, 'Found reports ' + reports); | ||
const report = reports[0]; | ||
const validateOpts = { pid: child.pid, expectNodeVersion: true }; | ||
common.validate(tap, report, validateOpts); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use strict'; | ||
|
||
// Testcase to check NodeReport succeeds if part of process.versions is damaged | ||
if (process.argv[2] === 'child') { | ||
// Tamper with the process object | ||
Object.defineProperty(process.versions, 'uv', {get() { throw 'boom'; }}); | ||
const nodereport = require('../'); | ||
nodereport.triggerReport(); | ||
} else { | ||
const common = require('./common.js'); | ||
const spawn = require('child_process').spawn; | ||
const tap = require('tap'); | ||
|
||
const child = spawn(process.execPath, [__filename, 'child']); | ||
child.on('exit', (code) => { | ||
tap.plan(3); | ||
tap.equal(code, 0, 'Process exited cleanly'); | ||
const reports = common.findReports(child.pid); | ||
tap.equal(reports.length, 1, 'Found reports ' + reports); | ||
const report = reports[0]; | ||
const validateOpts = { pid: child.pid, | ||
expectedVersions: Object.keys(process.versions).filter((c) => c !== 'uv') | ||
}; | ||
common.validate(tap, report, validateOpts); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
// Testcase to check NodeReport succeeds if both process.version and | ||
// process.versions are damaged | ||
if (process.argv[2] === 'child') { | ||
// Tamper with the process object | ||
delete process['version']; | ||
delete process['versions']; | ||
|
||
const nodereport = require('../'); | ||
nodereport.triggerReport(); | ||
} else { | ||
const common = require('./common.js'); | ||
const spawn = require('child_process').spawn; | ||
const tap = require('tap'); | ||
|
||
const child = spawn(process.execPath, [__filename, 'child']); | ||
child.on('exit', (code) => { | ||
tap.plan(3); | ||
tap.equal(code, 0, 'Process exited cleanly'); | ||
const reports = common.findReports(child.pid); | ||
tap.equal(reports.length, 1, 'Found reports ' + reports); | ||
const report = reports[0]; | ||
const validateOpts = { pid: child.pid, expectNodeVersion: false, | ||
expectedVersions: [] }; | ||
common.validate(tap, report, validateOpts); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.