Add delay into test-debugger-client

This commit is contained in:
Ryan Dahl 2011-01-11 16:30:01 -08:00
parent 8e461673c4
commit 7c0f453b7c

View File

@ -126,23 +126,27 @@ function doTest(cb, done) {
var didTryConnect = false; var didTryConnect = false;
nodeProcess.stderr.setEncoding('utf8'); nodeProcess.stderr.setEncoding('utf8');
var b = ''
nodeProcess.stderr.on('data', function (data) { nodeProcess.stderr.on('data', function (data) {
if (didTryConnect == false && /debugger/.test(data)) { b += data;
if (didTryConnect == false && /debugger listening on port/.test(b)) {
didTryConnect = true; didTryConnect = true;
// Wait for some data before trying to connect setTimeout(function() {
var c = new debug.Client(); // Wait for some data before trying to connect
process.stdout.write(">>> connecting..."); var c = new debug.Client();
c.connect(debug.port) process.stdout.write(">>> connecting...");
c.on('ready', function () { c.connect(debug.port)
connectCount++; c.on('ready', function () {
console.log("ready!"); connectCount++;
cb(c, function () { console.log("ready!");
console.error(">>> killing node process %d\n\n", nodeProcess.pid); cb(c, function () {
nodeProcess.kill(); console.error(">>> killing node process %d\n\n", nodeProcess.pid);
done(); nodeProcess.kill();
done();
});
}); });
}); }, 100);
} }
}); });
} }