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:
## common module is mandatory in tests
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;
binding.check(slice);
slice = null;
gc();
gc();
gc();
global.gc();
global.gc();
global.gc();
}
check(64, 1, 0);

2
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) {

4
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) {

4
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) {

4
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) {

4
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) {

6
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);

2
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) {

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');
var sandbox = {x: 1};
vm.createContext(sandbox);
gc();
global.gc();
vm.runInContext('x = 2', sandbox);
// 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 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

8
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);

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) {
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) {

12
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) {

6
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);

Loading…
Cancel
Save