Refactor QueueRunner and remove references to functions that Jasmine is done with
[finishes #56030214]
This commit is contained in:
@@ -603,6 +603,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
this.queueRunnerFactory(runnerConfig);
|
||||
|
||||
function complete(enabledAgain) {
|
||||
self.queueableFn.fn = null;
|
||||
self.result.status = self.status(enabledAgain);
|
||||
self.resultCallback(self.result);
|
||||
|
||||
@@ -4513,44 +4514,22 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
||||
}
|
||||
};
|
||||
|
||||
QueueRunner.prototype.run = function(recursiveIndex) {
|
||||
var length = this.queueableFns.length,
|
||||
self = this,
|
||||
iterativeIndex;
|
||||
QueueRunner.prototype.clearTimeout = function(timeoutId) {
|
||||
Function.prototype.apply.apply(this.timeout.clearTimeout, [j$.getGlobal(), [timeoutId]]);
|
||||
};
|
||||
|
||||
QueueRunner.prototype.setTimeout = function(fn, timeout) {
|
||||
return Function.prototype.apply.apply(this.timeout.setTimeout, [j$.getGlobal(), [fn, timeout]]);
|
||||
};
|
||||
|
||||
for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) {
|
||||
var result = attempt(iterativeIndex);
|
||||
|
||||
if (!result.completedSynchronously) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.completeOnFirstError && result.errored) {
|
||||
this.skipToCleanup(iterativeIndex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.clearStack(function() {
|
||||
self.globalErrors.popListener(self.handleFinalError);
|
||||
self.onComplete();
|
||||
});
|
||||
|
||||
function attempt() {
|
||||
var clearTimeout = function () {
|
||||
Function.prototype.apply.apply(self.timeout.clearTimeout, [j$.getGlobal(), [timeoutId]]);
|
||||
},
|
||||
setTimeout = function(delayedFn, delay) {
|
||||
return Function.prototype.apply.apply(self.timeout.setTimeout, [j$.getGlobal(), [delayedFn, delay]]);
|
||||
},
|
||||
completedSynchronously = true,
|
||||
QueueRunner.prototype.attempt = function attempt(iterativeIndex) {
|
||||
var self = this, completedSynchronously = true,
|
||||
handleError = function(error) {
|
||||
onException(error);
|
||||
next();
|
||||
},
|
||||
cleanup = once(function() {
|
||||
clearTimeout(timeoutId);
|
||||
self.clearTimeout(timeoutId);
|
||||
self.globalErrors.popListener(handleError);
|
||||
}),
|
||||
next = once(function () {
|
||||
@@ -4565,7 +4544,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
||||
}
|
||||
|
||||
if (completedSynchronously) {
|
||||
setTimeout(runNext);
|
||||
self.setTimeout(runNext);
|
||||
} else {
|
||||
runNext();
|
||||
}
|
||||
@@ -4583,7 +4562,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
||||
self.globalErrors.pushListener(handleError);
|
||||
|
||||
if (queueableFn.timeout) {
|
||||
timeoutId = setTimeout(function() {
|
||||
timeoutId = self.setTimeout(function() {
|
||||
var error = new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.');
|
||||
onException(error);
|
||||
next();
|
||||
@@ -4630,7 +4609,32 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
QueueRunner.prototype.run = function(recursiveIndex) {
|
||||
var length = this.queueableFns.length,
|
||||
self = this,
|
||||
iterativeIndex;
|
||||
|
||||
|
||||
for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) {
|
||||
var result = this.attempt(iterativeIndex);
|
||||
|
||||
if (!result.completedSynchronously) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.completeOnFirstError && result.errored) {
|
||||
this.skipToCleanup(iterativeIndex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.clearStack(function() {
|
||||
self.globalErrors.popListener(self.handleFinalError);
|
||||
self.onComplete();
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
return QueueRunner;
|
||||
@@ -5500,6 +5504,19 @@ getJasmineRequireObj().Suite = function(j$) {
|
||||
this.afterAllFns.unshift(fn);
|
||||
};
|
||||
|
||||
function removeFns(queueableFns) {
|
||||
for(var i = 0; i < queueableFns.length; i++) {
|
||||
queueableFns[i].fn = null;
|
||||
}
|
||||
}
|
||||
|
||||
Suite.prototype.cleanupBeforeAfter = function() {
|
||||
removeFns(this.beforeAllFns);
|
||||
removeFns(this.afterAllFns);
|
||||
removeFns(this.beforeFns);
|
||||
removeFns(this.afterFns);
|
||||
};
|
||||
|
||||
Suite.prototype.addChild = function(child) {
|
||||
this.children.push(child);
|
||||
};
|
||||
@@ -5796,6 +5813,7 @@ getJasmineRequireObj().TreeProcessor = function() {
|
||||
|
||||
queueRunnerFactory({
|
||||
onComplete: function() {
|
||||
node.cleanupBeforeAfter();
|
||||
nodeComplete(node, node.getResult());
|
||||
done();
|
||||
},
|
||||
|
||||
@@ -17,6 +17,7 @@ describe("TreeProcessor", function() {
|
||||
this.getResult = jasmine.createSpy(this.id + '#execute');
|
||||
this.beforeAllFns = attrs.beforeAllFns || [];
|
||||
this.afterAllFns = attrs.afterAllFns || [];
|
||||
this.cleanupBeforeAfter = function() { };
|
||||
}
|
||||
|
||||
function Leaf(attrs) {
|
||||
|
||||
@@ -43,44 +43,22 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
||||
}
|
||||
};
|
||||
|
||||
QueueRunner.prototype.run = function(recursiveIndex) {
|
||||
var length = this.queueableFns.length,
|
||||
self = this,
|
||||
iterativeIndex;
|
||||
QueueRunner.prototype.clearTimeout = function(timeoutId) {
|
||||
Function.prototype.apply.apply(this.timeout.clearTimeout, [j$.getGlobal(), [timeoutId]]);
|
||||
};
|
||||
|
||||
QueueRunner.prototype.setTimeout = function(fn, timeout) {
|
||||
return Function.prototype.apply.apply(this.timeout.setTimeout, [j$.getGlobal(), [fn, timeout]]);
|
||||
};
|
||||
|
||||
for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) {
|
||||
var result = attempt(iterativeIndex);
|
||||
|
||||
if (!result.completedSynchronously) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.completeOnFirstError && result.errored) {
|
||||
this.skipToCleanup(iterativeIndex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.clearStack(function() {
|
||||
self.globalErrors.popListener(self.handleFinalError);
|
||||
self.onComplete();
|
||||
});
|
||||
|
||||
function attempt() {
|
||||
var clearTimeout = function () {
|
||||
Function.prototype.apply.apply(self.timeout.clearTimeout, [j$.getGlobal(), [timeoutId]]);
|
||||
},
|
||||
setTimeout = function(delayedFn, delay) {
|
||||
return Function.prototype.apply.apply(self.timeout.setTimeout, [j$.getGlobal(), [delayedFn, delay]]);
|
||||
},
|
||||
completedSynchronously = true,
|
||||
QueueRunner.prototype.attempt = function attempt(iterativeIndex) {
|
||||
var self = this, completedSynchronously = true,
|
||||
handleError = function(error) {
|
||||
onException(error);
|
||||
next();
|
||||
},
|
||||
cleanup = once(function() {
|
||||
clearTimeout(timeoutId);
|
||||
self.clearTimeout(timeoutId);
|
||||
self.globalErrors.popListener(handleError);
|
||||
}),
|
||||
next = once(function () {
|
||||
@@ -95,7 +73,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
||||
}
|
||||
|
||||
if (completedSynchronously) {
|
||||
setTimeout(runNext);
|
||||
self.setTimeout(runNext);
|
||||
} else {
|
||||
runNext();
|
||||
}
|
||||
@@ -113,7 +91,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
||||
self.globalErrors.pushListener(handleError);
|
||||
|
||||
if (queueableFn.timeout) {
|
||||
timeoutId = setTimeout(function() {
|
||||
timeoutId = self.setTimeout(function() {
|
||||
var error = new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.');
|
||||
onException(error);
|
||||
next();
|
||||
@@ -160,7 +138,32 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
QueueRunner.prototype.run = function(recursiveIndex) {
|
||||
var length = this.queueableFns.length,
|
||||
self = this,
|
||||
iterativeIndex;
|
||||
|
||||
|
||||
for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) {
|
||||
var result = this.attempt(iterativeIndex);
|
||||
|
||||
if (!result.completedSynchronously) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.completeOnFirstError && result.errored) {
|
||||
this.skipToCleanup(iterativeIndex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.clearStack(function() {
|
||||
self.globalErrors.popListener(self.handleFinalError);
|
||||
self.onComplete();
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
return QueueRunner;
|
||||
|
||||
@@ -81,6 +81,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
this.queueRunnerFactory(runnerConfig);
|
||||
|
||||
function complete(enabledAgain) {
|
||||
self.queueableFn.fn = null;
|
||||
self.result.status = self.status(enabledAgain);
|
||||
self.resultCallback(self.result);
|
||||
|
||||
|
||||
@@ -65,6 +65,19 @@ getJasmineRequireObj().Suite = function(j$) {
|
||||
this.afterAllFns.unshift(fn);
|
||||
};
|
||||
|
||||
function removeFns(queueableFns) {
|
||||
for(var i = 0; i < queueableFns.length; i++) {
|
||||
queueableFns[i].fn = null;
|
||||
}
|
||||
}
|
||||
|
||||
Suite.prototype.cleanupBeforeAfter = function() {
|
||||
removeFns(this.beforeAllFns);
|
||||
removeFns(this.afterAllFns);
|
||||
removeFns(this.beforeFns);
|
||||
removeFns(this.afterFns);
|
||||
};
|
||||
|
||||
Suite.prototype.addChild = function(child) {
|
||||
this.children.push(child);
|
||||
};
|
||||
|
||||
@@ -168,6 +168,7 @@ getJasmineRequireObj().TreeProcessor = function() {
|
||||
|
||||
queueRunnerFactory({
|
||||
onComplete: function() {
|
||||
node.cleanupBeforeAfter();
|
||||
nodeComplete(node, node.getResult());
|
||||
done();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user