diff --git a/test/.eslintrc b/test/.eslintrc index 172c0bfb9d08bf..b498b08f4d7d0c 100644 --- a/test/.eslintrc +++ b/test/.eslintrc @@ -3,6 +3,3 @@ rules: ## common module is mandatory in tests required-modules: [2, "common"] - -globals: - gc: false diff --git a/test/addons/buffer-free-callback/test.js b/test/addons/buffer-free-callback/test.js index f9d7ec90f8c0e9..09c19baecf7213 100644 --- a/test/addons/buffer-free-callback/test.js +++ b/test/addons/buffer-free-callback/test.js @@ -11,9 +11,9 @@ function check(size, alignment, offset) { buf = null; binding.check(slice); slice = null; - gc(); - gc(); - gc(); + global.gc(); + global.gc(); + global.gc(); } check(64, 1, 0); diff --git a/test/common.js b/test/common.js index 48f8ea719c5c63..ffd1ba1366f15f 100644 --- a/test/common.js +++ b/test/common.js @@ -275,7 +275,7 @@ var knownGlobals = [setTimeout, global]; if (global.gc) { - knownGlobals.push(gc); + knownGlobals.push(global.gc); } if (global.DTRACE_HTTP_SERVER_RESPONSE) { diff --git a/test/gc/test-http-client-connaborted.js b/test/gc/test-http-client-connaborted.js index 074457a7511fc5..c203f43cadb18a 100644 --- a/test/gc/test-http-client-connaborted.js +++ b/test/gc/test-http-client-connaborted.js @@ -53,13 +53,13 @@ function afterGC() { var timer; function statusLater() { - gc(); + global.gc(); if (timer) clearTimeout(timer); timer = setTimeout(status, 1); } function status() { - gc(); + global.gc(); console.log('Done: %d/%d', done, todo); console.log('Collected: %d/%d', countGC, count); if (done === todo) { diff --git a/test/gc/test-http-client-onerror.js b/test/gc/test-http-client-onerror.js index 2e5ef6a54288d4..0dc07691d41415 100644 --- a/test/gc/test-http-client-onerror.js +++ b/test/gc/test-http-client-onerror.js @@ -61,13 +61,13 @@ function afterGC() { var timer; function statusLater() { - gc(); + global.gc(); if (timer) clearTimeout(timer); timer = setTimeout(status, 1); } function status() { - gc(); + global.gc(); console.log('Done: %d/%d', done, todo); console.log('Collected: %d/%d', countGC, count); if (done === todo) { diff --git a/test/gc/test-http-client-timeout.js b/test/gc/test-http-client-timeout.js index d80cf9cdee1532..ef930a9d606f83 100644 --- a/test/gc/test-http-client-timeout.js +++ b/test/gc/test-http-client-timeout.js @@ -62,13 +62,13 @@ function afterGC() { var timer; function statusLater() { - gc(); + global.gc(); if (timer) clearTimeout(timer); timer = setTimeout(status, 1); } function status() { - gc(); + global.gc(); console.log('Done: %d/%d', done, todo); console.log('Collected: %d/%d', countGC, count); if (done === todo) { diff --git a/test/gc/test-http-client.js b/test/gc/test-http-client.js index 73f284a042c37a..6f5d8b2d904469 100644 --- a/test/gc/test-http-client.js +++ b/test/gc/test-http-client.js @@ -31,7 +31,7 @@ function getall() { res.resume(); console.error('in cb'); done += 1; - res.on('end', gc); + res.on('end', global.gc); } var req = http.get({ @@ -57,7 +57,7 @@ function afterGC() { setInterval(status, 1000).unref(); function status() { - gc(); + global.gc(); console.log('Done: %d/%d', done, todo); console.log('Collected: %d/%d', countGC, count); if (done === todo) { diff --git a/test/gc/test-net-timeout.js b/test/gc/test-net-timeout.js index 24671a647e0eac..62080b68dc3904 100644 --- a/test/gc/test-net-timeout.js +++ b/test/gc/test-net-timeout.js @@ -43,7 +43,7 @@ function getall() { //console.log('timeout (expected)') req.destroy(); done++; - gc(); + global.gc(); }); count++; @@ -63,13 +63,13 @@ function afterGC() { setInterval(status, 100).unref(); function status() { - gc(); + global.gc(); console.log('Done: %d/%d', done, todo); console.log('Collected: %d/%d', countGC, count); if (done === todo) { /* Give libuv some time to make close callbacks. */ setTimeout(function() { - gc(); + global.gc(); console.log('All should be collected now.'); console.log('Collected: %d/%d', countGC, count); assert(count === countGC); diff --git a/test/parallel/test-http-parser-bad-ref.js b/test/parallel/test-http-parser-bad-ref.js index b7f132a3ea36fb..3ba9ee60b660a5 100644 --- a/test/parallel/test-http-parser-bad-ref.js +++ b/test/parallel/test-http-parser-bad-ref.js @@ -18,7 +18,7 @@ var messagesComplete = 0; function flushPool() { Buffer.allocUnsafe(Buffer.poolSize - 1); - gc(); + global.gc(); } function demoBug(part1, part2) { diff --git a/test/parallel/test-vm-create-and-run-in-context.js b/test/parallel/test-vm-create-and-run-in-context.js index 15efc8f527b8c9..fc92cf2f6cb6eb 100644 --- a/test/parallel/test-vm-create-and-run-in-context.js +++ b/test/parallel/test-vm-create-and-run-in-context.js @@ -24,6 +24,6 @@ assert.equal('lala', context.thing); console.error('run in contextified sandbox without referencing the context'); var sandbox = {x: 1}; vm.createContext(sandbox); -gc(); +global.gc(); vm.runInContext('x = 2', sandbox); // Should not crash. diff --git a/test/parallel/test-vm-run-in-new-context.js b/test/parallel/test-vm-run-in-new-context.js index 1467ea1e17d808..956e02306d4fb8 100644 --- a/test/parallel/test-vm-run-in-new-context.js +++ b/test/parallel/test-vm-run-in-new-context.js @@ -5,7 +5,7 @@ const common = require('../common'); const assert = require('assert'); const vm = require('vm'); -assert.equal(typeof gc, 'function', 'Run this test with --expose-gc'); +assert.equal(typeof global.gc, 'function', 'Run this test with --expose-gc'); common.globalCheck = false; @@ -48,6 +48,6 @@ assert.equal(f.a, 2); console.error('use function in context without referencing context'); var fn = vm.runInNewContext('(function() { obj.p = {}; })', { obj: {} }); -gc(); +global.gc(); fn(); // Should not crash diff --git a/test/pummel/test-net-connect-memleak.js b/test/pummel/test-net-connect-memleak.js index 855bf1f070d7c8..e30ca2e6b0b72a 100644 --- a/test/pummel/test-net-connect-memleak.js +++ b/test/pummel/test-net-connect-memleak.js @@ -5,25 +5,25 @@ var common = require('../common'); var assert = require('assert'); var net = require('net'); -assert(typeof gc === 'function', 'Run this test with --expose-gc'); +assert(typeof global.gc === 'function', 'Run this test with --expose-gc'); net.createServer(function() {}).listen(common.PORT); var before = 0; (function() { // 2**26 == 64M entries - gc(); + global.gc(); for (var i = 0, junk = [0]; i < 26; ++i) junk = junk.concat(junk); before = process.memoryUsage().rss; net.createConnection(common.PORT, '127.0.0.1', function() { assert(junk.length != 0); // keep reference alive setTimeout(done, 10); - gc(); + global.gc(); }); })(); function done() { - gc(); + global.gc(); var after = process.memoryUsage().rss; var reclaimed = (before - after) / 1024; console.log('%d kB reclaimed', reclaimed); diff --git a/test/pummel/test-regress-GH-814.js b/test/pummel/test-regress-GH-814.js index 031276efa602e2..d2f85bdf3ef324 100644 --- a/test/pummel/test-regress-GH-814.js +++ b/test/pummel/test-regress-GH-814.js @@ -38,7 +38,7 @@ var timeToQuit = Date.now() + 8e3; //Test during no more than this seconds. if (PASS) { fs.write(testFileFD, newBuffer(kBufSize, 0x61), 0, kBufSize, -1, cb); - gc(); + global.gc(); var nuBuf = Buffer.allocUnsafe(kBufSize); neverWrittenBuffer.copy(nuBuf); if (bufPool.push(nuBuf) > 100) { diff --git a/test/pummel/test-regress-GH-814_2.js b/test/pummel/test-regress-GH-814_2.js index c7a84b5ea67086..7909a461f37956 100644 --- a/test/pummel/test-regress-GH-814_2.js +++ b/test/pummel/test-regress-GH-814_2.js @@ -44,12 +44,12 @@ function writer() { }, 555); } else { fs.write(testFD, newBuffer(kBufSize, 0x61), 0, kBufSize, -1, writerCB); - gc(); - gc(); - gc(); - gc(); - gc(); - gc(); + global.gc(); + global.gc(); + global.gc(); + global.gc(); + global.gc(); + global.gc(); var nuBuf = Buffer.allocUnsafe(kBufSize); neverWrittenBuffer.copy(nuBuf); if (bufPool.push(nuBuf) > 100) { diff --git a/test/pummel/test-tls-connect-memleak.js b/test/pummel/test-tls-connect-memleak.js index b8ddc78fab6e4e..41617ba259018c 100644 --- a/test/pummel/test-tls-connect-memleak.js +++ b/test/pummel/test-tls-connect-memleak.js @@ -12,7 +12,7 @@ var tls = require('tls'); var fs = require('fs'); -assert(typeof gc === 'function', 'Run this test with --expose-gc'); +assert(typeof global.gc === 'function', 'Run this test with --expose-gc'); tls.createServer({ cert: fs.readFileSync(common.fixturesDir + '/test_cert.pem'), @@ -27,13 +27,13 @@ tls.createServer({ tls.connect(common.PORT, '127.0.0.1', options, function() { assert(junk.length != 0); // keep reference alive setTimeout(done, 10); - gc(); + global.gc(); }); })(); function done() { var before = process.memoryUsage().rss; - gc(); + global.gc(); var after = process.memoryUsage().rss; var reclaimed = (before - after) / 1024; console.log('%d kB reclaimed', reclaimed);