Browse Source

test: relax timing in test-http-exit-delay

This test was originally intended to guard against regressions for
commit 16b59cbc74.

As such, it only needs to ensure that process exit has not been held up
by the date cache timer, which would fire on the next second.
v0.11.11-release
Alexis Campailla 11 years ago
committed by Timothy J Fontaine
parent
commit
5393d02c0c
  1. 15
      test/simple/test-http-exit-delay.js

15
test/simple/test-http-exit-delay.js

@ -30,16 +30,16 @@ var server = http.createServer(function(req, res) {
res.end('Success'); res.end('Success');
}); });
server.close(function() { server.close();
start = process.hrtime();
});
}); });
server.listen(common.PORT, 'localhost', function() { server.listen(common.PORT, 'localhost', function() {
var interval_id = setInterval(function() { var interval_id = setInterval(function() {
if (new Date().getMilliseconds() > 100) start = new Date();
if (start.getMilliseconds() > 100)
return; return;
console.log(start.toISOString());
var req = http.request({ var req = http.request({
'host': 'localhost', 'host': 'localhost',
'port': common.PORT, 'port': common.PORT,
@ -53,8 +53,9 @@ server.listen(common.PORT, 'localhost', function() {
}); });
process.on('exit', function() { process.on('exit', function() {
var d = process.hrtime(start); var end = new Date();
assert.equal(d[0], 0); console.log(end.toISOString());
assert(d[1] / 1e9 < 0.03); assert.equal(start.getSeconds(), end.getSeconds());
assert(end.getMilliseconds() < 900);
console.log('ok'); console.log('ok');
}); });

Loading…
Cancel
Save