Convreted TreeProcessor to async/await
This commit is contained in:
@@ -8518,58 +8518,53 @@ getJasmineRequireObj().Runner = function(j$) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.currentlyExecutingSuites_.push(this.topSuite_);
|
this.currentlyExecutingSuites_.push(this.topSuite_);
|
||||||
|
await processor.execute();
|
||||||
|
|
||||||
return new Promise(resolve => {
|
if (this.topSuite_.hadBeforeAllFailure) {
|
||||||
processor.execute(() => {
|
await this.reportChildrenOfBeforeAllFailure_(this.topSuite_);
|
||||||
(async () => {
|
}
|
||||||
if (this.topSuite_.hadBeforeAllFailure) {
|
|
||||||
await this.reportChildrenOfBeforeAllFailure_(this.topSuite_);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.runableResources_.clearForRunable(this.topSuite_.id);
|
this.runableResources_.clearForRunable(this.topSuite_.id);
|
||||||
this.currentlyExecutingSuites_.pop();
|
this.currentlyExecutingSuites_.pop();
|
||||||
let overallStatus, incompleteReason;
|
let overallStatus, incompleteReason;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.hasFailures ||
|
this.hasFailures ||
|
||||||
this.topSuite_.result.failedExpectations.length > 0
|
this.topSuite_.result.failedExpectations.length > 0
|
||||||
) {
|
) {
|
||||||
overallStatus = 'failed';
|
overallStatus = 'failed';
|
||||||
} else if (this.focusedRunables_().length > 0) {
|
} else if (this.focusedRunables_().length > 0) {
|
||||||
overallStatus = 'incomplete';
|
overallStatus = 'incomplete';
|
||||||
incompleteReason = 'fit() or fdescribe() was found';
|
incompleteReason = 'fit() or fdescribe() was found';
|
||||||
} else if (totalSpecsDefined === 0) {
|
} else if (totalSpecsDefined === 0) {
|
||||||
overallStatus = 'incomplete';
|
overallStatus = 'incomplete';
|
||||||
incompleteReason = 'No specs found';
|
incompleteReason = 'No specs found';
|
||||||
} else {
|
} else {
|
||||||
overallStatus = 'passed';
|
overallStatus = 'passed';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information passed to the {@link Reporter#jasmineDone} event.
|
* Information passed to the {@link Reporter#jasmineDone} event.
|
||||||
* @typedef JasmineDoneInfo
|
* @typedef JasmineDoneInfo
|
||||||
* @property {OverallStatus} overallStatus - The overall result of the suite: 'passed', 'failed', or 'incomplete'.
|
* @property {OverallStatus} overallStatus - The overall result of the suite: 'passed', 'failed', or 'incomplete'.
|
||||||
* @property {Int} totalTime - The total time (in ms) that it took to execute the suite
|
* @property {Int} totalTime - The total time (in ms) that it took to execute the suite
|
||||||
* @property {IncompleteReason} incompleteReason - Explanation of why the suite was incomplete.
|
* @property {IncompleteReason} incompleteReason - Explanation of why the suite was incomplete.
|
||||||
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
|
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
|
||||||
* @property {Expectation[]} failedExpectations - List of expectations that failed in an {@link afterAll} at the global level.
|
* @property {Expectation[]} failedExpectations - List of expectations that failed in an {@link afterAll} at the global level.
|
||||||
* @property {Expectation[]} deprecationWarnings - List of deprecation warnings that occurred at the global level.
|
* @property {Expectation[]} deprecationWarnings - List of deprecation warnings that occurred at the global level.
|
||||||
* @since 2.4.0
|
* @since 2.4.0
|
||||||
*/
|
*/
|
||||||
const jasmineDoneInfo = {
|
const jasmineDoneInfo = {
|
||||||
overallStatus: overallStatus,
|
overallStatus: overallStatus,
|
||||||
totalTime: jasmineTimer.elapsed(),
|
totalTime: jasmineTimer.elapsed(),
|
||||||
incompleteReason: incompleteReason,
|
incompleteReason: incompleteReason,
|
||||||
order: order,
|
order: order,
|
||||||
failedExpectations: this.topSuite_.result.failedExpectations,
|
failedExpectations: this.topSuite_.result.failedExpectations,
|
||||||
deprecationWarnings: this.topSuite_.result.deprecationWarnings
|
deprecationWarnings: this.topSuite_.result.deprecationWarnings
|
||||||
};
|
};
|
||||||
this.topSuite_.reportedDone = true;
|
this.topSuite_.reportedDone = true;
|
||||||
await this.reporter_.jasmineDone(jasmineDoneInfo);
|
await this.reporter_.jasmineDone(jasmineDoneInfo);
|
||||||
resolve(jasmineDoneInfo);
|
return jasmineDoneInfo;
|
||||||
})();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reportSuiteDone_(suite, result, next) {
|
reportSuiteDone_(suite, result, next) {
|
||||||
@@ -10190,7 +10185,7 @@ getJasmineRequireObj().TreeProcessor = function() {
|
|||||||
return stats;
|
return stats;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.execute = function(done) {
|
this.execute = async function() {
|
||||||
if (!processed) {
|
if (!processed) {
|
||||||
this.processTree();
|
this.processTree();
|
||||||
}
|
}
|
||||||
@@ -10201,16 +10196,18 @@ getJasmineRequireObj().TreeProcessor = function() {
|
|||||||
|
|
||||||
const childFns = wrapChildren(tree, 0);
|
const childFns = wrapChildren(tree, 0);
|
||||||
|
|
||||||
queueRunnerFactory({
|
await new Promise(function(resolve) {
|
||||||
queueableFns: childFns,
|
queueRunnerFactory({
|
||||||
userContext: tree.sharedUserContext(),
|
queueableFns: childFns,
|
||||||
onException: function() {
|
userContext: tree.sharedUserContext(),
|
||||||
tree.handleException.apply(tree, arguments);
|
onException: function() {
|
||||||
},
|
tree.handleException.apply(tree, arguments);
|
||||||
onComplete: done,
|
},
|
||||||
onMultipleDone: tree.onMultipleDone
|
onComplete: resolve,
|
||||||
? tree.onMultipleDone.bind(tree)
|
onMultipleDone: tree.onMultipleDone
|
||||||
: null
|
? tree.onMultipleDone.bind(tree)
|
||||||
|
: null
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ describe('TreeProcessor', function() {
|
|||||||
expect(result.valid).toBe(true);
|
expect(result.valid).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('runs a single leaf', function() {
|
it('runs a single leaf', async function() {
|
||||||
const leaf = new Leaf(),
|
const leaf = new Leaf(),
|
||||||
node = new Node({ children: [leaf], userContext: { root: 'context' } }),
|
node = new Node({ children: [leaf], userContext: { root: 'context' } }),
|
||||||
queueRunner = jasmine.createSpy('queueRunner'),
|
queueRunner = jasmine.createSpy('queueRunner'),
|
||||||
@@ -282,25 +282,27 @@ describe('TreeProcessor', function() {
|
|||||||
tree: node,
|
tree: node,
|
||||||
runnableIds: [leaf.id],
|
runnableIds: [leaf.id],
|
||||||
queueRunnerFactory: queueRunner
|
queueRunnerFactory: queueRunner
|
||||||
}),
|
});
|
||||||
treeComplete = jasmine.createSpy('treeComplete');
|
|
||||||
|
|
||||||
processor.execute(treeComplete);
|
const promise = processor.execute();
|
||||||
|
|
||||||
expect(queueRunner).toHaveBeenCalledWith({
|
expect(queueRunner).toHaveBeenCalledWith({
|
||||||
onComplete: treeComplete,
|
onComplete: jasmine.any(Function),
|
||||||
onException: jasmine.any(Function),
|
onException: jasmine.any(Function),
|
||||||
userContext: { root: 'context' },
|
userContext: { root: 'context' },
|
||||||
queueableFns: [{ fn: jasmine.any(Function) }],
|
queueableFns: [{ fn: jasmine.any(Function) }],
|
||||||
onMultipleDone: null
|
onMultipleDone: null
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.calls.mostRecent().args[0].queueableFns[0].fn('foo');
|
const queueRunnerArgs = queueRunner.calls.mostRecent().args[0];
|
||||||
|
queueRunnerArgs.queueableFns[0].fn('foo');
|
||||||
expect(leaf.execute).toHaveBeenCalledWith(queueRunner, 'foo', false, false);
|
expect(leaf.execute).toHaveBeenCalledWith(queueRunner, 'foo', false, false);
|
||||||
|
|
||||||
|
queueRunnerArgs.onComplete();
|
||||||
|
await expectAsync(promise).toBeResolvedTo(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('runs a node with no children', function() {
|
it('runs a node with no children', async function() {
|
||||||
const node = new Node({ userContext: { node: 'context' } }),
|
const node = new Node({ userContext: { node: 'context' } }),
|
||||||
root = new Node({ children: [node], userContext: { root: 'context' } }),
|
root = new Node({ children: [node], userContext: { root: 'context' } }),
|
||||||
nodeStart = jasmine.createSpy('nodeStart'),
|
nodeStart = jasmine.createSpy('nodeStart'),
|
||||||
@@ -313,21 +315,20 @@ describe('TreeProcessor', function() {
|
|||||||
nodeComplete: nodeComplete,
|
nodeComplete: nodeComplete,
|
||||||
queueRunnerFactory: queueRunner
|
queueRunnerFactory: queueRunner
|
||||||
}),
|
}),
|
||||||
treeComplete = jasmine.createSpy('treeComplete'),
|
|
||||||
nodeDone = jasmine.createSpy('nodeDone');
|
nodeDone = jasmine.createSpy('nodeDone');
|
||||||
|
|
||||||
processor.execute(treeComplete);
|
const promise = processor.execute();
|
||||||
|
|
||||||
expect(queueRunner).toHaveBeenCalledWith({
|
expect(queueRunner).toHaveBeenCalledWith({
|
||||||
onComplete: treeComplete,
|
onComplete: jasmine.any(Function),
|
||||||
onException: jasmine.any(Function),
|
onException: jasmine.any(Function),
|
||||||
userContext: { root: 'context' },
|
userContext: { root: 'context' },
|
||||||
queueableFns: [{ fn: jasmine.any(Function) }],
|
queueableFns: [{ fn: jasmine.any(Function) }],
|
||||||
onMultipleDone: null
|
onMultipleDone: null
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.calls.mostRecent().args[0].queueableFns[0].fn(nodeDone);
|
const queueRunnerArgs = queueRunner.calls.mostRecent().args[0];
|
||||||
|
queueRunnerArgs.queueableFns[0].fn(nodeDone);
|
||||||
expect(queueRunner).toHaveBeenCalledWith({
|
expect(queueRunner).toHaveBeenCalledWith({
|
||||||
onComplete: jasmine.any(Function),
|
onComplete: jasmine.any(Function),
|
||||||
onMultipleDone: null,
|
onMultipleDone: null,
|
||||||
@@ -348,6 +349,9 @@ describe('TreeProcessor', function() {
|
|||||||
{ my: 'result' },
|
{ my: 'result' },
|
||||||
jasmine.any(Function)
|
jasmine.any(Function)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
queueRunnerArgs.onComplete();
|
||||||
|
await expectAsync(promise).toBeResolvedTo(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('runs a node with children', function() {
|
it('runs a node with children', function() {
|
||||||
|
|||||||
@@ -136,58 +136,53 @@ getJasmineRequireObj().Runner = function(j$) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.currentlyExecutingSuites_.push(this.topSuite_);
|
this.currentlyExecutingSuites_.push(this.topSuite_);
|
||||||
|
await processor.execute();
|
||||||
|
|
||||||
return new Promise(resolve => {
|
if (this.topSuite_.hadBeforeAllFailure) {
|
||||||
processor.execute(() => {
|
await this.reportChildrenOfBeforeAllFailure_(this.topSuite_);
|
||||||
(async () => {
|
}
|
||||||
if (this.topSuite_.hadBeforeAllFailure) {
|
|
||||||
await this.reportChildrenOfBeforeAllFailure_(this.topSuite_);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.runableResources_.clearForRunable(this.topSuite_.id);
|
this.runableResources_.clearForRunable(this.topSuite_.id);
|
||||||
this.currentlyExecutingSuites_.pop();
|
this.currentlyExecutingSuites_.pop();
|
||||||
let overallStatus, incompleteReason;
|
let overallStatus, incompleteReason;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.hasFailures ||
|
this.hasFailures ||
|
||||||
this.topSuite_.result.failedExpectations.length > 0
|
this.topSuite_.result.failedExpectations.length > 0
|
||||||
) {
|
) {
|
||||||
overallStatus = 'failed';
|
overallStatus = 'failed';
|
||||||
} else if (this.focusedRunables_().length > 0) {
|
} else if (this.focusedRunables_().length > 0) {
|
||||||
overallStatus = 'incomplete';
|
overallStatus = 'incomplete';
|
||||||
incompleteReason = 'fit() or fdescribe() was found';
|
incompleteReason = 'fit() or fdescribe() was found';
|
||||||
} else if (totalSpecsDefined === 0) {
|
} else if (totalSpecsDefined === 0) {
|
||||||
overallStatus = 'incomplete';
|
overallStatus = 'incomplete';
|
||||||
incompleteReason = 'No specs found';
|
incompleteReason = 'No specs found';
|
||||||
} else {
|
} else {
|
||||||
overallStatus = 'passed';
|
overallStatus = 'passed';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information passed to the {@link Reporter#jasmineDone} event.
|
* Information passed to the {@link Reporter#jasmineDone} event.
|
||||||
* @typedef JasmineDoneInfo
|
* @typedef JasmineDoneInfo
|
||||||
* @property {OverallStatus} overallStatus - The overall result of the suite: 'passed', 'failed', or 'incomplete'.
|
* @property {OverallStatus} overallStatus - The overall result of the suite: 'passed', 'failed', or 'incomplete'.
|
||||||
* @property {Int} totalTime - The total time (in ms) that it took to execute the suite
|
* @property {Int} totalTime - The total time (in ms) that it took to execute the suite
|
||||||
* @property {IncompleteReason} incompleteReason - Explanation of why the suite was incomplete.
|
* @property {IncompleteReason} incompleteReason - Explanation of why the suite was incomplete.
|
||||||
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
|
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite.
|
||||||
* @property {Expectation[]} failedExpectations - List of expectations that failed in an {@link afterAll} at the global level.
|
* @property {Expectation[]} failedExpectations - List of expectations that failed in an {@link afterAll} at the global level.
|
||||||
* @property {Expectation[]} deprecationWarnings - List of deprecation warnings that occurred at the global level.
|
* @property {Expectation[]} deprecationWarnings - List of deprecation warnings that occurred at the global level.
|
||||||
* @since 2.4.0
|
* @since 2.4.0
|
||||||
*/
|
*/
|
||||||
const jasmineDoneInfo = {
|
const jasmineDoneInfo = {
|
||||||
overallStatus: overallStatus,
|
overallStatus: overallStatus,
|
||||||
totalTime: jasmineTimer.elapsed(),
|
totalTime: jasmineTimer.elapsed(),
|
||||||
incompleteReason: incompleteReason,
|
incompleteReason: incompleteReason,
|
||||||
order: order,
|
order: order,
|
||||||
failedExpectations: this.topSuite_.result.failedExpectations,
|
failedExpectations: this.topSuite_.result.failedExpectations,
|
||||||
deprecationWarnings: this.topSuite_.result.deprecationWarnings
|
deprecationWarnings: this.topSuite_.result.deprecationWarnings
|
||||||
};
|
};
|
||||||
this.topSuite_.reportedDone = true;
|
this.topSuite_.reportedDone = true;
|
||||||
await this.reporter_.jasmineDone(jasmineDoneInfo);
|
await this.reporter_.jasmineDone(jasmineDoneInfo);
|
||||||
resolve(jasmineDoneInfo);
|
return jasmineDoneInfo;
|
||||||
})();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reportSuiteDone_(suite, result, next) {
|
reportSuiteDone_(suite, result, next) {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ getJasmineRequireObj().TreeProcessor = function() {
|
|||||||
return stats;
|
return stats;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.execute = function(done) {
|
this.execute = async function() {
|
||||||
if (!processed) {
|
if (!processed) {
|
||||||
this.processTree();
|
this.processTree();
|
||||||
}
|
}
|
||||||
@@ -38,16 +38,18 @@ getJasmineRequireObj().TreeProcessor = function() {
|
|||||||
|
|
||||||
const childFns = wrapChildren(tree, 0);
|
const childFns = wrapChildren(tree, 0);
|
||||||
|
|
||||||
queueRunnerFactory({
|
await new Promise(function(resolve) {
|
||||||
queueableFns: childFns,
|
queueRunnerFactory({
|
||||||
userContext: tree.sharedUserContext(),
|
queueableFns: childFns,
|
||||||
onException: function() {
|
userContext: tree.sharedUserContext(),
|
||||||
tree.handleException.apply(tree, arguments);
|
onException: function() {
|
||||||
},
|
tree.handleException.apply(tree, arguments);
|
||||||
onComplete: done,
|
},
|
||||||
onMultipleDone: tree.onMultipleDone
|
onComplete: resolve,
|
||||||
? tree.onMultipleDone.bind(tree)
|
onMultipleDone: tree.onMultipleDone
|
||||||
: null
|
? tree.onMultipleDone.bind(tree)
|
||||||
|
: null
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user