From 1a152e25933bf9230716c12b3585fa5cc133c8e9 Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Tue, 13 Aug 2024 10:29:14 -0700 Subject: [PATCH] testing: finalize test message stack trace API Closes #214488 --- .../src/testOutputScanner.ts | 2 +- .../tsconfig.json | 1 - .../common/extensionsApiProposals.ts | 3 -- .../workbench/api/common/extHost.api.impl.ts | 1 - .../api/common/extHostTypeConverters.ts | 2 +- src/vscode-dts/vscode.d.ts | 33 ++++++++++++++++ ...vscode.proposed.testMessageStackTrace.d.ts | 38 ------------------- 7 files changed, 35 insertions(+), 45 deletions(-) delete mode 100644 src/vscode-dts/vscode.proposed.testMessageStackTrace.d.ts diff --git a/.vscode/extensions/vscode-selfhost-test-provider/src/testOutputScanner.ts b/.vscode/extensions/vscode-selfhost-test-provider/src/testOutputScanner.ts index f8e70b4d9cdd5..296ed1e9f12be 100644 --- a/.vscode/extensions/vscode-selfhost-test-provider/src/testOutputScanner.ts +++ b/.vscode/extensions/vscode-selfhost-test-provider/src/testOutputScanner.ts @@ -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)); diff --git a/.vscode/extensions/vscode-selfhost-test-provider/tsconfig.json b/.vscode/extensions/vscode-selfhost-test-provider/tsconfig.json index df98ed3e6957c..56d6859c3e3b1 100644 --- a/.vscode/extensions/vscode-selfhost-test-provider/tsconfig.json +++ b/.vscode/extensions/vscode-selfhost-test-provider/tsconfig.json @@ -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" ] diff --git a/src/vs/platform/extensions/common/extensionsApiProposals.ts b/src/vs/platform/extensions/common/extensionsApiProposals.ts index 5d6bb87207abd..ae38c2ebec316 100644 --- a/src/vs/platform/extensions/common/extensionsApiProposals.ts +++ b/src/vs/platform/extensions/common/extensionsApiProposals.ts @@ -356,9 +356,6 @@ const _allApiProposals = { terminalSelection: { proposal: 'https://github.com/raw/microsoft/vscode/main/src/vscode-dts/vscode.proposed.terminalSelection.d.ts', }, - testMessageStackTrace: { - proposal: 'https://github.com/raw/microsoft/vscode/main/src/vscode-dts/vscode.proposed.testMessageStackTrace.d.ts', - }, testObserver: { proposal: 'https://github.com/raw/microsoft/vscode/main/src/vscode-dts/vscode.proposed.testObserver.d.ts', }, diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index 43c5387670b16..60968582b9851 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -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, diff --git a/src/vs/workbench/api/common/extHostTypeConverters.ts b/src/vs/workbench/api/common/extHostTypeConverters.ts index 436a9eb45441d..b57668f02f147 100644 --- a/src/vs/workbench/api/common/extHostTypeConverters.ts +++ b/src/vs/workbench/api/common/extHostTypeConverters.ts @@ -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(), diff --git a/src/vscode-dts/vscode.d.ts b/src/vscode-dts/vscode.d.ts index 9f109570c7a00..09ce5a92296eb 100644 --- a/src/vscode-dts/vscode.d.ts +++ b/src/vscode-dts/vscode.d.ts @@ -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. diff --git a/src/vscode-dts/vscode.proposed.testMessageStackTrace.d.ts b/src/vscode-dts/vscode.proposed.testMessageStackTrace.d.ts deleted file mode 100644 index 726865336da91..0000000000000 --- a/src/vscode-dts/vscode.proposed.testMessageStackTrace.d.ts +++ /dev/null @@ -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); - } -}