Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: remove common.leakedGlobals() #22965

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions test/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,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>]

Expand Down
1 change: 0 additions & 1 deletion test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,6 @@ module.exports = {
isSunOS,
isWindows,
isWOW64,
leakedGlobals,
localIPv6Hosts,
mustCall,
mustCallAsync,
Expand Down
2 changes: 0 additions & 2 deletions test/common/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const {
ddCommand,
platformTimeout,
allowGlobals,
leakedGlobals,
mustCall,
mustCallAtLeast,
mustCallAsync,
Expand Down Expand Up @@ -75,7 +74,6 @@ export {
ddCommand,
platformTimeout,
allowGlobals,
leakedGlobals,
mustCall,
mustCallAtLeast,
mustCallAsync,
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/leakedGlobal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

require('../common');

global.gc = 42; // intentionally leak a global
11 changes: 7 additions & 4 deletions test/parallel/test-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down