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

@@ -8,9 +8,7 @@ describe("TreeProcessor", function() {
this.canBeReentered = function() {
return !attrs.noReenter;
};
this.isExecutable = function() {
return attrs.executable !== false;
};
this.markedPending = attrs.markedPending || false;
this.sharedUserContext = function() {
return attrs.userContext || {};
};
@@ -23,13 +21,11 @@ describe("TreeProcessor", function() {
function Leaf(attrs) {
attrs = attrs || {};
this.id = 'leaf' + leafNumber++;
this.isExecutable = function() {
return attrs.executable !== false;
};
this.markedPending = attrs.markedPending || false;
this.execute = jasmine.createSpy(this.id + '#execute');
}
it("processes a single executable leaf", function() {
it("processes a single leaf", function() {
var leaf = new Leaf(),
processor = new jasmineUnderTest.TreeProcessor({ tree: leaf, runnableIds: [leaf.id] }),
result = processor.processTree();
@@ -37,20 +33,22 @@ describe("TreeProcessor", function() {
expect(result.valid).toBe(true);
expect(result[leaf.id]).toEqual({
executable: true,
excluded: false,
willExecute: true,
segments: jasmine.any(Array)
});
});
it("processes a single non-executable leaf", function() {
var leaf = new Leaf({ executable: false }),
it("processes a single pending leaf", function() {
var leaf = new Leaf({ markedPending: true }),
processor = new jasmineUnderTest.TreeProcessor({ tree: leaf, runnableIds: [leaf.id] }),
result = processor.processTree();
expect(result.valid).toBe(true);
expect(result[leaf.id]).toEqual({
executable: false,
excluded: false,
willExecute: false,
segments: jasmine.any(Array)
});
});
@@ -63,7 +61,26 @@ describe("TreeProcessor", function() {
expect(result.valid).toBe(true);
expect(result[leaf.id]).toEqual({
executable: false,
excluded: true,
willExecute: false,
segments: jasmine.any(Array)
});
});
it("processes a single excluded leaf", function() {
var leaf = new Leaf(),
processor = new jasmineUnderTest.TreeProcessor({
tree: leaf,
runnableIds: [leaf.id],
excludeNode: function(node) { return true; }
}),
result = processor.processTree();
expect(result.valid).toBe(true);
expect(result[leaf.id]).toEqual({
excluded: true,
willExecute: false,
segments: jasmine.any(Array)
});
});
@@ -77,18 +94,20 @@ describe("TreeProcessor", function() {
expect(result.valid).toBe(true);
expect(result[parent.id]).toEqual({
executable: true,
excluded: false,
willExecute: true,
segments: jasmine.any(Array)
});
expect(result[leaf.id]).toEqual({
executable: true,
excluded: false,
willExecute: true,
segments: jasmine.any(Array)
});
});
it("processes a tree with a single non-executable leaf, with the root specified", function() {
var leaf = new Leaf({ executable: false }),
it("processes a tree with a single pending leaf, with the root specified", function() {
var leaf = new Leaf({ markedPending: true }),
parent = new Node({ children: [leaf] }),
processor = new jasmineUnderTest.TreeProcessor({ tree: parent, runnableIds: [parent.id] }),
result = processor.processTree();
@@ -96,61 +115,77 @@ describe("TreeProcessor", function() {
expect(result.valid).toBe(true);
expect(result[parent.id]).toEqual({
executable: false,
excluded: false,
willExecute: false,
segments: jasmine.any(Array)
});
expect(result[leaf.id]).toEqual({
executable: false,
excluded: false,
willExecute: false,
segments: jasmine.any(Array)
});
});
it("processes a complicated tree with the root specified", function() {
var nonExecutable = new Leaf({ executable: false }),
executable = new Leaf({ executable: true }),
parent = new Node({ children: [nonExecutable, executable] }),
var pendingLeaf = new Leaf({ markedPending: true }),
executableLeaf = new Leaf({ markedPending: false }),
parent = new Node({ children: [pendingLeaf, executableLeaf] }),
childless = new Node(),
childOfDisabled = new Leaf({ executable: true }),
disabledNode = new Node({ executable: false, children: [childOfDisabled] }),
root = new Node({ children: [parent, childless, disabledNode] }),
childOfPending = new Leaf({ markedPending: true }),
pendingNode = new Node({ markedPending: true, children: [childOfPending] }),
parentOfPendings = new Node({ markedPending: false, children: [childless, pendingNode] }),
root = new Node({ children: [parent, parentOfPendings] }),
processor = new jasmineUnderTest.TreeProcessor({ tree: root, runnableIds: [root.id] }),
result = processor.processTree();
expect(result.valid).toBe(true);
expect(result[root.id]).toEqual({
executable: true,
excluded: false,
willExecute: true,
segments: jasmine.any(Array)
});
expect(result[parentOfPendings.id]).toEqual({
excluded: false,
willExecute: false,
segments: jasmine.any(Array)
});
expect(result[childless.id]).toEqual({
executable: false,
excluded: false,
willExecute: false,
segments: jasmine.any(Array)
});
expect(result[nonExecutable.id]).toEqual({
executable: false,
expect(result[pendingLeaf.id]).toEqual({
excluded: false,
willExecute: false,
segments: jasmine.any(Array)
});
expect(result[executable.id]).toEqual({
executable: true,
expect(result[executableLeaf.id]).toEqual({
excluded: false,
willExecute: true,
segments: jasmine.any(Array)
});
expect(result[parent.id]).toEqual({
executable: true,
excluded: false,
willExecute: true,
segments: jasmine.any(Array)
});
expect(result[disabledNode.id]).toEqual({
executable: false,
expect(result[pendingNode.id]).toEqual({
excluded: false,
willExecute: false,
segments: jasmine.any(Array)
});
expect(result[childOfDisabled.id]).toEqual({
executable: false,
expect(result[childOfPending.id]).toEqual({
excluded: false,
willExecute: false,
segments: jasmine.any(Array)
});
});
@@ -219,7 +254,7 @@ describe("TreeProcessor", function() {
queueRunner.calls.mostRecent().args[0].queueableFns[0].fn('foo');
expect(leaf.execute).toHaveBeenCalledWith('foo', true);
expect(leaf.execute).toHaveBeenCalledWith('foo', false);
});
it("runs a node with no children", function() {
@@ -286,22 +321,22 @@ describe("TreeProcessor", function() {
expect(queueableFns.length).toBe(2);
queueableFns[0].fn('foo');
expect(leaf1.execute).toHaveBeenCalledWith('foo', true);
expect(leaf1.execute).toHaveBeenCalledWith('foo', false);
queueableFns[1].fn('bar');
expect(leaf2.execute).toHaveBeenCalledWith('bar', true);
expect(leaf2.execute).toHaveBeenCalledWith('bar', false);
});
it("runs a disabled node", function() {
it("runs an excluded node with leaf", function() {
var leaf1 = new Leaf(),
node = new Node({ children: [leaf1], executable: false }),
node = new Node({ children: [leaf1] }),
root = new Node({ children: [node] }),
queueRunner = jasmine.createSpy('queueRunner'),
nodeStart = jasmine.createSpy('nodeStart'),
nodeComplete = jasmine.createSpy('nodeComplete'),
processor = new jasmineUnderTest.TreeProcessor({
tree: root,
runnableIds: [node.id],
runnableIds: [],
queueRunnerFactory: queueRunner,
nodeStart: nodeStart,
nodeComplete: nodeComplete
@@ -319,7 +354,7 @@ describe("TreeProcessor", function() {
expect(queueableFns.length).toBe(1);
queueableFns[0].fn('foo');
expect(leaf1.execute).toHaveBeenCalledWith('foo', false);
expect(leaf1.execute).toHaveBeenCalledWith('foo', true);
node.getResult.and.returnValue({ im: 'disabled' });
@@ -401,13 +436,13 @@ describe("TreeProcessor", function() {
expect(queueableFns).toEqual([]);
});
it("does not run beforeAlls or afterAlls for a disabled node", function() {
var leaf = new Leaf(),
it("does not run beforeAlls or afterAlls for a node with only pending children", function() {
var leaf = new Leaf({ markedPending: true }),
node = new Node({
children: [leaf],
beforeAllFns: ['before'],
afterAllFns: ['after'],
executable: false
markedPending: false
}),
root = new Node({ children: [node] }),
queueRunner = jasmine.createSpy('queueRunner'),
@@ -452,7 +487,7 @@ describe("TreeProcessor", function() {
expect(leaf1.execute).toHaveBeenCalled();
});
it("runs specified leaves before non-specified leaves", function() {
it("runs specified leaves before non-specified leaves within a parent node", function() {
var specified = new Leaf(),
nonSpecified = new Leaf(),
root = new Node({ children: [nonSpecified, specified] }),
@@ -469,11 +504,11 @@ describe("TreeProcessor", function() {
queueableFns[0].fn();
expect(nonSpecified.execute).not.toHaveBeenCalled();
expect(specified.execute).toHaveBeenCalledWith(undefined, true);
expect(specified.execute).toHaveBeenCalledWith(undefined, false);
queueableFns[1].fn();
expect(nonSpecified.execute).toHaveBeenCalledWith(undefined, false);
expect(nonSpecified.execute).toHaveBeenCalledWith(undefined, true);
});
it("runs nodes and leaves with a specified order", function() {
@@ -692,7 +727,7 @@ describe("TreeProcessor", function() {
expect(leaf11.execute).toHaveBeenCalled();
});
it("runs nodes in a custom order when orderChildren is overrided", function() {
it("runs nodes in a custom order when orderChildren is overridden", function() {
var leaf1 = new Leaf(),
leaf2 = new Leaf(),
leaf3 = new Leaf(),