未验证 提交 3f9af31b 编写于 作者: C Connor Peet

testing: update test types for feedback

上级 d22e9b4e
......@@ -1901,22 +1901,6 @@ declare module 'vscode' {
Coverage = 3,
}
/**
* Handler called to start a test run. When invoked, the function should
* {@link TestController.createTestRun} at least once, and all tasks
* associated with the run should be created before the function returns
* or the reutrned promise is resolved.
*
* @param request Request information for the test run
* @param cancellationToken Token that signals the used asked to abort the
* test run. If cancellation is requested on this token, all {@link TestRun}
* instances associated with the request will be
* automatically cancelled as well.
*/
// todo@api We have been there with NotebookCtrl#executeHandler and I believe the recommendation is still not to inline.
// At least with that we can still do it later
export type TestRunHandler = (request: TestRunRequest, token: CancellationToken) => Thenable<void> | void;
/**
* A TestRunProfile describes one way to execute tests in a {@link TestController}.
*/
......@@ -1955,10 +1939,10 @@ declare module 'vscode' {
configureHandler?: () => void;
/**
* Starts a test run. When called, the profile should call
* {@link TestController.createTestRun}. All tasks associated with the
* run should be created before the function returns or the reutrned
* promise is resolved.
* Handler called to start a test run. When invoked, the function should
* {@link TestController.createTestRun} at least once, and all tasks
* associated with the run should be created before the function returns
* or the reutrned promise is resolved.
*
* @param request Request information for the test run
* @param cancellationToken Token that signals the used asked to abort the
......@@ -1966,7 +1950,7 @@ declare module 'vscode' {
* instances associated with the request will be
* automatically cancelled as well.
*/
runHandler: TestRunHandler;
runHandler: (request: TestRunRequest, token: CancellationToken) => Thenable<void> | void;
/**
* Deletes the run profile.
......@@ -2014,7 +1998,7 @@ declare module 'vscode' {
* @param runHandler Function called to start a test run
* @param isDefault Whether this is the default action for the group
*/
createRunProfile(label: string, group: TestRunProfileGroup, runHandler: TestRunHandler, isDefault?: boolean): TestRunProfile;
createRunProfile(label: string, group: TestRunProfileGroup, runHandler: (request: TestRunRequest, token: CancellationToken) => Thenable<void> | void, isDefault?: boolean): TestRunProfile;
/**
* A function provided by the extension that the editor may call to request
......@@ -2158,7 +2142,7 @@ declare module 'vscode' {
* Collection of test items, found in {@link TestItem.children} and
* {@link TestController.items}.
*/
export interface TestItemCollection extends Iterable<TestItem> {
export interface TestItemCollection {
/**
* Updates the items stored by the collection.
* @param items Items to store, can be an array or other iterable.
......
......@@ -868,7 +868,7 @@ export class TestRunProfileImpl implements vscode.TestRunProfile {
public readonly profileId: number,
private _label: string,
public readonly group: vscode.TestRunProfileGroup,
public runHandler: vscode.TestRunHandler,
public runHandler: (request: vscode.TestRunRequest, token: vscode.CancellationToken) => Thenable<void> | void,
private _isDefault = false,
) {
this.#proxy = proxy;
......
......@@ -145,7 +145,7 @@ export class InvalidTestItemError extends Error {
}
}
export type TestItemCollectionImpl = vscode.TestItemCollection & { toJSON(): readonly TestItemImpl[] };
export type TestItemCollectionImpl = vscode.TestItemCollection & { toJSON(): readonly TestItemImpl[] } & Iterable<TestItemImpl>;
export const createTestItemCollection = (owningItem: TestItemImpl): TestItemCollectionImpl => {
const api = getPrivateApiFor(owningItem);
......
......@@ -25,7 +25,7 @@ const simplify = (item: TestItem) => ({
range: item.range,
});
const assertTreesEqual = (a: TestItem | undefined, b: TestItem | undefined) => {
const assertTreesEqual = (a: TestItemImpl | undefined, b: TestItemImpl | undefined) => {
if (!a) {
throw new assert.AssertionError({ message: 'Expected a to be defined', actual: a });
}
......@@ -39,7 +39,7 @@ const assertTreesEqual = (a: TestItem | undefined, b: TestItem | undefined) => {
const aChildren = [...a.children].map(c => c.id).sort();
const bChildren = [...b.children].map(c => c.id).sort();
assert.strictEqual(aChildren.length, bChildren.length, `expected ${a.label}.children.length == ${b.label}.children.length`);
aChildren.forEach(key => assertTreesEqual(a.children.get(key), b.children.get(key)));
aChildren.forEach(key => assertTreesEqual(a.children.get(key) as TestItemImpl, b.children.get(key) as TestItemImpl));
};
// const assertTreeListEqual = (a: ReadonlyArray<TestItem>, b: ReadonlyArray<TestItem>) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册