From b9ebb059dbf78156c22326f77c090aeb2186e359 Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Thu, 6 Oct 2022 15:56:37 -0700 Subject: [PATCH] testing: use real test item instances if available in command args (#162898) Fixes https://github.com/microsoft/vscode/issues/154659 (for realsies) --- src/vs/workbench/api/common/extHostTesting.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/api/common/extHostTesting.ts b/src/vs/workbench/api/common/extHostTesting.ts index bf44c8939d4..e6f7569b906 100644 --- a/src/vs/workbench/api/common/extHostTesting.ts +++ b/src/vs/workbench/api/common/extHostTesting.ts @@ -23,7 +23,7 @@ import * as Convert from 'vs/workbench/api/common/extHostTypeConverters'; import { TestRunProfileKind, TestRunRequest } from 'vs/workbench/api/common/extHostTypes'; import { TestId, TestIdPathParts, TestPosition } from 'vs/workbench/contrib/testing/common/testId'; import { InvalidTestItemError } from 'vs/workbench/contrib/testing/common/testItemCollection'; -import { AbstractIncrementalTestCollection, CoverageDetails, IFileCoverage, IncrementalChangeCollector, IncrementalTestCollectionItem, InternalTestItem, ISerializedTestResults, ITestItem, RunTestForControllerRequest, RunTestForControllerResult, TestResultState, TestRunProfileBitset, TestsDiff, TestsDiffOp } from 'vs/workbench/contrib/testing/common/testTypes'; +import { AbstractIncrementalTestCollection, CoverageDetails, IFileCoverage, IncrementalChangeCollector, IncrementalTestCollectionItem, InternalTestItem, ISerializedTestResults, ITestItem, ITestItemContext, RunTestForControllerRequest, RunTestForControllerResult, TestResultState, TestRunProfileBitset, TestsDiff, TestsDiffOp } from 'vs/workbench/contrib/testing/common/testTypes'; import type * as vscode from 'vscode'; interface ControllerInfo { @@ -52,8 +52,16 @@ export class ExtHostTesting implements ExtHostTestingShape { this.runTracker = new TestRunCoordinator(this.proxy); commands.registerArgumentProcessor({ - processArgument: arg => - arg?.$mid === MarshalledId.TestItemContext ? toItemFromContext(arg) : arg, + processArgument: arg => { + if (arg?.$mid !== MarshalledId.TestItemContext) { + return arg; + } + + const cast = arg as ITestItemContext; + const targetTest = cast.tests[cast.tests.length - 1].item.extId; + const controller = this.controllers.get(TestId.root(targetTest)); + return controller?.collection.tree.get(targetTest)?.actual ?? toItemFromContext(arg); + } }); }