Browse Source

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: https://github.com/nodejs/node/pull/6324
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
process-exit-stdio-flushing
Rich Trott 9 years ago
parent
commit
6c49714df0
  1. 3
      test/.eslintrc
  2. 6
      test/addons/buffer-free-callback/test.js
  3. 2
      test/common.js
  4. 4
      test/gc/test-http-client-connaborted.js
  5. 4
      test/gc/test-http-client-onerror.js
  6. 4
      test/gc/test-http-client-timeout.js
  7. 4
      test/gc/test-http-client.js
  8. 6
      test/gc/test-net-timeout.js
  9. 2
      test/parallel/test-http-parser-bad-ref.js
  10. 2
      test/parallel/test-vm-create-and-run-in-context.js
  11. 4
      test/parallel/test-vm-run-in-new-context.js
  12. 8
      test/pummel/test-net-connect-memleak.js
  13. 2
      test/pummel/test-regress-GH-814.js
  14. 12
      test/pummel/test-regress-GH-814_2.js
  15. 6
      test/pummel/test-tls-connect-memleak.js

3
test/.eslintrc

@ -3,6 +3,3 @@
rules: rules:
## common module is mandatory in tests ## common module is mandatory in tests
required-modules: [2, "common"] required-modules: [2, "common"]
globals:
gc: false

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

@ -11,9 +11,9 @@ function check(size, alignment, offset) {
buf = null; buf = null;
binding.check(slice); binding.check(slice);
slice = null; slice = null;
gc(); global.gc();
gc(); global.gc();
gc(); global.gc();
} }
check(64, 1, 0); check(64, 1, 0);

2
test/common.js

@ -275,7 +275,7 @@ var knownGlobals = [setTimeout,
global]; global];
if (global.gc) { if (global.gc) {
knownGlobals.push(gc); knownGlobals.push(global.gc);
} }
if (global.DTRACE_HTTP_SERVER_RESPONSE) { if (global.DTRACE_HTTP_SERVER_RESPONSE) {

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

@ -53,13 +53,13 @@ function afterGC() {
var timer; var timer;
function statusLater() { function statusLater() {
gc(); global.gc();
if (timer) clearTimeout(timer); if (timer) clearTimeout(timer);
timer = setTimeout(status, 1); timer = setTimeout(status, 1);
} }
function status() { function status() {
gc(); global.gc();
console.log('Done: %d/%d', done, todo); console.log('Done: %d/%d', done, todo);
console.log('Collected: %d/%d', countGC, count); console.log('Collected: %d/%d', countGC, count);
if (done === todo) { if (done === todo) {

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

@ -61,13 +61,13 @@ function afterGC() {
var timer; var timer;
function statusLater() { function statusLater() {
gc(); global.gc();
if (timer) clearTimeout(timer); if (timer) clearTimeout(timer);
timer = setTimeout(status, 1); timer = setTimeout(status, 1);
} }
function status() { function status() {
gc(); global.gc();
console.log('Done: %d/%d', done, todo); console.log('Done: %d/%d', done, todo);
console.log('Collected: %d/%d', countGC, count); console.log('Collected: %d/%d', countGC, count);
if (done === todo) { if (done === todo) {

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

@ -62,13 +62,13 @@ function afterGC() {
var timer; var timer;
function statusLater() { function statusLater() {
gc(); global.gc();
if (timer) clearTimeout(timer); if (timer) clearTimeout(timer);
timer = setTimeout(status, 1); timer = setTimeout(status, 1);
} }
function status() { function status() {
gc(); global.gc();
console.log('Done: %d/%d', done, todo); console.log('Done: %d/%d', done, todo);
console.log('Collected: %d/%d', countGC, count); console.log('Collected: %d/%d', countGC, count);
if (done === todo) { if (done === todo) {

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

@ -31,7 +31,7 @@ function getall() {
res.resume(); res.resume();
console.error('in cb'); console.error('in cb');
done += 1; done += 1;
res.on('end', gc); res.on('end', global.gc);
} }
var req = http.get({ var req = http.get({
@ -57,7 +57,7 @@ function afterGC() {
setInterval(status, 1000).unref(); setInterval(status, 1000).unref();
function status() { function status() {
gc(); global.gc();
console.log('Done: %d/%d', done, todo); console.log('Done: %d/%d', done, todo);
console.log('Collected: %d/%d', countGC, count); console.log('Collected: %d/%d', countGC, count);
if (done === todo) { if (done === todo) {

6
test/gc/test-net-timeout.js

@ -43,7 +43,7 @@ function getall() {
//console.log('timeout (expected)') //console.log('timeout (expected)')
req.destroy(); req.destroy();
done++; done++;
gc(); global.gc();
}); });
count++; count++;
@ -63,13 +63,13 @@ function afterGC() {
setInterval(status, 100).unref(); setInterval(status, 100).unref();
function status() { function status() {
gc(); global.gc();
console.log('Done: %d/%d', done, todo); console.log('Done: %d/%d', done, todo);
console.log('Collected: %d/%d', countGC, count); console.log('Collected: %d/%d', countGC, count);
if (done === todo) { if (done === todo) {
/* Give libuv some time to make close callbacks. */ /* Give libuv some time to make close callbacks. */
setTimeout(function() { setTimeout(function() {
gc(); global.gc();
console.log('All should be collected now.'); console.log('All should be collected now.');
console.log('Collected: %d/%d', countGC, count); console.log('Collected: %d/%d', countGC, count);
assert(count === countGC); assert(count === countGC);

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

@ -18,7 +18,7 @@ var messagesComplete = 0;
function flushPool() { function flushPool() {
Buffer.allocUnsafe(Buffer.poolSize - 1); Buffer.allocUnsafe(Buffer.poolSize - 1);
gc(); global.gc();
} }
function demoBug(part1, part2) { function demoBug(part1, part2) {

2
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'); console.error('run in contextified sandbox without referencing the context');
var sandbox = {x: 1}; var sandbox = {x: 1};
vm.createContext(sandbox); vm.createContext(sandbox);
gc(); global.gc();
vm.runInContext('x = 2', sandbox); vm.runInContext('x = 2', sandbox);
// Should not crash. // Should not crash.

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

@ -5,7 +5,7 @@ const common = require('../common');
const assert = require('assert'); const assert = require('assert');
const vm = require('vm'); 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; common.globalCheck = false;
@ -48,6 +48,6 @@ assert.equal(f.a, 2);
console.error('use function in context without referencing context'); console.error('use function in context without referencing context');
var fn = vm.runInNewContext('(function() { obj.p = {}; })', { obj: {} }); var fn = vm.runInNewContext('(function() { obj.p = {}; })', { obj: {} });
gc(); global.gc();
fn(); fn();
// Should not crash // Should not crash

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

@ -5,25 +5,25 @@ var common = require('../common');
var assert = require('assert'); var assert = require('assert');
var net = require('net'); 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); net.createServer(function() {}).listen(common.PORT);
var before = 0; var before = 0;
(function() { (function() {
// 2**26 == 64M entries // 2**26 == 64M entries
gc(); global.gc();
for (var i = 0, junk = [0]; i < 26; ++i) junk = junk.concat(junk); for (var i = 0, junk = [0]; i < 26; ++i) junk = junk.concat(junk);
before = process.memoryUsage().rss; before = process.memoryUsage().rss;
net.createConnection(common.PORT, '127.0.0.1', function() { net.createConnection(common.PORT, '127.0.0.1', function() {
assert(junk.length != 0); // keep reference alive assert(junk.length != 0); // keep reference alive
setTimeout(done, 10); setTimeout(done, 10);
gc(); global.gc();
}); });
})(); })();
function done() { function done() {
gc(); global.gc();
var after = process.memoryUsage().rss; var after = process.memoryUsage().rss;
var reclaimed = (before - after) / 1024; var reclaimed = (before - after) / 1024;
console.log('%d kB reclaimed', reclaimed); console.log('%d kB reclaimed', reclaimed);

2
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) { if (PASS) {
fs.write(testFileFD, newBuffer(kBufSize, 0x61), 0, kBufSize, -1, cb); fs.write(testFileFD, newBuffer(kBufSize, 0x61), 0, kBufSize, -1, cb);
gc(); global.gc();
var nuBuf = Buffer.allocUnsafe(kBufSize); var nuBuf = Buffer.allocUnsafe(kBufSize);
neverWrittenBuffer.copy(nuBuf); neverWrittenBuffer.copy(nuBuf);
if (bufPool.push(nuBuf) > 100) { if (bufPool.push(nuBuf) > 100) {

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

@ -44,12 +44,12 @@ function writer() {
}, 555); }, 555);
} else { } else {
fs.write(testFD, newBuffer(kBufSize, 0x61), 0, kBufSize, -1, writerCB); fs.write(testFD, newBuffer(kBufSize, 0x61), 0, kBufSize, -1, writerCB);
gc(); global.gc();
gc(); global.gc();
gc(); global.gc();
gc(); global.gc();
gc(); global.gc();
gc(); global.gc();
var nuBuf = Buffer.allocUnsafe(kBufSize); var nuBuf = Buffer.allocUnsafe(kBufSize);
neverWrittenBuffer.copy(nuBuf); neverWrittenBuffer.copy(nuBuf);
if (bufPool.push(nuBuf) > 100) { if (bufPool.push(nuBuf) > 100) {

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

@ -12,7 +12,7 @@ var tls = require('tls');
var fs = require('fs'); 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({ tls.createServer({
cert: fs.readFileSync(common.fixturesDir + '/test_cert.pem'), cert: fs.readFileSync(common.fixturesDir + '/test_cert.pem'),
@ -27,13 +27,13 @@ tls.createServer({
tls.connect(common.PORT, '127.0.0.1', options, function() { tls.connect(common.PORT, '127.0.0.1', options, function() {
assert(junk.length != 0); // keep reference alive assert(junk.length != 0); // keep reference alive
setTimeout(done, 10); setTimeout(done, 10);
gc(); global.gc();
}); });
})(); })();
function done() { function done() {
var before = process.memoryUsage().rss; var before = process.memoryUsage().rss;
gc(); global.gc();
var after = process.memoryUsage().rss; var after = process.memoryUsage().rss;
var reclaimed = (before - after) / 1024; var reclaimed = (before - after) / 1024;
console.log('%d kB reclaimed', reclaimed); console.log('%d kB reclaimed', reclaimed);

Loading…
Cancel
Save