From 92a6e6db6425b7854fbb50f1e182fced16e0874f Mon Sep 17 00:00:00 2001 From: Mate Pek Date: Thu, 24 Aug 2023 19:06:53 +0200 Subject: [PATCH] doctest improvements and fixes --- .vscode/settings.json | 6 +++++- src/framework/AbstractExecutable.ts | 14 ++++++++++--- src/framework/doctest/DOCExecutable.ts | 27 +++++++++++++++++++++++++- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index b6774c8b..2a942773 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -98,7 +98,11 @@ "variant": "cpp", "vector": "cpp", "*.tcc": "cpp", - "memory_resource": "cpp" + "memory_resource": "cpp", + "__bits": "cpp", + "__verbose_abort": "cpp", + "compare": "cpp", + "concepts": "cpp" }, "editor.defaultFormatter": "esbenp.prettier-vscode", "[javascript]": { diff --git a/src/framework/AbstractExecutable.ts b/src/framework/AbstractExecutable.ts index c05ebd6a..ee7dcbdf 100644 --- a/src/framework/AbstractExecutable.ts +++ b/src/framework/AbstractExecutable.ts @@ -512,6 +512,13 @@ export abstract class AbstractExecutable[], breakOnFailure: boolean): string[] { return this.shared.prependTestRunningArgs.concat(this._getDebugParamsInner(childrenToRun, breakOnFailure)); } @@ -580,10 +587,11 @@ export abstract class AbstractExecutable this._splitTestsToSmallEnoughSubsets(b)); //TODO:future merge with _splitTestSetForMultirunIfEnabled + const splittedForFramework = this._splitTests(testsToRunFinal); + const splittedForMultirun = splittedForFramework.flatMap(v => this._splitTestSetForMultirunIfEnabled(v)); + const splittedFinal = splittedForMultirun.flatMap(b => this._splitTestsToSmallEnoughSubsets(b)); //TODO:future merge with _splitTestSetForMultirunIfEnabled - const runningBucketPromises = actualTestBuckets.map(b => + const runningBucketPromises = splittedFinal.map(b => this._runInner(testRun, b, taskPool, cancellationToken).catch(err => { vscode.window.showWarningMessage(err.toString()); }), diff --git a/src/framework/doctest/DOCExecutable.ts b/src/framework/doctest/DOCExecutable.ts index 3ea7fa2d..ea88cab7 100644 --- a/src/framework/doctest/DOCExecutable.ts +++ b/src/framework/doctest/DOCExecutable.ts @@ -165,7 +165,7 @@ export class DOCExecutable extends AbstractExecutable { params.push('--subcase-filter-levels=' + subTests.length); } else if (childrenToRun.every(v => v instanceof DOCTest)) { const dc = childrenToRun as readonly DOCTest[]; - if (dc.length > 0 && dc[0].suiteName && dc.every(v => v.suiteName === dc[0].suiteName)) { + if (dc.length && dc[0].suiteName && dc.every(v => v.suiteName === dc[0].suiteName)) { params.push('--test-suite=' + dc[0].suiteName); } const testNames = dc.map(c => c.getEscapedTestName()); @@ -201,6 +201,31 @@ export class DOCExecutable extends AbstractExecutable { return execParams; } + protected override _splitTests(tests: readonly AbstractTest[]): (readonly AbstractTest[])[] { + const withoutSuite: AbstractTest[] = []; + const suites = new Map(); + for (const test of tests) { + if (test instanceof DOCTest) { + if (test.suiteName) { + const f = suites.get(test.suiteName); + if (f) f.push(test); + else { + const s = [test]; + suites.set(test.suiteName, s); + } + } else { + withoutSuite.push(test); + } + } else { + this.shared.log.error('expected DOCTest but got something else'); + } + } + const result: AbstractTest[][] = []; + if (withoutSuite.length) result.push(withoutSuite); + result.push(...suites.values()); + return result; + } + protected async _handleProcess(testRun: vscode.TestRun, runInfo: RunningExecutable): Promise { const unexpectedTests: DOCTest[] = []; const expectedToRunAndFoundTests: DOCTest[] = [];