Skip to content

Commit

Permalink
doctest improvements and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
matepek committed Aug 24, 2023
1 parent 65e57fd commit 92a6e6d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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]": {
Expand Down
14 changes: 11 additions & 3 deletions src/framework/AbstractExecutable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,13 @@ export abstract class AbstractExecutable<TestT extends AbstractTest = AbstractTe
breakOnFailure: boolean,
): string[];

/**
* Can be overridden, some cases make it necessary
*/
protected _splitTests(tests: readonly AbstractTest[]): (readonly AbstractTest[])[] {
return [tests];
}

getDebugParams(childrenToRun: readonly Readonly<AbstractTest>[], breakOnFailure: boolean): string[] {
return this.shared.prependTestRunningArgs.concat(this._getDebugParamsInner(childrenToRun, breakOnFailure));
}
Expand Down Expand Up @@ -580,10 +587,11 @@ export abstract class AbstractExecutable<TestT extends AbstractTest = AbstractTe
return;
}

const buckets = this._splitTestSetForMultirunIfEnabled(testsToRunFinal);
const actualTestBuckets = buckets.flatMap(b => 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());
}),
Expand Down
27 changes: 26 additions & 1 deletion src/framework/doctest/DOCExecutable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class DOCExecutable extends AbstractExecutable<DOCTest> {
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());
Expand Down Expand Up @@ -201,6 +201,31 @@ export class DOCExecutable extends AbstractExecutable<DOCTest> {
return execParams;
}

protected override _splitTests(tests: readonly AbstractTest[]): (readonly AbstractTest[])[] {
const withoutSuite: AbstractTest[] = [];
const suites = new Map<string, AbstractTest[]>();
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<HandleProcessResult> {
const unexpectedTests: DOCTest[] = [];
const expectedToRunAndFoundTests: DOCTest[] = [];
Expand Down

0 comments on commit 92a6e6d

Please sign in to comment.