Skip to content

Commit 089362f

Browse files
TrottFishrock123
authored andcommitted
test,tools: limit lint tolerance of gc global
Lint rules permitted the `gc` global in any test file. This change limits it to just the files that need it. PR-URL: #6324 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 66903f6 commit 089362f

15 files changed

+33
-36
lines changed

test/.eslintrc

-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,3 @@
33
rules:
44
## common module is mandatory in tests
55
required-modules: [2, "common"]
6-
7-
globals:
8-
gc: false

test/addons/buffer-free-callback/test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ function check(size, alignment, offset) {
1111
buf = null;
1212
binding.check(slice);
1313
slice = null;
14-
gc();
15-
gc();
16-
gc();
14+
global.gc();
15+
global.gc();
16+
global.gc();
1717
}
1818

1919
check(64, 1, 0);

test/common.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ var knownGlobals = [setTimeout,
275275
global];
276276

277277
if (global.gc) {
278-
knownGlobals.push(gc);
278+
knownGlobals.push(global.gc);
279279
}
280280

281281
if (global.DTRACE_HTTP_SERVER_RESPONSE) {

test/gc/test-http-client-connaborted.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ function afterGC() {
5353

5454
var timer;
5555
function statusLater() {
56-
gc();
56+
global.gc();
5757
if (timer) clearTimeout(timer);
5858
timer = setTimeout(status, 1);
5959
}
6060

6161
function status() {
62-
gc();
62+
global.gc();
6363
console.log('Done: %d/%d', done, todo);
6464
console.log('Collected: %d/%d', countGC, count);
6565
if (done === todo) {

test/gc/test-http-client-onerror.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ function afterGC() {
6161

6262
var timer;
6363
function statusLater() {
64-
gc();
64+
global.gc();
6565
if (timer) clearTimeout(timer);
6666
timer = setTimeout(status, 1);
6767
}
6868

6969
function status() {
70-
gc();
70+
global.gc();
7171
console.log('Done: %d/%d', done, todo);
7272
console.log('Collected: %d/%d', countGC, count);
7373
if (done === todo) {

test/gc/test-http-client-timeout.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ function afterGC() {
6262

6363
var timer;
6464
function statusLater() {
65-
gc();
65+
global.gc();
6666
if (timer) clearTimeout(timer);
6767
timer = setTimeout(status, 1);
6868
}
6969

7070
function status() {
71-
gc();
71+
global.gc();
7272
console.log('Done: %d/%d', done, todo);
7373
console.log('Collected: %d/%d', countGC, count);
7474
if (done === todo) {

test/gc/test-http-client.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function getall() {
3131
res.resume();
3232
console.error('in cb');
3333
done += 1;
34-
res.on('end', gc);
34+
res.on('end', global.gc);
3535
}
3636

3737
var req = http.get({
@@ -57,7 +57,7 @@ function afterGC() {
5757
setInterval(status, 1000).unref();
5858

5959
function status() {
60-
gc();
60+
global.gc();
6161
console.log('Done: %d/%d', done, todo);
6262
console.log('Collected: %d/%d', countGC, count);
6363
if (done === todo) {

test/gc/test-net-timeout.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function getall() {
4343
//console.log('timeout (expected)')
4444
req.destroy();
4545
done++;
46-
gc();
46+
global.gc();
4747
});
4848

4949
count++;
@@ -63,13 +63,13 @@ function afterGC() {
6363
setInterval(status, 100).unref();
6464

6565
function status() {
66-
gc();
66+
global.gc();
6767
console.log('Done: %d/%d', done, todo);
6868
console.log('Collected: %d/%d', countGC, count);
6969
if (done === todo) {
7070
/* Give libuv some time to make close callbacks. */
7171
setTimeout(function() {
72-
gc();
72+
global.gc();
7373
console.log('All should be collected now.');
7474
console.log('Collected: %d/%d', countGC, count);
7575
assert(count === countGC);

test/parallel/test-http-parser-bad-ref.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var messagesComplete = 0;
1818

1919
function flushPool() {
2020
Buffer.allocUnsafe(Buffer.poolSize - 1);
21-
gc();
21+
global.gc();
2222
}
2323

2424
function demoBug(part1, part2) {

test/parallel/test-vm-create-and-run-in-context.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ assert.equal('lala', context.thing);
2424
console.error('run in contextified sandbox without referencing the context');
2525
var sandbox = {x: 1};
2626
vm.createContext(sandbox);
27-
gc();
27+
global.gc();
2828
vm.runInContext('x = 2', sandbox);
2929
// Should not crash.

test/parallel/test-vm-run-in-new-context.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const common = require('../common');
55
const assert = require('assert');
66
const vm = require('vm');
77

8-
assert.equal(typeof gc, 'function', 'Run this test with --expose-gc');
8+
assert.equal(typeof global.gc, 'function', 'Run this test with --expose-gc');
99

1010
common.globalCheck = false;
1111

@@ -48,6 +48,6 @@ assert.equal(f.a, 2);
4848

4949
console.error('use function in context without referencing context');
5050
var fn = vm.runInNewContext('(function() { obj.p = {}; })', { obj: {} });
51-
gc();
51+
global.gc();
5252
fn();
5353
// Should not crash

test/pummel/test-net-connect-memleak.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@ var common = require('../common');
55
var assert = require('assert');
66
var net = require('net');
77

8-
assert(typeof gc === 'function', 'Run this test with --expose-gc');
8+
assert(typeof global.gc === 'function', 'Run this test with --expose-gc');
99
net.createServer(function() {}).listen(common.PORT);
1010

1111
var before = 0;
1212
(function() {
1313
// 2**26 == 64M entries
14-
gc();
14+
global.gc();
1515
for (var i = 0, junk = [0]; i < 26; ++i) junk = junk.concat(junk);
1616
before = process.memoryUsage().rss;
1717

1818
net.createConnection(common.PORT, '127.0.0.1', function() {
1919
assert(junk.length != 0); // keep reference alive
2020
setTimeout(done, 10);
21-
gc();
21+
global.gc();
2222
});
2323
})();
2424

2525
function done() {
26-
gc();
26+
global.gc();
2727
var after = process.memoryUsage().rss;
2828
var reclaimed = (before - after) / 1024;
2929
console.log('%d kB reclaimed', reclaimed);

test/pummel/test-regress-GH-814.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var timeToQuit = Date.now() + 8e3; //Test during no more than this seconds.
3838

3939
if (PASS) {
4040
fs.write(testFileFD, newBuffer(kBufSize, 0x61), 0, kBufSize, -1, cb);
41-
gc();
41+
global.gc();
4242
var nuBuf = Buffer.allocUnsafe(kBufSize);
4343
neverWrittenBuffer.copy(nuBuf);
4444
if (bufPool.push(nuBuf) > 100) {

test/pummel/test-regress-GH-814_2.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ function writer() {
4444
}, 555);
4545
} else {
4646
fs.write(testFD, newBuffer(kBufSize, 0x61), 0, kBufSize, -1, writerCB);
47-
gc();
48-
gc();
49-
gc();
50-
gc();
51-
gc();
52-
gc();
47+
global.gc();
48+
global.gc();
49+
global.gc();
50+
global.gc();
51+
global.gc();
52+
global.gc();
5353
var nuBuf = Buffer.allocUnsafe(kBufSize);
5454
neverWrittenBuffer.copy(nuBuf);
5555
if (bufPool.push(nuBuf) > 100) {

test/pummel/test-tls-connect-memleak.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var tls = require('tls');
1212

1313
var fs = require('fs');
1414

15-
assert(typeof gc === 'function', 'Run this test with --expose-gc');
15+
assert(typeof global.gc === 'function', 'Run this test with --expose-gc');
1616

1717
tls.createServer({
1818
cert: fs.readFileSync(common.fixturesDir + '/test_cert.pem'),
@@ -27,13 +27,13 @@ tls.createServer({
2727
tls.connect(common.PORT, '127.0.0.1', options, function() {
2828
assert(junk.length != 0); // keep reference alive
2929
setTimeout(done, 10);
30-
gc();
30+
global.gc();
3131
});
3232
})();
3333

3434
function done() {
3535
var before = process.memoryUsage().rss;
36-
gc();
36+
global.gc();
3737
var after = process.memoryUsage().rss;
3838
var reclaimed = (before - after) / 1024;
3939
console.log('%d kB reclaimed', reclaimed);

0 commit comments

Comments
 (0)