diff --git a/test/common/README.md b/test/common/README.md index 08687547825..c3f2c5f6b8a 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -219,11 +219,6 @@ Platform check for Windows. Platform check for Windows 32-bit on Windows 64-bit. -### leakedGlobals() -* return [<Array>] - -Indicates whether any globals are not on the `knownGlobals` list. - ### localhostIPv4 * [<string>] diff --git a/test/common/index.js b/test/common/index.js index 3741211bd3d..75fe2e1548e 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -726,7 +726,6 @@ module.exports = { isSunOS, isWindows, isWOW64, - leakedGlobals, localIPv6Hosts, mustCall, mustCallAsync, diff --git a/test/common/index.mjs b/test/common/index.mjs index e0842011c66..832f68a9ee0 100644 --- a/test/common/index.mjs +++ b/test/common/index.mjs @@ -25,7 +25,6 @@ const { ddCommand, platformTimeout, allowGlobals, - leakedGlobals, mustCall, mustCallAtLeast, mustCallAsync, @@ -75,7 +74,6 @@ export { ddCommand, platformTimeout, allowGlobals, - leakedGlobals, mustCall, mustCallAtLeast, mustCallAsync, diff --git a/test/fixtures/leakedGlobal.js b/test/fixtures/leakedGlobal.js new file mode 100644 index 00000000000..6f4b1b992e2 --- /dev/null +++ b/test/fixtures/leakedGlobal.js @@ -0,0 +1,5 @@ +'use strict'; + +require('../common'); + +global.gc = 42; // intentionally leak a global diff --git a/test/parallel/test-common.js b/test/parallel/test-common.js index eafe4dd830b..51e0302868c 100644 --- a/test/parallel/test-common.js +++ b/test/parallel/test-common.js @@ -27,10 +27,13 @@ const assert = require('assert'); const { execFile } = require('child_process'); // test for leaked global detection -global.gc = 42; // Not a valid global unless --expose_gc is set. -assert.deepStrictEqual(common.leakedGlobals(), ['gc']); -delete global.gc; - +{ + const p = fixtures.path('leakedGlobal.js'); + execFile(process.argv[0], [p], common.mustCall((ex, stdout, stderr) => { + assert.notStrictEqual(ex.code, 0); + assert.ok(/\bAssertionError\b.*\bUnexpected global\b.*\bgc\b/.test(stderr)); + })); +} // common.mustCall() tests assert.throws(function() {