testing: finalize test message stack trace API (#225517)

Closes #214488
pull/225530/head^2
Connor Peet 2024-08-13 13:56:29 -07:00 committed by GitHub
parent ffee42566a
commit ef72141fd1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 35 additions and 45 deletions

View File

@ -290,7 +290,7 @@ export async function scanTestOutput(
enqueueExitBlocker(
(async () => {
const stackInfo = await deriveStackLocations(store, rawErr, tcase!);
let message: vscode.TestMessage2;
let message: vscode.TestMessage;
if (hasDiff) {
message = new vscode.TestMessage(tryMakeMarkdown(err));

View File

@ -11,7 +11,6 @@
"src/**/*",
"../../../src/vscode-dts/vscode.d.ts",
"../../../src/vscode-dts/vscode.proposed.testObserver.d.ts",
"../../../src/vscode-dts/vscode.proposed.testMessageStackTrace.d.ts",
"../../../src/vscode-dts/vscode.proposed.testRelatedCode.d.ts",
"../../../src/vscode-dts/vscode.proposed.attributableCoverage.d.ts"
]

View File

@ -356,9 +356,6 @@ const _allApiProposals = {
terminalSelection: {
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.terminalSelection.d.ts',
},
testMessageStackTrace: {
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.testMessageStackTrace.d.ts',
},
testObserver: {
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.testObserver.d.ts',
},

View File

@ -1770,7 +1770,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
TestResultState: extHostTypes.TestResultState,
TestRunRequest: extHostTypes.TestRunRequest,
TestMessage: extHostTypes.TestMessage,
TestMessage2: extHostTypes.TestMessage,
TestMessageStackFrame: extHostTypes.TestMessageStackFrame,
TestTag: extHostTypes.TestTag,
TestRunProfileKind: extHostTypes.TestRunProfileKind,

View File

@ -1893,7 +1893,7 @@ export namespace TestMessage {
actual: message.actualOutput,
contextValue: message.contextValue,
location: message.location && ({ range: Range.from(message.location.range), uri: message.location.uri }),
stackTrace: (message as vscode.TestMessage2).stackTrace?.map(s => ({
stackTrace: message.stackTrace?.map(s => ({
label: s.label,
position: s.position && Position.from(s.position),
uri: s.uri && URI.revive(s.uri).toJSON(),

View File

@ -18093,6 +18093,34 @@ declare module 'vscode' {
error: string | MarkdownString | undefined;
}
/**
* A stack frame found in the {@link TestMessage.stackTrace}.
*/
export class TestMessageStackFrame {
/**
* The location of this stack frame. This should be provided as a URI if the
* location of the call frame can be accessed by the editor.
*/
uri?: Uri;
/**
* Position of the stack frame within the file.
*/
position?: Position;
/**
* The name of the stack frame, typically a method or function name.
*/
label: string;
/**
* @param label The name of the stack frame
* @param file The file URI of the stack frame
* @param position The position of the stack frame within the file
*/
constructor(label: string, uri?: Uri, position?: Position);
}
/**
* Message associated with the test state. Can be linked to a specific
* source range -- useful for assertion failures, for example.
@ -18149,6 +18177,11 @@ declare module 'vscode' {
*/
contextValue?: string;
/**
* The stack trace associated with the message or failure.
*/
stackTrace?: TestMessageStackFrame[];
/**
* Creates a new TestMessage that will present as a diff in the editor.
* @param message Message to display to the user.

View File

@ -1,38 +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' {
export class TestMessage2 extends TestMessage {
/**
* The stack trace associated with the message or failure.
*/
stackTrace?: TestMessageStackFrame[];
}
export class TestMessageStackFrame {
/**
* The location of this stack frame. This should be provided as a URI if the
* location of the call frame can be accessed by the editor.
*/
uri?: Uri;
/**
* Position of the stack frame within the file.
*/
position?: Position;
/**
* The name of the stack frame, typically a method or function name.
*/
label: string;
/**
* @param label The name of the stack frame
* @param file The file URI of the stack frame
* @param position The position of the stack frame within the file
*/
constructor(label: string, uri?: Uri, position?: Position);
}
}