-
Notifications
You must be signed in to change notification settings - Fork 29.2k
/
vscode.proposed.testObserver.d.ts
184 lines (158 loc) · 5.05 KB
/
vscode.proposed.testObserver.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
declare module 'vscode' {
// https://github.com/microsoft/vscode/issues/107467
export namespace tests {
/**
* Requests that tests be run by their controller.
* @param run Run options to use.
* @param token Cancellation token for the test run
*/
export function runTests(run: TestRunRequest, token?: CancellationToken): Thenable<void>;
/**
* Returns an observer that watches and can request tests.
*/
export function createTestObserver(): TestObserver;
/**
* List of test results stored by the editor, sorted in descending
* order by their `completedAt` time.
*/
export const testResults: ReadonlyArray<TestRunResult>;
/**
* Event that fires when the {@link testResults} array is updated.
*/
export const onDidChangeTestResults: Event<void>;
}
export interface TestObserver {
/**
* List of tests returned by test provider for files in the workspace.
*/
readonly tests: ReadonlyArray<TestItem>;
/**
* An event that fires when an existing test in the collection changes, or
* null if a top-level test was added or removed. When fired, the consumer
* should check the test item and all its children for changes.
*/
readonly onDidChangeTest: Event<TestsChangeEvent>;
/**
* Dispose of the observer, allowing the editor to eventually tell test
* providers that they no longer need to update tests.
*/
dispose(): void;
}
export interface TestsChangeEvent {
/**
* List of all tests that are newly added.
*/
readonly added: ReadonlyArray<TestItem>;
/**
* List of existing tests that have updated.
*/
readonly updated: ReadonlyArray<TestItem>;
/**
* List of existing tests that have been removed.
*/
readonly removed: ReadonlyArray<TestItem>;
}
/**
* TestResults can be provided to the editor in {@link tests.publishTestResult},
* or read from it in {@link tests.testResults}.
*
* The results contain a 'snapshot' of the tests at the point when the test
* run is complete. Therefore, information such as its {@link Range} may be
* out of date. If the test still exists in the workspace, consumers can use
* its `id` to correlate the result instance with the living test.
*/
export interface TestRunResult {
/**
* Unix milliseconds timestamp at which the test run was completed.
*/
readonly completedAt: number;
/**
* Optional raw output from the test run.
*/
readonly output?: string;
/**
* List of test results. The items in this array are the items that
* were passed in the {@link tests.runTests} method.
*/
readonly results: ReadonlyArray<Readonly<TestResultSnapshot>>;
}
/**
* A {@link TestItem}-like interface with an associated result, which appear
* or can be provided in {@link TestResult} interfaces.
*/
export interface TestResultSnapshot {
/**
* Unique identifier that matches that of the associated TestItem.
* This is used to correlate test results and tests in the document with
* those in the workspace (test explorer).
*/
readonly id: string;
/**
* Parent of this item.
*/
readonly parent?: TestResultSnapshot;
/**
* URI this TestItem is associated with. May be a file or file.
*/
readonly uri?: Uri;
/**
* Display name describing the test case.
*/
readonly label: string;
/**
* Optional description that appears next to the label.
*/
readonly description?: string;
/**
* Location of the test item in its `uri`. This is only meaningful if the
* `uri` points to a file.
*/
readonly range?: Range;
/**
* State of the test in each task. In the common case, a test will only
* be executed in a single task and the length of this array will be 1.
*/
readonly taskStates: ReadonlyArray<TestSnapshotTaskState>;
/**
* Optional list of nested tests for this item.
*/
readonly children: Readonly<TestResultSnapshot>[];
}
export interface TestSnapshotTaskState {
/**
* Current result of the test.
*/
readonly state: TestResultState;
/**
* The number of milliseconds the test took to run. This is set once the
* `state` is `Passed`, `Failed`, or `Errored`.
*/
readonly duration?: number;
/**
* Associated test run message. Can, for example, contain assertion
* failure information if the test fails.
*/
readonly messages: ReadonlyArray<TestMessage>;
}
/**
* Possible states of tests in a test run.
*/
export enum TestResultState {
// Test will be run, but is not currently running.
Queued = 1,
// Test is currently running
Running = 2,
// Test run has passed
Passed = 3,
// Test run has failed (on an assertion)
Failed = 4,
// Test run has been skipped
Skipped = 5,
// Test run failed for some other reason (compilation error, timeout, etc)
Errored = 6
}
}