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