Fold TreeRunner#runQueueWithSkipPolicy into caller

This commit is contained in:
Steve Gravrock
2025-08-25 18:43:54 -07:00
parent fd37a7eac0
commit db65c3b131
2 changed files with 26 additions and 36 deletions
+13 -18
View File
@@ -11471,7 +11471,7 @@ getJasmineRequireObj().TreeRunner = function(j$) {
); );
await new Promise(resolve => { await new Promise(resolve => {
this.#runQueueWithSkipPolicy({ this.#runQueue({
queueableFns, queueableFns,
userContext: this.#executionTree.topSuite.sharedUserContext(), userContext: this.#executionTree.topSuite.sharedUserContext(),
onException: function() { onException: function() {
@@ -11480,7 +11480,8 @@ getJasmineRequireObj().TreeRunner = function(j$) {
onComplete: resolve, onComplete: resolve,
onMultipleDone: topSuite.onMultipleDone onMultipleDone: topSuite.onMultipleDone
? topSuite.onMultipleDone.bind(topSuite) ? topSuite.onMultipleDone.bind(topSuite)
: null : null,
SkipPolicy: this.#suiteSkipPolicy()
}); });
}); });
@@ -11517,7 +11518,7 @@ getJasmineRequireObj().TreeRunner = function(j$) {
resultCallback resultCallback
); );
this.#runQueueWithSkipPolicy({ this.#runQueue({
isLeaf: true, isLeaf: true,
queueableFns, queueableFns,
onException: e => spec.handleException(e), onException: e => spec.handleException(e),
@@ -11542,7 +11543,8 @@ getJasmineRequireObj().TreeRunner = function(j$) {
} }
}, },
userContext: spec.userContext(), userContext: spec.userContext(),
runnableName: spec.getFullName.bind(spec) runnableName: spec.getFullName.bind(spec),
SkipPolicy: j$.CompleteOnFirstErrorSkipPolicy
}); });
} }
@@ -11607,7 +11609,7 @@ getJasmineRequireObj().TreeRunner = function(j$) {
...this.#addBeforeAndAfterAlls(suite, wrappedChildren) ...this.#addBeforeAndAfterAlls(suite, wrappedChildren)
]; ];
this.#runQueueWithSkipPolicy({ this.#runQueue({
// TODO: if onComplete always takes 0-1 arguments (and it probably does) // TODO: if onComplete always takes 0-1 arguments (and it probably does)
// then it can be switched to an arrow fn with a named arg. // then it can be switched to an arrow fn with a named arg.
onComplete: function() { onComplete: function() {
@@ -11623,7 +11625,8 @@ getJasmineRequireObj().TreeRunner = function(j$) {
}, },
onMultipleDone: suite.onMultipleDone onMultipleDone: suite.onMultipleDone
? suite.onMultipleDone.bind(suite) ? suite.onMultipleDone.bind(suite)
: null : null,
SkipPolicy: this.#suiteSkipPolicy()
}); });
} }
@@ -11689,20 +11692,12 @@ getJasmineRequireObj().TreeRunner = function(j$) {
.concat(suite.afterAllFns); .concat(suite.afterAllFns);
} }
#runQueueWithSkipPolicy(options) { #suiteSkipPolicy() {
if (options.isLeaf) { if (this.#getConfig().stopOnSpecFailure) {
// A spec return j$.CompleteOnFirstErrorSkipPolicy;
options.SkipPolicy = j$.CompleteOnFirstErrorSkipPolicy;
} else { } else {
// A suite return j$.SkipAfterBeforeAllErrorPolicy;
if (this.#getConfig().stopOnSpecFailure) {
options.SkipPolicy = j$.CompleteOnFirstErrorSkipPolicy;
} else {
options.SkipPolicy = j$.SkipAfterBeforeAllErrorPolicy;
}
} }
return this.#runQueue(options);
} }
} }
+13 -18
View File
@@ -36,7 +36,7 @@ getJasmineRequireObj().TreeRunner = function(j$) {
); );
await new Promise(resolve => { await new Promise(resolve => {
this.#runQueueWithSkipPolicy({ this.#runQueue({
queueableFns, queueableFns,
userContext: this.#executionTree.topSuite.sharedUserContext(), userContext: this.#executionTree.topSuite.sharedUserContext(),
onException: function() { onException: function() {
@@ -45,7 +45,8 @@ getJasmineRequireObj().TreeRunner = function(j$) {
onComplete: resolve, onComplete: resolve,
onMultipleDone: topSuite.onMultipleDone onMultipleDone: topSuite.onMultipleDone
? topSuite.onMultipleDone.bind(topSuite) ? topSuite.onMultipleDone.bind(topSuite)
: null : null,
SkipPolicy: this.#suiteSkipPolicy()
}); });
}); });
@@ -82,7 +83,7 @@ getJasmineRequireObj().TreeRunner = function(j$) {
resultCallback resultCallback
); );
this.#runQueueWithSkipPolicy({ this.#runQueue({
isLeaf: true, isLeaf: true,
queueableFns, queueableFns,
onException: e => spec.handleException(e), onException: e => spec.handleException(e),
@@ -107,7 +108,8 @@ getJasmineRequireObj().TreeRunner = function(j$) {
} }
}, },
userContext: spec.userContext(), userContext: spec.userContext(),
runnableName: spec.getFullName.bind(spec) runnableName: spec.getFullName.bind(spec),
SkipPolicy: j$.CompleteOnFirstErrorSkipPolicy
}); });
} }
@@ -172,7 +174,7 @@ getJasmineRequireObj().TreeRunner = function(j$) {
...this.#addBeforeAndAfterAlls(suite, wrappedChildren) ...this.#addBeforeAndAfterAlls(suite, wrappedChildren)
]; ];
this.#runQueueWithSkipPolicy({ this.#runQueue({
// TODO: if onComplete always takes 0-1 arguments (and it probably does) // TODO: if onComplete always takes 0-1 arguments (and it probably does)
// then it can be switched to an arrow fn with a named arg. // then it can be switched to an arrow fn with a named arg.
onComplete: function() { onComplete: function() {
@@ -188,7 +190,8 @@ getJasmineRequireObj().TreeRunner = function(j$) {
}, },
onMultipleDone: suite.onMultipleDone onMultipleDone: suite.onMultipleDone
? suite.onMultipleDone.bind(suite) ? suite.onMultipleDone.bind(suite)
: null : null,
SkipPolicy: this.#suiteSkipPolicy()
}); });
} }
@@ -254,20 +257,12 @@ getJasmineRequireObj().TreeRunner = function(j$) {
.concat(suite.afterAllFns); .concat(suite.afterAllFns);
} }
#runQueueWithSkipPolicy(options) { #suiteSkipPolicy() {
if (options.isLeaf) { if (this.#getConfig().stopOnSpecFailure) {
// A spec return j$.CompleteOnFirstErrorSkipPolicy;
options.SkipPolicy = j$.CompleteOnFirstErrorSkipPolicy;
} else { } else {
// A suite return j$.SkipAfterBeforeAllErrorPolicy;
if (this.#getConfig().stopOnSpecFailure) {
options.SkipPolicy = j$.CompleteOnFirstErrorSkipPolicy;
} else {
options.SkipPolicy = j$.SkipAfterBeforeAllErrorPolicy;
}
} }
return this.#runQueue(options);
} }
} }