Skip to content

Commit baa380d

Browse files
committed
testing: adopt optional value standard
For microsoft#124362
1 parent 2ada30a commit baa380d

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

src/vs/vscode.d.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14102,15 +14102,15 @@ declare module 'vscode' {
1410214102
* Associated tag for the profile. If this is set, only {@link TestItem}
1410314103
* instances with the same tag will be eligible to execute in this profile.
1410414104
*/
14105-
tag?: TestTag;
14105+
tag: TestTag | undefined;
1410614106

1410714107
/**
1410814108
* If this method is present, a configuration gear will be present in the
1410914109
* UI, and this method will be invoked when it's clicked. When called,
1411014110
* you can take other editor actions, such as showing a quick pick or
1411114111
* opening a configuration file.
1411214112
*/
14113-
configureHandler?: () => void;
14113+
configureHandler: (() => void) | undefined;
1411414114

1411514115
/**
1411614116
* Handler called to start a test run. When invoked, the function should call
@@ -14259,7 +14259,7 @@ declare module 'vscode' {
1425914259
* The process of running tests should resolve the children of any test
1426014260
* items who have not yet been resolved.
1426114261
*/
14262-
readonly include?: TestItem[];
14262+
readonly include: TestItem[] | undefined;
1426314263

1426414264
/**
1426514265
* An array of tests the user has marked as excluded from the test included
@@ -14268,14 +14268,14 @@ declare module 'vscode' {
1426814268
* May be omitted if no exclusions were requested. Test controllers should
1426914269
* not run excluded tests or any children of excluded tests.
1427014270
*/
14271-
readonly exclude?: TestItem[];
14271+
readonly exclude: TestItem[] | undefined;
1427214272

1427314273
/**
1427414274
* The profile used for this request. This will always be defined
1427514275
* for requests issued from the editor UI, though extensions may
1427614276
* programmatically create requests not associated with any profile.
1427714277
*/
14278-
readonly profile?: TestRunProfile;
14278+
readonly profile: TestRunProfile | undefined;
1427914279

1428014280
/**
1428114281
* @param tests Array of specific tests to run, or undefined to run all tests
@@ -14294,7 +14294,7 @@ declare module 'vscode' {
1429414294
* disambiguate multiple sets of results in a test run. It is useful if
1429514295
* tests are run across multiple platforms, for example.
1429614296
*/
14297-
readonly name?: string;
14297+
readonly name: string | undefined;
1429814298

1429914299
/**
1430014300
* A cancellation token which will be triggered when the test run is
@@ -14434,7 +14434,7 @@ declare module 'vscode' {
1443414434
/**
1443514435
* URI this `TestItem` is associated with. May be a file or directory.
1443614436
*/
14437-
readonly uri?: Uri;
14437+
readonly uri: Uri | undefined;
1443814438

1443914439
/**
1444014440
* The children of this test item. For a test suite, this may contain the
@@ -14447,7 +14447,7 @@ declare module 'vscode' {
1444714447
* top-level items in the {@link TestController.items} and for items that
1444814448
* aren't yet included in another item's {@link children}.
1444914449
*/
14450-
readonly parent?: TestItem;
14450+
readonly parent: TestItem | undefined;
1445114451

1445214452
/**
1445314453
* Tags associated with this test item. May be used in combination with
@@ -14489,15 +14489,15 @@ declare module 'vscode' {
1448914489
*
1449014490
* This is only meaningful if the `uri` points to a file.
1449114491
*/
14492-
range?: Range;
14492+
range: Range | undefined;
1449314493

1449414494
/**
1449514495
* Optional error encountered while loading the test.
1449614496
*
1449714497
* Note that this is not a test result and should only be used to represent errors in
1449814498
* test discovery, such as syntax errors.
1449914499
*/
14500-
error?: string | MarkdownString;
14500+
error: string | MarkdownString | undefined;
1450114501
}
1450214502

1450314503
/**

src/vs/workbench/api/common/extHostTypeConverters.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,6 +1728,8 @@ export namespace TestItem {
17281728

17291729
export function toPlain(item: ITestItem): Omit<vscode.TestItem, 'children' | 'invalidate' | 'discoverChildren'> {
17301730
return {
1731+
parent: undefined,
1732+
error: undefined,
17311733
id: TestId.fromString(item.extId).localId,
17321734
label: item.label,
17331735
uri: URI.revive(item.uri),

src/vs/workbench/api/common/extHostTypes.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3328,9 +3328,9 @@ export enum TestRunProfileKind {
33283328
@es5ClassCompat
33293329
export class TestRunRequest implements vscode.TestRunRequest {
33303330
constructor(
3331-
public readonly include?: vscode.TestItem[],
3332-
public readonly exclude?: vscode.TestItem[] | undefined,
3333-
public readonly profile?: vscode.TestRunProfile,
3331+
public readonly include: vscode.TestItem[] | undefined = undefined,
3332+
public readonly exclude: vscode.TestItem[] | undefined = undefined,
3333+
public readonly profile: vscode.TestRunProfile | undefined = undefined,
33343334
) { }
33353335
}
33363336

src/vs/workbench/test/browser/api/extHostTesting.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ import * as assert from 'assert';
77
import { VSBuffer } from 'vs/base/common/buffer';
88
import { CancellationTokenSource } from 'vs/base/common/cancellation';
99
import { Iterable } from 'vs/base/common/iterator';
10+
import { URI } from 'vs/base/common/uri';
1011
import { mockObject, MockObject } from 'vs/base/test/common/mock';
1112
import { MainThreadTestingShape } from 'vs/workbench/api/common/extHost.protocol';
1213
import { TestRunCoordinator, TestRunDto, TestRunProfileImpl } from 'vs/workbench/api/common/extHostTesting';
1314
import * as convert from 'vs/workbench/api/common/extHostTypeConverters';
14-
import { TestMessage, TestResultState, TestRunProfileKind, TestTag, Location, Position, Range } from 'vs/workbench/api/common/extHostTypes';
15+
import { Location, Position, Range, TestMessage, TestResultState, TestRunProfileKind, TestRunRequest as TestRunRequestImpl, TestTag } from 'vs/workbench/api/common/extHostTypes';
1516
import { TestDiffOpType, TestItemExpandState, TestMessageType } from 'vs/workbench/contrib/testing/common/testCollection';
1617
import { TestId } from 'vs/workbench/contrib/testing/common/testId';
1718
import { TestItemImpl, testStubs } from 'vs/workbench/contrib/testing/common/testStubs';
1819
import { TestSingleUseCollection } from 'vs/workbench/contrib/testing/test/common/ownedTestCollection';
19-
import { URI } from 'vs/base/common/uri';
2020
import type { TestItem, TestRunRequest } from 'vscode';
2121

2222
const simplify = (item: TestItem) => ({
@@ -654,7 +654,7 @@ suite('ExtHost Testing', () => {
654654
const childB = new TestItemImpl('ctrlId', 'id-child', 'child', undefined);
655655
testB!.children.replace([childB]);
656656

657-
const task1 = c.createTestRun('ctrl', single, {}, 'hello world', false);
657+
const task1 = c.createTestRun('ctrl', single, new TestRunRequestImpl(), 'hello world', false);
658658
const tracker = Iterable.first(c.trackers)!;
659659

660660
task1.passed(childA);

0 commit comments

Comments
 (0)