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

View File

@@ -11471,7 +11471,7 @@ getJasmineRequireObj().TreeRunner = function(j$) {
);
await new Promise(resolve => {
this.#runQueueWithSkipPolicy({
this.#runQueue({
queueableFns,
userContext: this.#executionTree.topSuite.sharedUserContext(),
onException: function() {
@@ -11480,7 +11480,8 @@ getJasmineRequireObj().TreeRunner = function(j$) {
onComplete: resolve,
onMultipleDone: topSuite.onMultipleDone
? topSuite.onMultipleDone.bind(topSuite)
: null
: null,
SkipPolicy: this.#suiteSkipPolicy()
});
});
@@ -11517,7 +11518,7 @@ getJasmineRequireObj().TreeRunner = function(j$) {
resultCallback
);
this.#runQueueWithSkipPolicy({
this.#runQueue({
isLeaf: true,
queueableFns,
onException: e => spec.handleException(e),
@@ -11542,7 +11543,8 @@ getJasmineRequireObj().TreeRunner = function(j$) {
}
},
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.#runQueueWithSkipPolicy({
this.#runQueue({
// 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.
onComplete: function() {
@@ -11623,7 +11625,8 @@ getJasmineRequireObj().TreeRunner = function(j$) {
},
onMultipleDone: suite.onMultipleDone
? suite.onMultipleDone.bind(suite)
: null
: null,
SkipPolicy: this.#suiteSkipPolicy()
});
}
@@ -11689,20 +11692,12 @@ getJasmineRequireObj().TreeRunner = function(j$) {
.concat(suite.afterAllFns);
}
#runQueueWithSkipPolicy(options) {
if (options.isLeaf) {
// A spec
options.SkipPolicy = j$.CompleteOnFirstErrorSkipPolicy;
#suiteSkipPolicy() {
if (this.#getConfig().stopOnSpecFailure) {
return j$.CompleteOnFirstErrorSkipPolicy;
} else {
// A suite
if (this.#getConfig().stopOnSpecFailure) {
options.SkipPolicy = j$.CompleteOnFirstErrorSkipPolicy;
} else {
options.SkipPolicy = j$.SkipAfterBeforeAllErrorPolicy;
}
return j$.SkipAfterBeforeAllErrorPolicy;
}
return this.#runQueue(options);
}
}

View File

@@ -36,7 +36,7 @@ getJasmineRequireObj().TreeRunner = function(j$) {
);
await new Promise(resolve => {
this.#runQueueWithSkipPolicy({
this.#runQueue({
queueableFns,
userContext: this.#executionTree.topSuite.sharedUserContext(),
onException: function() {
@@ -45,7 +45,8 @@ getJasmineRequireObj().TreeRunner = function(j$) {
onComplete: resolve,
onMultipleDone: topSuite.onMultipleDone
? topSuite.onMultipleDone.bind(topSuite)
: null
: null,
SkipPolicy: this.#suiteSkipPolicy()
});
});
@@ -82,7 +83,7 @@ getJasmineRequireObj().TreeRunner = function(j$) {
resultCallback
);
this.#runQueueWithSkipPolicy({
this.#runQueue({
isLeaf: true,
queueableFns,
onException: e => spec.handleException(e),
@@ -107,7 +108,8 @@ getJasmineRequireObj().TreeRunner = function(j$) {
}
},
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.#runQueueWithSkipPolicy({
this.#runQueue({
// 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.
onComplete: function() {
@@ -188,7 +190,8 @@ getJasmineRequireObj().TreeRunner = function(j$) {
},
onMultipleDone: suite.onMultipleDone
? suite.onMultipleDone.bind(suite)
: null
: null,
SkipPolicy: this.#suiteSkipPolicy()
});
}
@@ -254,20 +257,12 @@ getJasmineRequireObj().TreeRunner = function(j$) {
.concat(suite.afterAllFns);
}
#runQueueWithSkipPolicy(options) {
if (options.isLeaf) {
// A spec
options.SkipPolicy = j$.CompleteOnFirstErrorSkipPolicy;
#suiteSkipPolicy() {
if (this.#getConfig().stopOnSpecFailure) {
return j$.CompleteOnFirstErrorSkipPolicy;
} else {
// A suite
if (this.#getConfig().stopOnSpecFailure) {
options.SkipPolicy = j$.CompleteOnFirstErrorSkipPolicy;
} else {
options.SkipPolicy = j$.SkipAfterBeforeAllErrorPolicy;
}
return j$.SkipAfterBeforeAllErrorPolicy;
}
return this.#runQueue(options);
}
}