From a9fc63f7a188fd96db656a5bef940b4ed2076560 Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 4 May 2012 10:32:42 -0700 Subject: [PATCH] Clean up gc tests This fixes the additional issues brought up in #3179. --- test/gc/test-http-client-connaborted.js | 7 +++++-- test/gc/test-http-client-onerror.js | 7 +++++-- test/gc/test-http-client-timeout.js | 7 +++++-- test/gc/test-http-client.js | 8 ++++++-- test/gc/test-net-timeout.js | 9 ++++++--- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/test/gc/test-http-client-connaborted.js b/test/gc/test-http-client-connaborted.js index 84d7ca588eb..80ac055109f 100644 --- a/test/gc/test-http-client-connaborted.js +++ b/test/gc/test-http-client-connaborted.js @@ -10,7 +10,7 @@ var http = require('http'), done = 0, count = 0, countGC = 0, - todo = 18, + todo = 500, common = require('../common.js'), assert = require('assert'), PORT = common.PORT; @@ -45,8 +45,11 @@ function afterGC(){ countGC ++; } +var timer; function statusLater() { - setTimeout(status, 1); + gc(); + if (timer) clearTimeout(timer); + timer = setTimeout(status, 1); } function status() { diff --git a/test/gc/test-http-client-onerror.js b/test/gc/test-http-client-onerror.js index 58724893a92..6bea7c000d8 100644 --- a/test/gc/test-http-client-onerror.js +++ b/test/gc/test-http-client-onerror.js @@ -11,7 +11,7 @@ var http = require('http'), done = 0, count = 0, countGC = 0, - todo = 18, + todo = 500, common = require('../common.js'), assert = require('assert'), PORT = common.PORT; @@ -49,8 +49,11 @@ function afterGC(){ countGC ++; } +var timer; function statusLater() { - setTimeout(status, 1); + gc(); + if (timer) clearTimeout(timer); + timer = setTimeout(status, 1); } function status() { diff --git a/test/gc/test-http-client-timeout.js b/test/gc/test-http-client-timeout.js index 32302a439d8..c98a008a2c3 100644 --- a/test/gc/test-http-client-timeout.js +++ b/test/gc/test-http-client-timeout.js @@ -13,7 +13,7 @@ var http = require('http'), done = 0, count = 0, countGC = 0, - todo = 18, + todo = 500, common = require('../common.js'), assert = require('assert'), PORT = common.PORT; @@ -52,8 +52,11 @@ function afterGC(){ countGC ++; } +var timer; function statusLater() { - setTimeout(status, 1); + gc(); + if (timer) clearTimeout(timer); + timer = setTimeout(status, 1); } function status() { diff --git a/test/gc/test-http-client.js b/test/gc/test-http-client.js index 913ca7b1af9..33be9ea15c4 100644 --- a/test/gc/test-http-client.js +++ b/test/gc/test-http-client.js @@ -10,7 +10,7 @@ var http = require('http'), done = 0, count = 0, countGC = 0, - todo = 5, + todo = 500, common = require('../common.js'), assert = require('assert'), PORT = common.PORT; @@ -47,8 +47,11 @@ function afterGC(){ countGC ++; } +var timer; function statusLater() { - setTimeout(status, 1); + gc(); + if (timer) clearTimeout(timer); + timer = setTimeout(status, 1); } function status() { @@ -61,3 +64,4 @@ function status() { process.exit(0); } } + diff --git a/test/gc/test-net-timeout.js b/test/gc/test-net-timeout.js index 789193ee37c..52f1176174d 100644 --- a/test/gc/test-net-timeout.js +++ b/test/gc/test-net-timeout.js @@ -13,7 +13,7 @@ var net = require('net'), done = 0, count = 0, countGC = 0, - todo = 18, + todo = 500, common = require('../common.js'), assert = require('assert'), PORT = common.PORT; @@ -36,7 +36,7 @@ function getall() { count++; weak(req, afterGC); - })() + })(); } } @@ -44,8 +44,11 @@ function afterGC(){ countGC ++; } +var timer; function statusLater() { - setTimeout(status, 1); + gc(); + if (timer) clearTimeout(timer); + timer = setTimeout(status, 1); } function status() {