testing: use real test item instances if available in command args (#162898)

Fixes https://github.com/microsoft/vscode/issues/154659 (for realsies)
This commit is contained in:
Connor Peet 2022-10-06 15:56:37 -07:00 committed by GitHub
parent a4c9ea968d
commit b9ebb059db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);
}
});
}