Unify status for xdescribe and xit

- Ensure *All's only execute if at least one child will run
- Specs will report a status of `excluded` instead of disabled

[finishes #153967580]
- #1418

Signed-off-by: Elenore Bastian <ebastian@pivotal.io>
This commit is contained in:
Gregg Van Hove
2018-01-25 16:17:31 -08:00
committed by Elenore Bastian
parent 07996b567f
commit 6b156ca6d1
10 changed files with 204 additions and 239 deletions

View File

@@ -525,7 +525,7 @@ getJasmineRequireObj().Spec = function(j$) {
return this.expectationFactory(actual, this);
};
Spec.prototype.execute = function(onComplete, enabled) {
Spec.prototype.execute = function(onComplete, excluded) {
var self = this;
this.onStart(this);
@@ -542,17 +542,16 @@ getJasmineRequireObj().Spec = function(j$) {
userContext: this.userContext()
};
if (!this.isExecutable() || this.markedPending || enabled === false) {
if (this.markedPending || excluded === true) {
runnerConfig.queueableFns = [];
runnerConfig.cleanupFns = [];
runnerConfig.onComplete = function() { complete(enabled); };
}
this.queueRunnerFactory(runnerConfig);
function complete(enabledAgain) {
function complete() {
self.queueableFn.fn = null;
self.result.status = self.status(enabledAgain);
self.result.status = self.status(excluded);
self.resultCallback(self.result);
if (onComplete) {
@@ -580,10 +579,6 @@ getJasmineRequireObj().Spec = function(j$) {
}, true);
};
Spec.prototype.disable = function() {
this.disabled = true;
};
Spec.prototype.pend = function(message) {
this.markedPending = true;
if (message) {
@@ -596,9 +591,9 @@ getJasmineRequireObj().Spec = function(j$) {
return this.result;
};
Spec.prototype.status = function(enabled) {
if (this.disabled || enabled === false) {
return 'disabled';
Spec.prototype.status = function(excluded) {
if (excluded === true) {
return 'excluded';
}
if (this.markedPending) {
@@ -612,10 +607,6 @@ getJasmineRequireObj().Spec = function(j$) {
}
};
Spec.prototype.isExecutable = function() {
return !this.disabled;
};
Spec.prototype.getFullName = function() {
return this.getSpecName(this);
};
@@ -976,6 +967,7 @@ getJasmineRequireObj().Env = function(j$) {
};
this.execute = function(runnablesToRun) {
var self = this;
this.suppressLoadErrors();
if(!runnablesToRun) {
@@ -1005,9 +997,7 @@ getJasmineRequireObj().Env = function(j$) {
throw new Error('Tried to complete the wrong suite');
}
if (!suite.markedPending) {
clearResourcesForRunnable(suite.id);
}
clearResourcesForRunnable(suite.id);
currentlyExecutingSuites.pop();
reporter.suiteDone(result);
@@ -1017,6 +1007,9 @@ getJasmineRequireObj().Env = function(j$) {
},
orderChildren: function(node) {
return order.sort(node.children);
},
excludeNode: function(spec) {
return !self.specFilter(spec);
}
});
@@ -1267,10 +1260,6 @@ getJasmineRequireObj().Env = function(j$) {
throwOnExpectationFailure: throwOnExpectationFailure
});
if (!self.specFilter(spec)) {
spec.disable();
}
return spec;
function specResultCallback(result) {
@@ -5610,14 +5599,10 @@ getJasmineRequireObj().Suite = function(j$) {
if (this.result.failedExpectations.length > 0) {
return 'failed';
} else {
return 'finished';
return 'passed';
}
};
Suite.prototype.isExecutable = function() {
return !this.markedPending;
};
Suite.prototype.canBeReentered = function() {
return this.beforeAllFns.length === 0 && this.afterAllFns.length === 0;
};
@@ -5712,13 +5697,14 @@ getJasmineRequireObj().TreeProcessor = function() {
nodeStart = attrs.nodeStart || function() {},
nodeComplete = attrs.nodeComplete || function() {},
orderChildren = attrs.orderChildren || function(node) { return node.children; },
excludeNode = attrs.excludeNode || function(node) { return false; },
stats = { valid: true },
processed = false,
defaultMin = Infinity,
defaultMax = 1 - Infinity;
this.processTree = function() {
processNode(tree, false);
processNode(tree, true);
processed = true;
return stats;
};
@@ -5752,18 +5738,18 @@ getJasmineRequireObj().TreeProcessor = function() {
}
}
function processNode(node, parentEnabled) {
function processNode(node, parentExcluded) {
var executableIndex = runnableIndex(node.id);
if (executableIndex !== undefined) {
parentEnabled = true;
parentExcluded = false;
}
parentEnabled = parentEnabled && node.isExecutable();
if (!node.children) {
var excluded = parentExcluded || excludeNode(node);
stats[node.id] = {
executable: parentEnabled && node.isExecutable(),
excluded: excluded,
willExecute: !excluded && !node.markedPending,
segments: [{
index: 0,
owner: node,
@@ -5780,7 +5766,7 @@ getJasmineRequireObj().TreeProcessor = function() {
for (var i = 0; i < orderedChildren.length; i++) {
var child = orderedChildren[i];
processNode(child, parentEnabled);
processNode(child, parentExcluded);
if (!stats.valid) {
return;
@@ -5788,11 +5774,12 @@ getJasmineRequireObj().TreeProcessor = function() {
var childStats = stats[child.id];
hasExecutableChild = hasExecutableChild || childStats.executable;
hasExecutableChild = hasExecutableChild || childStats.willExecute;
}
stats[node.id] = {
executable: hasExecutableChild
excluded: parentExcluded,
willExecute: hasExecutableChild
};
segmentChildren(node, orderedChildren, stats[node.id], executableIndex);
@@ -5888,7 +5875,7 @@ getJasmineRequireObj().TreeProcessor = function() {
};
} else {
return {
fn: function(done) { node.execute(done, stats[node.id].executable); }
fn: function(done) { node.execute(done, stats[node.id].excluded); }
};
}
}
@@ -5901,7 +5888,7 @@ getJasmineRequireObj().TreeProcessor = function() {
result.push(executeNode(segmentChildren[i].owner, segmentChildren[i].index));
}
if (!stats[node.id].executable) {
if (!stats[node.id].willExecute) {
return result;
}