testing: disentangle test item collection from exthost for use in tests

Fixes #141921
This commit is contained in:
Connor Peet
2022-03-30 14:57:46 -07:00
parent d441406b1e
commit 14a318068c
47 changed files with 558 additions and 386 deletions

View File

@@ -17,18 +17,18 @@ import { generateUuid } from 'vs/base/common/uuid';
import { ExtHostTestingShape, ILocationDto, MainContext, MainThreadTestingShape } from 'vs/workbench/api/common/extHost.protocol';
import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
import { InvalidTestItemError, TestItemImpl, TestItemRootImpl } from 'vs/workbench/api/common/extHostTestingPrivateApi';
import { ExtHostTestItemCollection, TestItemImpl, TestItemRootImpl } from 'vs/workbench/api/common/extHostTestingPrivateApi';
import * as Convert from 'vs/workbench/api/common/extHostTypeConverters';
import { TestRunProfileKind, TestRunRequest } from 'vs/workbench/api/common/extHostTypes';
import { SingleUseTestCollection } from 'vs/workbench/contrib/testing/common/ownedTestCollection';
import { AbstractIncrementalTestCollection, CoverageDetails, IFileCoverage, IncrementalChangeCollector, IncrementalTestCollectionItem, InternalTestItem, ISerializedTestResults, ITestItem, RunTestForControllerRequest, TestResultState, TestRunProfileBitset, TestsDiff, TestsDiffOp } from 'vs/workbench/contrib/testing/common/testCollection';
import { AbstractIncrementalTestCollection, CoverageDetails, IFileCoverage, IncrementalChangeCollector, IncrementalTestCollectionItem, InternalTestItem, ISerializedTestResults, ITestItem, RunTestForControllerRequest, TestResultState, TestRunProfileBitset, TestsDiff, TestsDiffOp } from 'vs/workbench/contrib/testing/common/testTypes';
import { TestId, TestIdPathParts, TestPosition } from 'vs/workbench/contrib/testing/common/testId';
import { InvalidTestItemError } from 'vs/workbench/contrib/testing/common/testItemCollection';
import type * as vscode from 'vscode';
interface ControllerInfo {
controller: vscode.TestController;
profiles: Map<number, vscode.TestRunProfile>;
collection: SingleUseTestCollection;
collection: ExtHostTestItemCollection;
}
export class ExtHostTesting implements ExtHostTestingShape {
@@ -61,7 +61,7 @@ export class ExtHostTesting implements ExtHostTestingShape {
}
const disposable = new DisposableStore();
const collection = disposable.add(new SingleUseTestCollection(controllerId));
const collection = disposable.add(new ExtHostTestItemCollection(controllerId, label));
collection.root.label = label;
const profiles = new Map<number, vscode.TestRunProfile>();
@@ -107,7 +107,7 @@ export class ExtHostTesting implements ExtHostTestingShape {
collection.resolveHandler = fn;
},
get resolveHandler() {
return collection.resolveHandler;
return collection.resolveHandler as undefined | ((item?: vscode.TestItem) => void);
},
dispose: () => {
disposable.dispose();
@@ -527,7 +527,7 @@ export class TestRunCoordinator {
/**
* Implements the public `createTestRun` API.
*/
public createTestRun(controllerId: string, collection: SingleUseTestCollection, request: vscode.TestRunRequest, name: string | undefined, persist: boolean): vscode.TestRun {
public createTestRun(controllerId: string, collection: ExtHostTestItemCollection, request: vscode.TestRunRequest, name: string | undefined, persist: boolean): vscode.TestRun {
const existing = this.tracked.get(request);
if (existing) {
return existing.createRun(name);
@@ -575,7 +575,7 @@ export class TestRunDto {
private readonly includePrefix: string[];
private readonly excludePrefix: string[];
public static fromPublic(controllerId: string, collection: SingleUseTestCollection, request: vscode.TestRunRequest, persist: boolean) {
public static fromPublic(controllerId: string, collection: ExtHostTestItemCollection, request: vscode.TestRunRequest, persist: boolean) {
return new TestRunDto(
controllerId,
generateUuid(),
@@ -586,7 +586,7 @@ export class TestRunDto {
);
}
public static fromInternal(request: RunTestForControllerRequest, collection: SingleUseTestCollection) {
public static fromInternal(request: RunTestForControllerRequest, collection: ExtHostTestItemCollection) {
return new TestRunDto(
request.controllerId,
request.runId,
@@ -603,7 +603,7 @@ export class TestRunDto {
include: string[],
exclude: string[],
public readonly isPersisted: boolean,
public readonly colllection: SingleUseTestCollection,
public readonly colllection: ExtHostTestItemCollection,
) {
this.includePrefix = include.map(id => id + TestIdPathParts.Delimiter);
this.excludePrefix = exclude.map(id => id + TestIdPathParts.Delimiter);
@@ -966,3 +966,4 @@ const profileGroupToBitset: { [K in TestRunProfileKind]: TestRunProfileBitset }
[TestRunProfileKind.Debug]: TestRunProfileBitset.Debug,
[TestRunProfileKind.Run]: TestRunProfileBitset.Run,
};