testing: finalize TestMessage.contextValue (#195706)

Closes #190277
This commit is contained in:
Connor Peet 2023-10-16 11:37:37 -07:00 committed by GitHub
parent f430137625
commit d2b1eb8a36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 35 additions and 57 deletions

View file

@ -45,7 +45,6 @@
"tunnels",
"testCoverage",
"testObserver",
"testMessageContextValue",
"textSearchProvider",
"timeline",
"tokenInformation",

View file

@ -1573,7 +1573,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
TestResultState: extHostTypes.TestResultState,
TestRunRequest: extHostTypes.TestRunRequest,
TestMessage: extHostTypes.TestMessage,
TestMessage2: extHostTypes.TestMessage,
TestMessage2: extHostTypes.TestMessage, // back compat for Oct 2023
TestTag: extHostTypes.TestTag,
TestRunProfileKind: extHostTypes.TestRunProfileKind,
TextSearchCompleteMessageType: TextSearchCompleteMessageType,

View file

@ -29,7 +29,6 @@ import { TestCommandId } from 'vs/workbench/contrib/testing/common/constants';
import { TestId, TestIdPathParts, TestPosition } from 'vs/workbench/contrib/testing/common/testId';
import { InvalidTestItemError } from 'vs/workbench/contrib/testing/common/testItemCollection';
import { AbstractIncrementalTestCollection, CoverageDetails, ICallProfileRunHandler, IFileCoverage, ISerializedTestResults, IStartControllerTests, IStartControllerTestsResult, ITestErrorMessage, ITestItem, ITestItemContext, ITestMessageMenuArgs, IncrementalChangeCollector, IncrementalTestCollectionItem, InternalTestItem, TestResultState, TestRunProfileBitset, TestsDiff, TestsDiffOp, isStartControllerTests } from 'vs/workbench/contrib/testing/common/testTypes';
import { checkProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions';
import type * as vscode from 'vscode';
interface ControllerInfo {
@ -424,7 +423,6 @@ class TestRunTracker extends Disposable {
constructor(
private readonly dto: TestRunDto,
private readonly proxy: MainThreadTestingShape,
private readonly extension: Readonly<IRelaxedExtensionDescription>,
parentToken?: CancellationToken,
) {
super();
@ -476,10 +474,6 @@ class TestRunTracker extends Disposable {
? messages.map(Convert.TestMessage.from)
: [Convert.TestMessage.from(messages)];
if (converted.some(c => c.contextValue !== undefined)) {
checkProposedApiEnabled(this.extension, 'testMessageContextValue');
}
if (test.uri && test.range) {
const defaultLocation: ILocationDto = { range: Convert.Range.from(test.range), uri: test.uri };
for (const message of converted) {
@ -690,7 +684,7 @@ export class TestRunCoordinator {
}
private getTracker(req: vscode.TestRunRequest, dto: TestRunDto, extension: IRelaxedExtensionDescription, token?: CancellationToken) {
const tracker = new TestRunTracker(dto, this.proxy, extension, token);
const tracker = new TestRunTracker(dto, this.proxy, token);
this.tracked.set(req, tracker);
Event.once(tracker.onEnd)(() => this.tracked.delete(req));
return tracker;

View file

@ -1833,7 +1833,7 @@ export namespace NotebookRendererScript {
}
export namespace TestMessage {
export function from(message: vscode.TestMessage2): ITestErrorMessage.Serialized {
export function from(message: vscode.TestMessage): ITestErrorMessage.Serialized {
return {
message: MarkdownString.fromStrict(message.message) || '',
type: TestMessageType.Error,
@ -1844,7 +1844,7 @@ export namespace TestMessage {
};
}
export function to(item: ITestErrorMessage.Serialized): vscode.TestMessage2 {
export function to(item: ITestErrorMessage.Serialized): vscode.TestMessage {
const message = new types.TestMessage(typeof item.message === 'string' ? item.message : MarkdownString.to(item.message));
message.actualOutput = item.actual;
message.expectedOutput = item.expected;

View file

@ -95,7 +95,6 @@ export const allApiProposals = Object.freeze({
terminalQuickFixProvider: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.terminalQuickFixProvider.d.ts',
terminalSelection: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.terminalSelection.d.ts',
testCoverage: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.testCoverage.d.ts',
testMessageContextValue: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.testMessageContextValue.d.ts',
testObserver: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.testObserver.d.ts',
textSearchProvider: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.textSearchProvider.d.ts',
timeline: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.timeline.d.ts',

View file

@ -17610,6 +17610,37 @@ declare module 'vscode' {
*/
location?: Location;
/**
* Context value of the test item. This can be used to contribute message-
* specific actions to the test peek view. The value set here can be found
* in the `testMessage` property of the following `menus` contribution points:
*
* - `testing/message/context` - context menu for the message in the results tree
* - `testing/message/content` - a prominent button overlaying editor content where
* the message is displayed.
*
* For example:
*
* ```json
* "contributes": {
* "menus": {
* "testing/message/content": [
* {
* "command": "extension.deleteCommentThread",
* "when": "testMessage == canApplyRichDiff"
* }
* ]
* }
* }
* ```
*
* The command will be called with an object containing:
* - `test`: the {@link TestItem} the message is associated with, *if* it
* is still present in the {@link TestController.items} collection.
* - `message`: the {@link TestMessage} instance.
*/
contextValue?: string;
/**
* Creates a new TestMessage that will present as a diff in the editor.
* @param message Message to display to the user.

View file

@ -1,45 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
declare module 'vscode' {
// https://github.com/microsoft/vscode/issues/190277
export class TestMessage2 extends TestMessage {
/**
* Context value of the test item. This can be used to contribute message-
* specific actions to the test peek view. The value set here can be found
* in the `testMessage` property of the following `menus` contribution points:
*
* - `testing/message/context` - context menu for the message in the results tree
* - `testing/message/content` - a prominent button overlaying editor content where
* the message is displayed.
*
* For example:
*
* ```json
* "contributes": {
* "menus": {
* "testing/message/content": [
* {
* "command": "extension.deleteCommentThread",
* "when": "testMessage == canApplyRichDiff"
* }
* ]
* }
* }
* ```
*
* The command will be called with an object containing:
* - `test`: the {@link TestItem} the message is associated with, *if* it
* is still present in the {@link TestController.items} collection.
* - `message`: the {@link TestMessage} instance.
*/
contextValue?: string;
// ...
}
}