From: Fedor Indutny Date: Sat, 5 Nov 2011 07:47:21 +0000 (+0600) Subject: test: debugger-repl should wait for 'drain' event X-Git-Tag: v0.6.1~45 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=da82daf54c65b26112c020f4e2fe51a4ccab9041;p=platform%2Fupstream%2Fnodejs.git test: debugger-repl should wait for 'drain' event --- diff --git a/test/simple/test-debugger-repl.js b/test/simple/test-debugger-repl.js index ef560e7..df1b142 100644 --- a/test/simple/test-debugger-repl.js +++ b/test/simple/test-debugger-repl.js @@ -58,15 +58,20 @@ child.on('line', function(line) { function addTest(input, output) { function next() { if (expected.length > 0) { - child.stdin.write(expected[0].input + '\n'); + var res = child.stdin.write(expected[0].input + '\n'), + callback; if (!expected[0].lines) { - setTimeout(function() { - var callback = expected[0].callback; - expected.shift(); + callback = expected[0].callback; + expected.shift(); + } - callback && callback(); - }, 50); + if (callback) { + if (res !== true) { + child.stdin.on('drain', callback); + } else { + process.nextTick(callback); + } } } else { finish(); @@ -90,7 +95,7 @@ addTest('n', [ ]); // Watch -addTest('watch("\'x\'")'); +addTest('watch("\'x\'"), true', [/true/]); // Continue addTest('c', [ @@ -107,7 +112,7 @@ addTest('watchers', [ ]); // Unwatch -addTest('unwatch("\'x\'")'); +addTest('unwatch("\'x\'"), true', [ /true/ ]); // Step out addTest('o', [