Skip to content

Commit 560f694

Browse files
committed
Calculate databasesUnderTest with a loop
Currently QLTestAdapter.run() calculates the databases affected by a set of tests (those databases will be deleted and then reopened after test completion) using a nested filter-find expression. Which does not work because the predicate is an async function, so the expression is testing the truthiness of a Promise instead of the async result. This commit fixes the problem by implementing the same check with a loop so that we can invoke the async predicate using await.
1 parent 7a58d36 commit 560f694

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

extensions/ql-vscode/src/test-adapter.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,15 @@ export class QLTestAdapter extends DisposableObject implements TestAdapter {
190190
this._testStates.fire({ type: 'started', tests: tests } as TestRunStartedEvent);
191191

192192
const currentDatabaseUri = this.databaseManager.currentDatabaseItem?.databaseUri;
193-
const databasesUnderTest = this.databaseManager.databaseItems
194-
.filter(database => tests.find(testPath => database.isAffectedByTest(testPath)));
193+
const databasesUnderTest: DatabaseItem[] = [];
194+
for (const database of this.databaseManager.databaseItems) {
195+
for (const test of tests) {
196+
if (await database.isAffectedByTest(test)) {
197+
databasesUnderTest.push(database);
198+
break;
199+
}
200+
}
201+
}
195202

196203
await this.removeDatabasesBeforeTests(databasesUnderTest, token);
197204
try {

0 commit comments

Comments
 (0)