Fix ordering for suites with more than 11 direct children.
- When no specs were focused, they all had the same precedence, and `sort`ing them caused some of the nodes to move around Fixes #850
This commit is contained in:
+11
-12
@@ -2311,30 +2311,29 @@ getJasmineRequireObj().TreeProcessor = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function orderChildSegments(children) {
|
function orderChildSegments(children) {
|
||||||
var result = [];
|
var specifiedOrder = [],
|
||||||
|
unspecifiedOrder = [];
|
||||||
|
|
||||||
for (var i = 0; i < children.length; i++) {
|
for (var i = 0; i < children.length; i++) {
|
||||||
var child = children[i],
|
var child = children[i],
|
||||||
segments = stats[child.id].segments;
|
segments = stats[child.id].segments;
|
||||||
|
|
||||||
for (var j = 0; j < segments.length; j++) {
|
for (var j = 0; j < segments.length; j++) {
|
||||||
result.push(segments[j]);
|
var seg = segments[j];
|
||||||
|
|
||||||
|
if (seg.min === defaultMin) {
|
||||||
|
unspecifiedOrder.push(seg);
|
||||||
|
} else {
|
||||||
|
specifiedOrder.push(seg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result.sort(function(a, b) {
|
specifiedOrder.sort(function(a, b) {
|
||||||
if (a.min === null) {
|
|
||||||
return b.min === null ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (b.min === null) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return a.min - b.min;
|
return a.min - b.min;
|
||||||
});
|
});
|
||||||
|
|
||||||
return result;
|
return specifiedOrder.concat(unspecifiedOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
function executeNode(node, segmentNumber) {
|
function executeNode(node, segmentNumber) {
|
||||||
|
|||||||
@@ -632,4 +632,62 @@ describe("TreeProcessor", function() {
|
|||||||
childFns[1].fn();
|
childFns[1].fn();
|
||||||
expect(leaf3.execute).toHaveBeenCalled();
|
expect(leaf3.execute).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("runs large segments of nodes in the order they were declared", function() {
|
||||||
|
var leaf1 = new Leaf(),
|
||||||
|
leaf2 = new Leaf(),
|
||||||
|
leaf3 = new Leaf(),
|
||||||
|
leaf4 = new Leaf(),
|
||||||
|
leaf5 = new Leaf(),
|
||||||
|
leaf6 = new Leaf(),
|
||||||
|
leaf7 = new Leaf(),
|
||||||
|
leaf8 = new Leaf(),
|
||||||
|
leaf9 = new Leaf(),
|
||||||
|
leaf10 = new Leaf(),
|
||||||
|
leaf11 = new Leaf(),
|
||||||
|
root = new Node({ children: [leaf1, leaf2, leaf3, leaf4, leaf5, leaf6, leaf7, leaf8, leaf9, leaf10, leaf11] }),
|
||||||
|
queueRunner = jasmine.createSpy('queueRunner'),
|
||||||
|
processor = new j$.TreeProcessor({
|
||||||
|
tree: root,
|
||||||
|
runnableIds: [root.id],
|
||||||
|
queueRunnerFactory: queueRunner
|
||||||
|
});
|
||||||
|
|
||||||
|
processor.execute();
|
||||||
|
var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||||
|
expect(queueableFns.length).toBe(11);
|
||||||
|
|
||||||
|
queueableFns[0].fn();
|
||||||
|
expect(leaf1.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[1].fn();
|
||||||
|
expect(leaf2.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[2].fn();
|
||||||
|
expect(leaf3.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[3].fn();
|
||||||
|
expect(leaf4.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[4].fn();
|
||||||
|
expect(leaf5.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[5].fn();
|
||||||
|
expect(leaf6.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[6].fn();
|
||||||
|
expect(leaf7.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[7].fn();
|
||||||
|
expect(leaf8.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[8].fn();
|
||||||
|
expect(leaf9.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[9].fn();
|
||||||
|
expect(leaf10.execute).toHaveBeenCalled();
|
||||||
|
|
||||||
|
queueableFns[10].fn();
|
||||||
|
expect(leaf11.execute).toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
+11
-12
@@ -132,30 +132,29 @@ getJasmineRequireObj().TreeProcessor = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function orderChildSegments(children) {
|
function orderChildSegments(children) {
|
||||||
var result = [];
|
var specifiedOrder = [],
|
||||||
|
unspecifiedOrder = [];
|
||||||
|
|
||||||
for (var i = 0; i < children.length; i++) {
|
for (var i = 0; i < children.length; i++) {
|
||||||
var child = children[i],
|
var child = children[i],
|
||||||
segments = stats[child.id].segments;
|
segments = stats[child.id].segments;
|
||||||
|
|
||||||
for (var j = 0; j < segments.length; j++) {
|
for (var j = 0; j < segments.length; j++) {
|
||||||
result.push(segments[j]);
|
var seg = segments[j];
|
||||||
|
|
||||||
|
if (seg.min === defaultMin) {
|
||||||
|
unspecifiedOrder.push(seg);
|
||||||
|
} else {
|
||||||
|
specifiedOrder.push(seg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result.sort(function(a, b) {
|
specifiedOrder.sort(function(a, b) {
|
||||||
if (a.min === null) {
|
|
||||||
return b.min === null ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (b.min === null) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return a.min - b.min;
|
return a.min - b.min;
|
||||||
});
|
});
|
||||||
|
|
||||||
return result;
|
return specifiedOrder.concat(unspecifiedOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
function executeNode(node, segmentNumber) {
|
function executeNode(node, segmentNumber) {
|
||||||
|
|||||||
Reference in New Issue
Block a user