Skip to content

Commit

Permalink
tests api implementation setup of test-item, type-converters and test…
Browse files Browse the repository at this point in the history
…ing workspace. Lint not fixed

Signed-off-by: Kevin Clapperton  <keclapperton@gmail.com>
  • Loading branch information
Zakaria authored and KevinClapperton committed Mar 6, 2023
1 parent a5e1162 commit f4cba51
Show file tree
Hide file tree
Showing 28 changed files with 5,988 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/plugin-ext/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@theia/search-in-workspace": "1.35.0",
"@theia/task": "1.35.0",
"@theia/terminal": "1.35.0",
"@theia/testing": "1.35.0",
"@theia/timeline": "1.35.0",
"@theia/typehierarchy": "1.35.0",
"@theia/variable-resolver": "1.35.0",
Expand Down
105 changes: 103 additions & 2 deletions packages/plugin-ext/src/common/plugin-api-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,21 @@ import { isString, isObject, PickOptions, QuickInputButtonHandle } from '@theia/
import { Severity } from '@theia/core/lib/common/severity';
import { DebugConfiguration, DebugSessionOptions } from '@theia/debug/lib/common/debug-configuration';

import {
CoverageDetails,
IFileCoverage,
ISerializedTestResults,
RunTestForControllerRequest,
TestsDiffOp,
ITestRunProfile,
ResolvedTestRunRequest,
ITestItem,
TestResultState,
ITestMessage,
ITestRunTask,
ExtensionRunTestsRequest,
} from '@theia/testing/lib/common/test-types';

export interface PreferenceData {
[scope: number]: any;
}
Expand Down Expand Up @@ -2072,6 +2087,90 @@ export interface TabsMain {

// endregion

export const enum TestingResourceExt {
Workspace,
TextDocument
}

export interface TestingExt {
$runControllerTests(req: RunTestForControllerRequest[], token: CancellationToken): Promise<{ error?: string }[]>;
$cancelExtensionTestRun(runId: string | undefined): void;
/** Handles a diff of tests, as a result of a subscribeToDiffs() call */
$acceptDiff(diff: TestsDiffOp.Serialized[]): void;
/** Publishes that a test run finished. */
$publishTestResults(results: ISerializedTestResults[]): void;
/** Expands a test item's children, by the given number of levels. */
$expandTest(testId: string, levels: number): Promise<void>;
/** Requests file coverage for a test run. Errors if not available. */
$provideFileCoverage(runId: string, taskId: string, token: CancellationToken): Promise<IFileCoverage[]>;
/**
* Requests coverage details for the file index in coverage data for the run.
* Requires file coverage to have been previously requested via $provideFileCoverage.
*/
$resolveFileCoverage(runId: string, taskId: string, fileIndex: number, token: CancellationToken): Promise<CoverageDetails[]>;
/** Configures a test run config. */
$configureRunProfile(controllerId: string, configId: number): void;
/** Asks the controller to refresh its tests */
$refreshTests(controllerId: string, token: CancellationToken): Promise<void>;
}

export interface ITestControllerPatch {
label?: string;
canRefresh?: boolean;
}

export interface TestingMain {
// --- test lifecycle:

/** Registers that there's a test controller with the given ID */
$registerTestController(controllerId: string, label: string, canRefresh: boolean): void;
/** Updates the label of an existing test controller. */
$updateController(controllerId: string, patch: ITestControllerPatch): void;
/** Diposes of the test controller with the given ID */
$unregisterTestController(controllerId: string): void;
/** Requests tests published to VS Code. */
$subscribeToDiffs(): void;
/** Stops requesting tests published to VS Code. */
$unsubscribeFromDiffs(): void;
/** Publishes that new tests were available on the given source. */
$publishDiff(controllerId: string, diff: TestsDiffOp.Serialized[]): void;

// --- test run configurations:

/** Called when a new test run configuration is available */
$publishTestRunProfile(config: ITestRunProfile): void;
/** Updates an existing test run configuration */
$updateTestRunConfig(controllerId: string, configId: number, update: Partial<ITestRunProfile>): void;
/** Removes a previously-published test run config */
$removeTestProfile(controllerId: string, configId: number): void;

// --- test run handling:

/** Request by an extension to run tests. */
$runTests(req: ResolvedTestRunRequest, token: CancellationToken): Promise<string>;
/**
* Adds tests to the run. The tests are given in descending depth. The first
* item will be a previously-known test, or a test root.
*/
$addTestsToRun(controllerId: string, runId: string, tests: ITestItem.Serialized[]): void;
/** Updates the state of a test run in the given run. */
$updateTestStateInRun(runId: string, taskId: string, testId: string, state: TestResultState, duration?: number): void;
/** Appends a message to a test in the run. */
$appendTestMessagesInRun(runId: string, taskId: string, testId: string, messages: ITestMessage.Serialized[]): void;
/** Appends raw output to the test run.. */
$appendOutputToRun(runId: string, taskId: string, output: BinaryBuffer, location?: Location, testId?: string): void;
/** Triggered when coverage is added to test results. */
$signalCoverageAvailable(runId: string, taskId: string): void;
/** Signals a task in a test run started. */
$startedTestRunTask(runId: string, task: ITestRunTask): void;
/** Signals a task in a test run ended. */
$finishedTestRunTask(runId: string, taskId: string): void;
/** Start a new extension-provided test run. */
$startedExtensionTestRun(req: ExtensionRunTestsRequest): void;
/** Signals that an extension-provided test run finished. */
$finishedExtensionTestRun(runId: string): void;
}

export const PLUGIN_RPC_CONTEXT = {
AUTHENTICATION_MAIN: <ProxyIdentifier<AuthenticationMain>>createProxyIdentifier<AuthenticationMain>('AuthenticationMain'),
COMMAND_REGISTRY_MAIN: <ProxyIdentifier<CommandRegistryMain>>createProxyIdentifier<CommandRegistryMain>('CommandRegistryMain'),
Expand Down Expand Up @@ -2106,7 +2205,8 @@ export const PLUGIN_RPC_CONTEXT = {
TIMELINE_MAIN: <ProxyIdentifier<TimelineMain>>createProxyIdentifier<TimelineMain>('TimelineMain'),
THEMING_MAIN: <ProxyIdentifier<ThemingMain>>createProxyIdentifier<ThemingMain>('ThemingMain'),
COMMENTS_MAIN: <ProxyIdentifier<CommentsMain>>createProxyIdentifier<CommentsMain>('CommentsMain'),
TABS_MAIN: <ProxyIdentifier<TabsMain>>createProxyIdentifier<TabsMain>('TabsMain')
TABS_MAIN: <ProxyIdentifier<TabsMain>>createProxyIdentifier<TabsMain>('TabsMain'),
TESTING_MAIN: createProxyIdentifier<TestingMain>('TestingMain')
};

export const MAIN_RPC_CONTEXT = {
Expand Down Expand Up @@ -2141,7 +2241,8 @@ export const MAIN_RPC_CONTEXT = {
TIMELINE_EXT: createProxyIdentifier<TimelineExt>('TimeLineExt'),
THEMING_EXT: createProxyIdentifier<ThemingExt>('ThemingExt'),
COMMENTS_EXT: createProxyIdentifier<CommentsExt>('CommentsExt'),
TABS_EXT: createProxyIdentifier<TabsExt>('TabsExt')
TABS_EXT: createProxyIdentifier<TabsExt>('TabsExt'),
TESTING_EXT: createProxyIdentifier<TestingExt>('TestingExt')
};

export interface TasksExt {
Expand Down
Loading

0 comments on commit f4cba51

Please sign in to comment.