Fixed timing-dependent unit-tests failures

DebuggerAgent.resume unit-test should pass `done` as the callback
function, otherwise other tests may run before this one is finished.

Fixed launcher so that it runs the test callback only once, instead of
everytime a `break` event is emitted.
This commit is contained in:
Miroslav Bajtoš 2014-01-23 13:53:54 +01:00
Родитель fe2cc2f895
Коммит 1acbd00471
2 изменённых файлов: 12 добавлений и 6 удалений

Просмотреть файл

@ -227,10 +227,8 @@ describe('DebuggerAgent', function() {
before(setupDebugScenario);
it('does not throw an error', function(done) {
expect(function () { agent.resume(); })
expect(function () { agent.resume({}, done); })
.to.not.throw();
done();
});
var debuggerClient, agent;
@ -238,7 +236,15 @@ describe('DebuggerAgent', function() {
function setupDebugScenario(done) {
launcher.runOnBreakInFunction(function(client) {
debuggerClient = client;
agent = new DebuggerAgent({}, null, debuggerClient, null, null);
var frontEndClientStub = {
sendEvent: function() {}
};
agent = new DebuggerAgent(
{},
frontEndClientStub,
debuggerClient,
null, // BreakEventHandler
null); // ScripManager
done();
});
}

Просмотреть файл

@ -44,7 +44,7 @@ function startDebugger(scriptPath, done) {
function runOnBreakInFunction(test) {
stopAllDebuggers();
startDebugger('BreakInFunction.js', function(childProcess, debuggerClient) {
debuggerClient.on('break', function() {
debuggerClient.once('break', function() {
test(debuggerClient);
});
childProcess.stdin.write('go!\n');
@ -55,7 +55,7 @@ function runOnBreakInFunction(test) {
function runInspectObject(test) {
stopAllDebuggers();
startDebugger('InspectObject.js', function(childProcess, debuggerClient) {
debuggerClient.on('break', function() {
debuggerClient.once('break', function() {
debuggerClient.fetchObjectId(
debuggerClient,
'inspectedObject',