Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 22f46e7

Browse filesBrowse files
BridgeARMylesBorins
authored andcommitted
test: remove common.globalCheck
This flag is partially used in tests where it was not necessary and it is always possible to replace this flag with `common.allowGlobals`. This makes sure all globals are truly tested for. PR-URL: #20717 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent ada41b0 commit 22f46e7
Copy full SHA for 22f46e7
Expand file treeCollapse file tree

17 files changed

+33
-44
lines changed
Open diff view settings
Collapse file

‎test/common/README.md‎

Copy file name to clipboardExpand all lines: test/common/README.md
-5Lines changed: 0 additions & 5 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,6 @@ Attempts to get a valid TTY file descriptor. Returns `-1` if it fails.
150150

151151
The TTY file descriptor is assumed to be capable of being writable.
152152

153-
### globalCheck
154-
* [&lt;boolean>]
155-
156-
Set to `false` if the test should not check for global leaks.
157-
158153
### hasCrypto
159154
* [&lt;boolean>]
160155

Collapse file

‎test/common/index.js‎

Copy file name to clipboardExpand all lines: test/common/index.js
-6Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,21 +366,15 @@ function leakedGlobals() {
366366
}
367367
exports.leakedGlobals = leakedGlobals;
368368

369-
// Turn this off if the test should not check for global leaks.
370-
exports.globalCheck = true;
371-
372369
process.on('exit', function() {
373-
if (!exports.globalCheck) return;
374370
const leaked = leakedGlobals();
375371
if (leaked.length > 0) {
376372
assert.fail(`Unexpected global(s) found: ${leaked.join(', ')}`);
377373
}
378374
});
379375

380-
381376
const mustCallChecks = [];
382377

383-
384378
function runCallChecks(exitCode) {
385379
if (exitCode !== 0) return;
386380

Collapse file

‎test/common/index.mjs‎

Copy file name to clipboardExpand all lines: test/common/index.mjs
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,7 @@ export function leakedGlobals() {
6363
}
6464
}
6565

66-
// Turn this off if the test should not check for global leaks.
67-
export let globalCheck = true; // eslint-disable-line
68-
6966
process.on('exit', function() {
70-
if (!globalCheck) return;
7167
const leaked = leakedGlobals();
7268
if (leaked.length > 0) {
7369
assert.fail(`Unexpected global(s) found: ${leaked.join(', ')}`);
Collapse file

‎test/parallel/test-domain-crypto.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-domain-crypto.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if (!common.hasCrypto)
2929
const crypto = require('crypto');
3030

3131
// Pollution of global is intentional as part of test.
32-
common.globalCheck = false;
32+
common.allowGlobals(require('domain'));
3333
// See https://github.com/nodejs/node/commit/d1eff9ab
3434
global.domain = require('domain');
3535

Collapse file

‎test/parallel/test-global.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-global.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const fixtures = require('../common/fixtures');
2828

2929
const assert = require('assert');
3030

31-
common.globalCheck = false;
31+
common.allowGlobals('bar', 'foo');
3232

3333
baseFoo = 'foo'; // eslint-disable-line no-undef
3434
global.baseBar = 'bar';
Collapse file

‎test/parallel/test-repl-autolibs.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-repl-autolibs.js
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ const assert = require('assert');
2525
const util = require('util');
2626
const repl = require('repl');
2727

28-
// This test adds global variables
29-
common.globalCheck = false;
30-
3128
const putIn = new common.ArrayStream();
3229
repl.start('', putIn, null, true);
3330

@@ -65,6 +62,7 @@ function test2() {
6562
};
6663
const val = {};
6764
global.url = val;
65+
common.allowGlobals(val);
6866
assert(!gotWrite);
6967
putIn.run(['url']);
7068
assert(gotWrite);
Collapse file

‎test/parallel/test-repl-envvars.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-repl-envvars.js
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Flags: --expose-internals
44

5-
const common = require('../common');
5+
require('../common');
66
const stream = require('stream');
77
const REPL = require('internal/repl');
88
const assert = require('assert');
@@ -47,9 +47,6 @@ function run(test) {
4747
REPL.createInternalRepl(env, opts, function(err, repl) {
4848
assert.ifError(err);
4949

50-
// The REPL registers 'module' and 'require' globals
51-
common.allowGlobals(repl.context.module, repl.context.require);
52-
5350
assert.strictEqual(expected.terminal, repl.terminal,
5451
`Expected ${inspect(expected)} with ${inspect(env)}`);
5552
assert.strictEqual(expected.useColors, repl.useColors,
Collapse file

‎test/parallel/test-repl-history-perm.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-repl-history-perm.js
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ const replHistoryPath = path.join(tmpdir.path, '.node_repl_history');
3838
const checkResults = common.mustCall(function(err, r) {
3939
assert.ifError(err);
4040

41-
// The REPL registers 'module' and 'require' globals
42-
common.allowGlobals(r.context.module, r.context.require);
43-
4441
r.input.end();
4542
const stat = fs.statSync(replHistoryPath);
4643
const fileMode = stat.mode & 0o777;
Collapse file

‎test/parallel/test-repl-persistent-history.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-repl-persistent-history.js
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,6 @@ function runTest(assertCleaned) {
216216
throw err;
217217
}
218218

219-
// The REPL registers 'module' and 'require' globals
220-
common.allowGlobals(repl.context.module, repl.context.require);
221-
222219
repl.once('close', () => {
223220
if (repl._flushing) {
224221
repl.once('flushHistory', onClose);
Collapse file

‎test/parallel/test-repl-reset-event.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-repl-reset-event.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const assert = require('assert');
2626
const repl = require('repl');
2727
const util = require('util');
2828

29+
common.allowGlobals(42);
30+
2931
// Create a dummy stream that does nothing
3032
const dummy = new common.ArrayStream();
3133

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.