mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-28 12:33:35 +01:00
testing: update test item async resolving
See https://github.com/microsoft/vscode/issues/126987#issuecomment-867031454
This commit makes the following changes:
- Keep the `resolveChildrenHandler`, and remove the CancellationToken parameter
- Remove `TestITem.status` and instead have `TestItem.canResolveChildren?: boolean`
- Add `TestItem.busy?: boolean`. Note that the UI would implicitly show
the item as busy while `resolve` is being called. (This is a new feature)
Upgrading to account for these changes should take around 10 to 20 minutes:
1. Where you previously set `item.status = vscode.TestItemStatus.Pending`,
instead set `item.canResolveChildren = true`.
2. If you used the cancellation token in resolveChildrenHandler, you no
longer need to do so. What you do here instead is up to you:
- If you set up global workspace watchers, add those to `context.subscriptions`
- You _probably_ don't need to set up watchers for "file" test items,
since you will receive updates via `vscode.workspace.onDidChangeTextDocument`
and/or any FileWatcher you have set up.
Example of an update: 7287c64bf7
This commit is contained in:
@@ -1273,7 +1273,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||
NotebookControllerAffinity: extHostTypes.NotebookControllerAffinity,
|
||||
PortAttributes: extHostTypes.PortAttributes,
|
||||
LinkedEditingRanges: extHostTypes.LinkedEditingRanges,
|
||||
TestItemStatus: extHostTypes.TestItemStatus,
|
||||
TestResultState: extHostTypes.TestResultState,
|
||||
TestRunRequest: extHostTypes.TestRunRequest,
|
||||
TestMessage: extHostTypes.TestMessage,
|
||||
|
||||
@@ -1669,7 +1669,8 @@ export namespace TestItem {
|
||||
uri: URI.revive(item.uri),
|
||||
range: Range.to(item.range || undefined),
|
||||
dispose: () => undefined,
|
||||
status: types.TestItemStatus.Pending,
|
||||
canExpand: false,
|
||||
busy: false,
|
||||
data: undefined as never,
|
||||
debuggable: item.debuggable,
|
||||
description: item.description || undefined,
|
||||
|
||||
@@ -3297,11 +3297,6 @@ export enum TestMessageSeverity {
|
||||
Hint = 3
|
||||
}
|
||||
|
||||
export enum TestItemStatus {
|
||||
Pending = 0,
|
||||
Resolved = 1,
|
||||
}
|
||||
|
||||
const testItemPropAccessor = <K extends keyof vscode.TestItem<never>>(
|
||||
api: IExtHostTestItemApi,
|
||||
key: K,
|
||||
@@ -3351,7 +3346,8 @@ export class TestItemImpl<T = any> implements vscode.TestItem<T> {
|
||||
public debuggable!: boolean;
|
||||
public label!: string;
|
||||
public error!: string | vscode.MarkdownString;
|
||||
public status!: vscode.TestItemStatus;
|
||||
public busy!: boolean;
|
||||
public canResolveChildren!: boolean;
|
||||
|
||||
constructor(id: string, label: string, uri: vscode.Uri | undefined, public data: T, parent: vscode.TestItem | undefined) {
|
||||
const api = getPrivateApiFor(this);
|
||||
@@ -3382,7 +3378,8 @@ export class TestItemImpl<T = any> implements vscode.TestItem<T> {
|
||||
description: testItemPropAccessor(api, 'description', undefined, strictEqualComparator),
|
||||
runnable: testItemPropAccessor(api, 'runnable', true, strictEqualComparator),
|
||||
debuggable: testItemPropAccessor(api, 'debuggable', false, strictEqualComparator),
|
||||
status: testItemPropAccessor(api, 'status', TestItemStatus.Resolved, strictEqualComparator),
|
||||
canResolveChildren: testItemPropAccessor(api, 'canResolveChildren', false, strictEqualComparator),
|
||||
busy: testItemPropAccessor(api, 'busy', false, strictEqualComparator),
|
||||
error: testItemPropAccessor(api, 'error', undefined, strictEqualComparator),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user