Remove support for excution orders that re-enter suites

This commit is contained in:
Steve Gravrock
2025-09-27 13:33:25 -07:00
parent 4598e4049c
commit c2ce55580c
7 changed files with 42 additions and 272 deletions

View File

@@ -3,8 +3,7 @@ getJasmineRequireObj().TreeProcessor = function(j$) {
const defaultMax = 1 - Infinity;
// Transforms the suite tree into an execution tree, which represents the set
// of specs and (possibly interleaved) suites to be run in the order they are
// to be run in.
// of specs and suites to be run in the order they are to be run in.
class TreeProcessor {
#tree;
#runnableIds;
@@ -86,15 +85,7 @@ getJasmineRequireObj().TreeProcessor = function(j$) {
segmentChildren(node, orderedChildren, this.#stats, executableIndex);
if (this.#stats[node.id].segments.length > 1) {
if (node.canBeReentered()) {
j$.getEnv().deprecated(
'The specified spec/suite order splits up a suite, running unrelated specs in the middle of it. This will become an error in a future release.'
);
} else {
throw new Error(
'Invalid order: would cause a beforeAll or afterAll to be run multiple times'
);
}
throw new Error('Invalid order: would split up a suite');
}
}
}
@@ -112,15 +103,14 @@ getJasmineRequireObj().TreeProcessor = function(j$) {
}
childrenOfTopSuite() {
return this.childrenOfSuiteSegment(this.topSuite, 0);
return this.childrenOfSuite(this.topSuite);
}
childrenOfSuiteSegment(suite, segmentNumber) {
const segmentChildren = this.#stats[suite.id].segments[segmentNumber]
.nodes;
childrenOfSuite(suite) {
const segmentChildren = this.#stats[suite.id].segments[0].nodes;
return segmentChildren.map(function(child) {
if (child.owner.children) {
return { suite: child.owner, segmentNumber: child.index };
return { suite: child.owner };
} else {
return { spec: child.owner };
}

View File

@@ -24,7 +24,7 @@ getJasmineRequireObj().TreeRunner = function(j$) {
async execute() {
this.#hasFailures = false;
await new Promise(resolve => {
this.#executeSuiteSegment(this.#executionTree.topSuite, 0, resolve);
this.#executeSuite(this.#executionTree.topSuite, resolve);
});
return { hasFailures: this.#hasFailures };
}
@@ -34,7 +34,7 @@ getJasmineRequireObj().TreeRunner = function(j$) {
return {
fn: done => {
if (node.suite) {
this.#executeSuiteSegment(node.suite, node.segmentNumber, done);
this.#executeSuite(node.suite, done);
} else {
this._executeSpec(node.spec, done);
}
@@ -124,7 +124,7 @@ getJasmineRequireObj().TreeRunner = function(j$) {
return fns;
}
#executeSuiteSegment(suite, segmentNumber, done) {
#executeSuite(suite, done) {
const isTopSuite = suite === this.#executionTree.topSuite;
const isExcluded = this.#executionTree.isExcluded(suite);
let befores = [];
@@ -146,7 +146,7 @@ getJasmineRequireObj().TreeRunner = function(j$) {
const children = isTopSuite
? this.#executionTree.childrenOfTopSuite()
: this.#executionTree.childrenOfSuiteSegment(suite, segmentNumber);
: this.#executionTree.childrenOfSuite(suite);
const queueableFns = [
...befores,
...this.#wrapNodes(children),