testing: add test configurations api

This commit is contained in:
Connor Peet
2021-06-28 18:58:46 -07:00
parent 4cf81a2a56
commit 9a09d4817d
31 changed files with 943 additions and 533 deletions

View File

@@ -5,14 +5,15 @@
import { VSBuffer } from 'vs/base/common/buffer';
import { CancellationToken } from 'vs/base/common/cancellation';
import { Disposable, IDisposable, MutableDisposable } from 'vs/base/common/lifecycle';
import { Disposable, DisposableStore, IDisposable, MutableDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { isDefined } from 'vs/base/common/types';
import { URI } from 'vs/base/common/uri';
import { Range } from 'vs/editor/common/core/range';
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
import { TestResultState } from 'vs/workbench/api/common/extHostTypes';
import { MutableObservableValue } from 'vs/workbench/contrib/testing/common/observableValue';
import { ExtensionRunTestsRequest, ITestItem, ITestMessage, ITestRunTask, RunTestsRequest, TestDiffOpType, TestsDiff } from 'vs/workbench/contrib/testing/common/testCollection';
import { ExtensionRunTestsRequest, ITestItem, ITestMessage, ITestRunConfiguration, ITestRunTask, ResolvedTestRunRequest, TestDiffOpType, TestsDiff } from 'vs/workbench/contrib/testing/common/testCollection';
import { ITestConfigurationService } from 'vs/workbench/contrib/testing/common/testConfigurationService';
import { TestCoverage } from 'vs/workbench/contrib/testing/common/testCoverage';
import { LiveTestResult } from 'vs/workbench/contrib/testing/common/testResult';
import { ITestResultService } from 'vs/workbench/contrib/testing/common/testResultService';
@@ -42,6 +43,7 @@ export class MainThreadTesting extends Disposable implements MainThreadTestingSh
constructor(
extHostContext: IExtHostContext,
@ITestService private readonly testService: ITestService,
@ITestConfigurationService private readonly testConfiguration: ITestConfigurationService,
@ITestResultService private readonly resultService: ITestResultService,
) {
super();
@@ -65,6 +67,27 @@ export class MainThreadTesting extends Disposable implements MainThreadTestingSh
}));
}
/**
* @inheritdoc
*/
$publishTestRunConfig(config: ITestRunConfiguration): void {
this.testConfiguration.addConfiguration(config);
}
/**
* @inheritdoc
*/
$updateTestRunConfig(controllerId: string, configId: number, update: Partial<ITestRunConfiguration>): void {
this.testConfiguration.updateConfiguration(controllerId, configId, update);
}
/**
* @inheritdoc
*/
$removeTestRunConfig(controllerId: string, configId: number): void {
this.testConfiguration.removeConfiguration(controllerId, configId);
}
/**
* @inheritdoc
*/
@@ -158,10 +181,13 @@ export class MainThreadTesting extends Disposable implements MainThreadTestingSh
* @inheritdoc
*/
public $registerTestController(controllerId: string) {
const disposable = this.testService.registerTestController(controllerId, {
const disposable = new DisposableStore();
disposable.add(toDisposable(() => this.testConfiguration.removeConfiguration(controllerId)));
disposable.add(this.testService.registerTestController(controllerId, {
runTests: (req, token) => this.proxy.$runControllerTests(req, token),
expandTest: (src, levels) => this.proxy.$expandTest(src, isFinite(levels) ? levels : -1),
});
}));
this.testProviderRegistrations.set(controllerId, disposable);
}
@@ -169,9 +195,9 @@ export class MainThreadTesting extends Disposable implements MainThreadTestingSh
/**
* @inheritdoc
*/
public $unregisterTestController(id: string) {
this.testProviderRegistrations.get(id)?.dispose();
this.testProviderRegistrations.delete(id);
public $unregisterTestController(controllerId: string) {
this.testProviderRegistrations.get(controllerId)?.dispose();
this.testProviderRegistrations.delete(controllerId);
}
/**
@@ -197,8 +223,8 @@ export class MainThreadTesting extends Disposable implements MainThreadTestingSh
this.testService.publishDiff(controllerId, diff);
}
public async $runTests(req: RunTestsRequest, token: CancellationToken): Promise<string> {
const result = await this.testService.runTests(req, token);
public async $runTests(req: ResolvedTestRunRequest, token: CancellationToken): Promise<string> {
const result = await this.testService.runResolvedTests(req, token);
return result.id;
}