Add 'ensured' blocks to the queue.
This blocks will be run even when a preceeding block sets the abort flag. This is so that we can support afterEach calls running when the spec fails due to a timeout.
This commit is contained in:
committed by
Davis W. Frank & Rajan Agaskar
parent
c5c57247f8
commit
bbc4c70c91
@@ -1,5 +1,9 @@
|
||||
jasmine.Queue = function(env) {
|
||||
this.env = env;
|
||||
|
||||
// parallel to blocks. each true value in this array means the block will
|
||||
// get executed even if we abort
|
||||
this.ensured = [];
|
||||
this.blocks = [];
|
||||
this.running = false;
|
||||
this.index = 0;
|
||||
@@ -7,15 +11,30 @@ jasmine.Queue = function(env) {
|
||||
this.abort = false;
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.addBefore = function(block) {
|
||||
jasmine.Queue.prototype.addBefore = function(block, ensure) {
|
||||
if (ensure === jasmine.undefined) {
|
||||
ensure = false;
|
||||
}
|
||||
|
||||
this.blocks.unshift(block);
|
||||
this.ensured.unshift(ensure);
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.add = function(block) {
|
||||
jasmine.Queue.prototype.add = function(block, ensure) {
|
||||
if (ensure === jasmine.undefined) {
|
||||
ensure = false;
|
||||
}
|
||||
|
||||
this.blocks.push(block);
|
||||
this.ensured.push(ensure);
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.insertNext = function(block) {
|
||||
jasmine.Queue.prototype.insertNext = function(block, ensure) {
|
||||
if (ensure === jasmine.undefined) {
|
||||
ensure = false;
|
||||
}
|
||||
|
||||
this.ensured.splice((this.index + this.offset + 1), 0, ensure);
|
||||
this.blocks.splice((this.index + this.offset + 1), 0, block);
|
||||
this.offset++;
|
||||
};
|
||||
@@ -39,7 +58,7 @@ jasmine.Queue.prototype.next_ = function() {
|
||||
while (goAgain) {
|
||||
goAgain = false;
|
||||
|
||||
if (self.index < self.blocks.length && !this.abort) {
|
||||
if (self.index < self.blocks.length && !(this.abort && !this.ensured[self.index])) {
|
||||
var calledSynchronously = true;
|
||||
var completedSynchronously = false;
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ jasmine.Spec.prototype.finish = function(onComplete) {
|
||||
|
||||
jasmine.Spec.prototype.after = function(doAfter) {
|
||||
if (this.queue.isRunning()) {
|
||||
this.queue.add(new jasmine.Block(this.env, doAfter, this));
|
||||
this.queue.add(new jasmine.Block(this.env, doAfter, this), true);
|
||||
} else {
|
||||
this.afterCallbacks.unshift(doAfter);
|
||||
}
|
||||
@@ -192,15 +192,15 @@ jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() {
|
||||
this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this));
|
||||
}
|
||||
for (i = 0; i < this.afterCallbacks.length; i++) {
|
||||
this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this));
|
||||
this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this), true);
|
||||
}
|
||||
for (suite = this.suite; suite; suite = suite.parentSuite) {
|
||||
for (i = 0; i < suite.after_.length; i++) {
|
||||
this.queue.add(new jasmine.Block(this.env, suite.after_[i], this));
|
||||
this.queue.add(new jasmine.Block(this.env, suite.after_[i], this), true);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < runner.after_.length; i++) {
|
||||
this.queue.add(new jasmine.Block(this.env, runner.after_[i], this));
|
||||
this.queue.add(new jasmine.Block(this.env, runner.after_[i], this), true);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user