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

testing: adopt optional value standard

For #124362
上级 2ada30a9
......@@ -14102,7 +14102,7 @@ declare module 'vscode' {
* Associated tag for the profile. If this is set, only {@link TestItem}
* instances with the same tag will be eligible to execute in this profile.
*/
tag?: TestTag;
tag: TestTag | undefined;
/**
* If this method is present, a configuration gear will be present in the
......@@ -14110,7 +14110,7 @@ declare module 'vscode' {
* you can take other editor actions, such as showing a quick pick or
* opening a configuration file.
*/
configureHandler?: () => void;
configureHandler: (() => void) | undefined;
/**
* Handler called to start a test run. When invoked, the function should call
......@@ -14259,7 +14259,7 @@ declare module 'vscode' {
* The process of running tests should resolve the children of any test
* items who have not yet been resolved.
*/
readonly include?: TestItem[];
readonly include: TestItem[] | undefined;
/**
* An array of tests the user has marked as excluded from the test included
......@@ -14268,14 +14268,14 @@ declare module 'vscode' {
* May be omitted if no exclusions were requested. Test controllers should
* not run excluded tests or any children of excluded tests.
*/
readonly exclude?: TestItem[];
readonly exclude: TestItem[] | undefined;
/**
* The profile used for this request. This will always be defined
* for requests issued from the editor UI, though extensions may
* programmatically create requests not associated with any profile.
*/
readonly profile?: TestRunProfile;
readonly profile: TestRunProfile | undefined;
/**
* @param tests Array of specific tests to run, or undefined to run all tests
......@@ -14294,7 +14294,7 @@ declare module 'vscode' {
* disambiguate multiple sets of results in a test run. It is useful if
* tests are run across multiple platforms, for example.
*/
readonly name?: string;
readonly name: string | undefined;
/**
* A cancellation token which will be triggered when the test run is
......@@ -14434,7 +14434,7 @@ declare module 'vscode' {
/**
* URI this `TestItem` is associated with. May be a file or directory.
*/
readonly uri?: Uri;
readonly uri: Uri | undefined;
/**
* The children of this test item. For a test suite, this may contain the
......@@ -14447,7 +14447,7 @@ declare module 'vscode' {
* top-level items in the {@link TestController.items} and for items that
* aren't yet included in another item's {@link children}.
*/
readonly parent?: TestItem;
readonly parent: TestItem | undefined;
/**
* Tags associated with this test item. May be used in combination with
......@@ -14489,7 +14489,7 @@ declare module 'vscode' {
*
* This is only meaningful if the `uri` points to a file.
*/
range?: Range;
range: Range | undefined;
/**
* Optional error encountered while loading the test.
......@@ -14497,7 +14497,7 @@ declare module 'vscode' {
* Note that this is not a test result and should only be used to represent errors in
* test discovery, such as syntax errors.
*/
error?: string | MarkdownString;
error: string | MarkdownString | undefined;
}
/**
......
......@@ -1728,6 +1728,8 @@ export namespace TestItem {
export function toPlain(item: ITestItem): Omit<vscode.TestItem, 'children' | 'invalidate' | 'discoverChildren'> {
return {
parent: undefined,
error: undefined,
id: TestId.fromString(item.extId).localId,
label: item.label,
uri: URI.revive(item.uri),
......
......@@ -3328,9 +3328,9 @@ export enum TestRunProfileKind {
@es5ClassCompat
export class TestRunRequest implements vscode.TestRunRequest {
constructor(
public readonly include?: vscode.TestItem[],
public readonly exclude?: vscode.TestItem[] | undefined,
public readonly profile?: vscode.TestRunProfile,
public readonly include: vscode.TestItem[] | undefined = undefined,
public readonly exclude: vscode.TestItem[] | undefined = undefined,
public readonly profile: vscode.TestRunProfile | undefined = undefined,
) { }
}
......
......@@ -7,16 +7,16 @@ import * as assert from 'assert';
import { VSBuffer } from 'vs/base/common/buffer';
import { CancellationTokenSource } from 'vs/base/common/cancellation';
import { Iterable } from 'vs/base/common/iterator';
import { URI } from 'vs/base/common/uri';
import { mockObject, MockObject } from 'vs/base/test/common/mock';
import { MainThreadTestingShape } from 'vs/workbench/api/common/extHost.protocol';
import { TestRunCoordinator, TestRunDto, TestRunProfileImpl } from 'vs/workbench/api/common/extHostTesting';
import * as convert from 'vs/workbench/api/common/extHostTypeConverters';
import { TestMessage, TestResultState, TestRunProfileKind, TestTag, Location, Position, Range } from 'vs/workbench/api/common/extHostTypes';
import { Location, Position, Range, TestMessage, TestResultState, TestRunProfileKind, TestRunRequest as TestRunRequestImpl, TestTag } from 'vs/workbench/api/common/extHostTypes';
import { TestDiffOpType, TestItemExpandState, TestMessageType } from 'vs/workbench/contrib/testing/common/testCollection';
import { TestId } from 'vs/workbench/contrib/testing/common/testId';
import { TestItemImpl, testStubs } from 'vs/workbench/contrib/testing/common/testStubs';
import { TestSingleUseCollection } from 'vs/workbench/contrib/testing/test/common/ownedTestCollection';
import { URI } from 'vs/base/common/uri';
import type { TestItem, TestRunRequest } from 'vscode';
const simplify = (item: TestItem) => ({
......@@ -654,7 +654,7 @@ suite('ExtHost Testing', () => {
const childB = new TestItemImpl('ctrlId', 'id-child', 'child', undefined);
testB!.children.replace([childB]);
const task1 = c.createTestRun('ctrl', single, {}, 'hello world', false);
const task1 = c.createTestRun('ctrl', single, new TestRunRequestImpl(), 'hello world', false);
const tracker = Iterable.first(c.trackers)!;
task1.passed(childA);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册