Fix tests

This commit is contained in:
Ryan Dahl 2010-08-13 11:54:40 -04:00
parent 03123435e0
commit a8c2bb41af
5 changed files with 105 additions and 97 deletions

View File

@ -22,8 +22,10 @@ function runAb(opts, callback) {
var command = "ab " + opts + " http://127.0.0.1:" + common.PORT + "/";
exec(command, function (err, stdout, stderr) {
if (err) {
if (stderr.indexOf("ab") >= 0) {
console.log("ab not installed? skipping test.\n" + stderr);
process.exit();
process.reallyExit(0);
}
return;
}
if (err) throw err;

View File

@ -43,8 +43,8 @@ function pingPongTest (port, host, on_complete) {
socket.server.close();
});
});
server.listen(port, host);
server.listen(port, host, function () {
var client = net.createConnection(port, host);
client.setEncoding("utf8");
@ -83,6 +83,7 @@ function pingPongTest (port, host, on_complete) {
if (on_complete) on_complete();
tests_run += 1;
});
});
}
pingPongTest(common.PORT);

View File

@ -43,8 +43,8 @@ function pingPongTest (port, host, on_complete) {
socket.server.close();
});
});
server.listen(port, host);
server.listen(port, host, function () {
var client = net.createConnection(port, host);
client.setEncoding("utf8");
@ -82,6 +82,7 @@ function pingPongTest (port, host, on_complete) {
if (on_complete) on_complete();
tests_run += 1;
});
});
}
/* All are run at once, so run on different ports */

View File

@ -3,6 +3,10 @@ assert = common.assert
net = require("net");
N = 160*1024; // 30kb
chars_recved = 0;
npauses = 0;
console.log("build big string");
var body = "";
for (var i = 0; i < N; i++) {
@ -17,13 +21,7 @@ server = net.createServer(function (connection) {
connection.end();
});
});
server.listen(common.PORT);
chars_recved = 0;
npauses = 0;
server.listen(common.PORT, function () {
var paused = false;
client = net.createConnection(common.PORT);
client.setEncoding("ascii");
@ -49,6 +47,9 @@ client.addListener("end", function () {
server.close();
client.end();
});
});
process.addListener("exit", function () {
assert.equal(N, chars_recved);

View File

@ -23,7 +23,10 @@ function runAb(opts, callback) {
var command = "ab " + opts + " http://127.0.0.1:" + common.PORT + "/";
exec(command, function (err, stdout, stderr) {
if (err) {
if (stderr.indexOf("ab") >= 0) {
console.log("ab not installed? skipping test.\n" + stderr);
process.reallyExit(0);
}
process.exit();
return;
}