test: remove timer from test-http-1.0
It's possible that the `end` event is emitted after the timeout fires causing the test to fail. Just remove the timer. If for some reason the `end` would never fire, the test will fail with a timeout. PR-URL: https://github.com/nodejs/node/pull/5129 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
parent
c7b127025a
commit
6a3d38f00f
@ -15,13 +15,6 @@ function test(handler, request_generator, response_validator) {
|
|||||||
var client_got_eof = false;
|
var client_got_eof = false;
|
||||||
var server_response = '';
|
var server_response = '';
|
||||||
|
|
||||||
function cleanup() {
|
|
||||||
server.close();
|
|
||||||
response_validator(server_response, client_got_eof, true);
|
|
||||||
}
|
|
||||||
var timer = setTimeout(cleanup, common.platformTimeout(1000));
|
|
||||||
process.on('exit', cleanup);
|
|
||||||
|
|
||||||
server.listen(port);
|
server.listen(port);
|
||||||
server.on('listening', function() {
|
server.on('listening', function() {
|
||||||
var c = net.createConnection(port);
|
var c = net.createConnection(port);
|
||||||
@ -36,14 +29,12 @@ function test(handler, request_generator, response_validator) {
|
|||||||
server_response += chunk;
|
server_response += chunk;
|
||||||
});
|
});
|
||||||
|
|
||||||
c.on('end', function() {
|
c.on('end', common.mustCall(function() {
|
||||||
client_got_eof = true;
|
client_got_eof = true;
|
||||||
c.end();
|
c.end();
|
||||||
server.close();
|
server.close();
|
||||||
clearTimeout(timer);
|
|
||||||
process.removeListener('exit', cleanup);
|
|
||||||
response_validator(server_response, client_got_eof, false);
|
response_validator(server_response, client_got_eof, false);
|
||||||
});
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user