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

@@ -286,6 +286,7 @@ getJasmineRequireObj().Env = function(j$) {
};
this.execute = function(runnablesToRun) {
var self = this;
this.suppressLoadErrors();
if(!runnablesToRun) {
@@ -315,9 +316,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);
@@ -327,6 +326,9 @@ getJasmineRequireObj().Env = function(j$) {
},
orderChildren: function(node) {
return order.sort(node.children);
},
excludeNode: function(spec) {
return !self.specFilter(spec);
}
});
@@ -577,10 +579,6 @@ getJasmineRequireObj().Env = function(j$) {
throwOnExpectationFailure: throwOnExpectationFailure
});
if (!self.specFilter(spec)) {
spec.disable();
}
return spec;
function specResultCallback(result) {

View File

@@ -55,7 +55,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);
@@ -72,17 +72,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) {
@@ -110,10 +109,6 @@ getJasmineRequireObj().Spec = function(j$) {
}, true);
};
Spec.prototype.disable = function() {
this.disabled = true;
};
Spec.prototype.pend = function(message) {
this.markedPending = true;
if (message) {
@@ -126,9 +121,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) {
@@ -142,10 +137,6 @@ getJasmineRequireObj().Spec = function(j$) {
}
};
Spec.prototype.isExecutable = function() {
return !this.disabled;
};
Spec.prototype.getFullName = function() {
return this.getSpecName(this);
};

View File

@@ -90,14 +90,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;
};

View File

@@ -6,13 +6,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;
};
@@ -46,18 +47,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,
@@ -74,7 +75,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;
@@ -82,11 +83,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);
@@ -182,7 +184,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); }
};
}
}
@@ -195,7 +197,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;
}