@codingame/monaco-vscode-testing-service-override 3.2.3 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/package.json +8 -8
  2. package/testing.js +5 -4
  3. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +0 -3
  4. package/external/tslib/tslib.es6.js +0 -11
  5. package/vscode/src/vs/workbench/contrib/testing/browser/codeCoverageDecorations.js +0 -567
  6. package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/display.js +0 -3
  7. package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/index.js +0 -83
  8. package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/listProjection.js +0 -186
  9. package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/testItemContextOverlay.js +0 -18
  10. package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/testingObjectTree.js +0 -46
  11. package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/testingViewState.js +0 -17
  12. package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/treeProjection.js +0 -225
  13. package/vscode/src/vs/workbench/contrib/testing/browser/icons.js +0 -174
  14. package/vscode/src/vs/workbench/contrib/testing/browser/media/testing.css.js +0 -6
  15. package/vscode/src/vs/workbench/contrib/testing/browser/testCoverageBars.js +0 -227
  16. package/vscode/src/vs/workbench/contrib/testing/browser/testCoverageView.js +0 -545
  17. package/vscode/src/vs/workbench/contrib/testing/browser/testExplorerActions.js +0 -1662
  18. package/vscode/src/vs/workbench/contrib/testing/browser/testing.contribution.js +0 -219
  19. package/vscode/src/vs/workbench/contrib/testing/browser/testingDecorations.js +0 -970
  20. package/vscode/src/vs/workbench/contrib/testing/browser/testingExplorerFilter.js +0 -236
  21. package/vscode/src/vs/workbench/contrib/testing/browser/testingExplorerView.js +0 -1227
  22. package/vscode/src/vs/workbench/contrib/testing/browser/testingOutputPeek.css.js +0 -6
  23. package/vscode/src/vs/workbench/contrib/testing/browser/testingOutputPeek.js +0 -2091
  24. package/vscode/src/vs/workbench/contrib/testing/browser/testingProgressUiService.js +0 -142
  25. package/vscode/src/vs/workbench/contrib/testing/browser/testingViewPaneContainer.js +0 -47
  26. package/vscode/src/vs/workbench/contrib/testing/browser/theme.js +0 -259
  27. package/vscode/src/vs/workbench/contrib/testing/common/configuration.js +0 -273
  28. package/vscode/src/vs/workbench/contrib/testing/common/constants.js +0 -59
  29. package/vscode/src/vs/workbench/contrib/testing/common/mainThreadTestCollection.js +0 -129
  30. package/vscode/src/vs/workbench/contrib/testing/common/testExclusions.js +0 -48
  31. package/vscode/src/vs/workbench/contrib/testing/common/testServiceImpl.js +0 -296
  32. package/vscode/src/vs/workbench/contrib/testing/common/testingContentProvider.js +0 -125
  33. package/vscode/src/vs/workbench/contrib/testing/common/testingUri.js +0 -67
@@ -1,1662 +0,0 @@
1
- import { distinct } from 'vscode/vscode/vs/base/common/arrays';
2
- import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
3
- import { Iterable } from 'vscode/vscode/vs/base/common/iterator';
4
- import { KeyChord } from 'vscode/vscode/vs/base/common/keyCodes';
5
- import { isDefined } from 'vscode/vscode/vs/base/common/types';
6
- import { isCodeEditor } from 'vscode/vscode/vs/editor/browser/editorBrowser';
7
- import { Position } from 'vscode/vscode/vs/editor/common/core/position';
8
- import { Range } from 'vscode/vscode/vs/editor/common/core/range';
9
- import { EditorContextKeys } from 'vscode/vscode/vs/editor/common/editorContextKeys';
10
- import { MessageController } from 'vscode/vscode/vs/editor/contrib/message/browser/messageController';
11
- import { localize2WithPath, localizeWithPath } from 'vscode/vscode/vs/nls';
12
- import { Categories } from 'vscode/vscode/vs/platform/action/common/actionCommonCategories';
13
- import { Action2, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
14
- import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands';
15
- import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
16
- import { ContextKeyGreaterExpr, ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
17
- import { INotificationService, Severity } from 'vscode/vscode/vs/platform/notification/common/notification';
18
- import { IProgressService } from 'vscode/vscode/vs/platform/progress/common/progress';
19
- import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput';
20
- import { widgetClose } from 'vscode/vscode/vs/platform/theme/common/iconRegistry';
21
- import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
22
- import { ViewAction } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPane';
23
- import { FocusedViewContext } from 'vscode/vscode/vs/workbench/common/contextkeys';
24
- import { VIEWLET_ID } from 'vscode/vscode/vs/workbench/contrib/extensions/common/extensions';
25
- import { TestItemTreeElement } from './explorerProjections/index.js';
26
- import { testingDebugIcon, testingCoverageIcon, testingRunIcon, testingUpdateProfiles, testingTurnContinuousRunOn, testingContinuousIsOn, testingTurnContinuousRunOff, testingRunAllIcon, testingDebugAllIcon, testingCoverageAllIcon, testingCancelIcon, testingRefreshTests, testingCancelRefreshTests } from './icons.js';
27
- import { getTestingConfiguration } from '../common/configuration.js';
28
- import { testConfigurationGroupNames } from '../common/constants.js';
29
- import { ITestCoverageService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testCoverageService';
30
- import { TestId } from 'vscode/vscode/vs/workbench/contrib/testing/common/testId';
31
- import { canUseProfileWithTest, ITestProfileService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testProfileService';
32
- import { ITestResultService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testResultService';
33
- import { expandAndGetTestById, ITestService, testsInFile, testsUnderUri } from 'vscode/vscode/vs/workbench/contrib/testing/common/testService';
34
- import { TestingContextKeys } from 'vscode/vscode/vs/workbench/contrib/testing/common/testingContextKeys';
35
- import { ITestingContinuousRunService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testingContinuousRunService';
36
- import { ITestingPeekOpener } from 'vscode/vscode/vs/workbench/contrib/testing/common/testingPeekOpener';
37
- import { isFailedState } from 'vscode/vscode/vs/workbench/contrib/testing/common/testingStates';
38
- import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
39
- import { IPaneCompositePartService } from 'vscode/vscode/vs/workbench/services/panecomposite/browser/panecomposite';
40
- import { IViewsService } from 'vscode/vscode/vs/workbench/services/views/common/viewsService';
41
-
42
- const category = Categories.Test;
43
- const hasAnyTestProvider = ContextKeyGreaterExpr.create(TestingContextKeys.providerCount.key, 0);
44
- const LABEL_RUN_TESTS = ( localize2WithPath(
45
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
46
- 'runSelectedTests',
47
- "Run Tests"
48
- ));
49
- const LABEL_DEBUG_TESTS = ( localize2WithPath(
50
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
51
- 'debugSelectedTests',
52
- "Debug Tests"
53
- ));
54
- const LABEL_COVERAGE_TESTS = ( localize2WithPath(
55
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
56
- 'coverageSelectedTests',
57
- "Run Tests with Coverage"
58
- ));
59
- class HideTestAction extends Action2 {
60
- constructor() {
61
- super({
62
- id: "testing.hideTest" ,
63
- title: ( localizeWithPath(
64
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
65
- 'hideTest',
66
- 'Hide Test'
67
- )),
68
- menu: {
69
- id: MenuId.TestItem,
70
- group: 'builtin@2',
71
- when: ( TestingContextKeys.testItemIsHidden.isEqualTo(false))
72
- },
73
- });
74
- }
75
- run(accessor, ...elements) {
76
- const service = accessor.get(ITestService);
77
- for (const element of elements) {
78
- service.excluded.toggle(element.test, true);
79
- }
80
- return Promise.resolve();
81
- }
82
- }
83
- class UnhideTestAction extends Action2 {
84
- constructor() {
85
- super({
86
- id: "testing.unhideTest" ,
87
- title: ( localizeWithPath(
88
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
89
- 'unhideTest',
90
- 'Unhide Test'
91
- )),
92
- menu: {
93
- id: MenuId.TestItem,
94
- order: 21 ,
95
- when: ( TestingContextKeys.testItemIsHidden.isEqualTo(true))
96
- },
97
- });
98
- }
99
- run(accessor, ...elements) {
100
- const service = accessor.get(ITestService);
101
- for (const element of elements) {
102
- if (element instanceof TestItemTreeElement) {
103
- service.excluded.toggle(element.test, false);
104
- }
105
- }
106
- return Promise.resolve();
107
- }
108
- }
109
- class UnhideAllTestsAction extends Action2 {
110
- constructor() {
111
- super({
112
- id: "testing.unhideAllTests" ,
113
- title: ( localizeWithPath(
114
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
115
- 'unhideAllTests',
116
- 'Unhide All Tests'
117
- )),
118
- });
119
- }
120
- run(accessor) {
121
- const service = accessor.get(ITestService);
122
- service.excluded.clear();
123
- return Promise.resolve();
124
- }
125
- }
126
- const testItemInlineAndInContext = (order, when) => [
127
- {
128
- id: MenuId.TestItem,
129
- group: 'inline',
130
- order,
131
- when,
132
- }, {
133
- id: MenuId.TestItem,
134
- group: 'builtin@1',
135
- order,
136
- when,
137
- }
138
- ];
139
- class RunVisibleAction extends ViewAction {
140
- constructor(bitset, desc) {
141
- super({
142
- ...desc,
143
- viewId: "workbench.view.testing" ,
144
- });
145
- this.bitset = bitset;
146
- }
147
- runInView(accessor, view, ...elements) {
148
- const { include, exclude } = view.getTreeIncludeExclude(( elements.map(e => e.test)));
149
- return accessor.get(ITestService).runTests({
150
- tests: include,
151
- exclude,
152
- group: this.bitset,
153
- });
154
- }
155
- }
156
- class DebugAction extends RunVisibleAction {
157
- constructor() {
158
- super(4 , {
159
- id: "testing.debug" ,
160
- title: ( localizeWithPath(
161
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
162
- 'debug test',
163
- 'Debug Test'
164
- )),
165
- icon: testingDebugIcon,
166
- menu: testItemInlineAndInContext(12 , ( TestingContextKeys.hasDebuggableTests.isEqualTo(true))),
167
- });
168
- }
169
- }
170
- class CoverageAction extends RunVisibleAction {
171
- constructor() {
172
- super(8 , {
173
- id: "testing.coverage" ,
174
- title: ( localizeWithPath(
175
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
176
- 'run with cover test',
177
- 'Run Test with Coverage'
178
- )),
179
- icon: testingCoverageIcon,
180
- menu: testItemInlineAndInContext(13 , ( TestingContextKeys.hasCoverableTests.isEqualTo(true))),
181
- });
182
- }
183
- }
184
- class RunUsingProfileAction extends Action2 {
185
- constructor() {
186
- super({
187
- id: "testing.runUsing" ,
188
- title: ( localizeWithPath(
189
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
190
- 'testing.runUsing',
191
- 'Execute Using Profile...'
192
- )),
193
- icon: testingDebugIcon,
194
- menu: {
195
- id: MenuId.TestItem,
196
- order: 15 ,
197
- group: 'builtin@2',
198
- when: ( TestingContextKeys.hasNonDefaultProfile.isEqualTo(true)),
199
- },
200
- });
201
- }
202
- async run(acessor, ...elements) {
203
- const commandService = acessor.get(ICommandService);
204
- const testService = acessor.get(ITestService);
205
- const profile = await commandService.executeCommand('vscode.pickTestProfile', {
206
- onlyForTest: elements[0].test,
207
- });
208
- if (!profile) {
209
- return;
210
- }
211
- testService.runResolvedTests({
212
- targets: [{
213
- profileGroup: profile.group,
214
- profileId: profile.profileId,
215
- controllerId: profile.controllerId,
216
- testIds: ( elements.filter(t => canUseProfileWithTest(profile, t.test)).map(t => t.test.item.extId))
217
- }]
218
- });
219
- }
220
- }
221
- class RunAction extends RunVisibleAction {
222
- constructor() {
223
- super(2 , {
224
- id: "testing.run" ,
225
- title: ( localizeWithPath(
226
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
227
- 'run test',
228
- 'Run Test'
229
- )),
230
- icon: testingRunIcon,
231
- menu: testItemInlineAndInContext(11 , ( TestingContextKeys.hasRunnableTests.isEqualTo(true))),
232
- });
233
- }
234
- }
235
- class SelectDefaultTestProfiles extends Action2 {
236
- constructor() {
237
- super({
238
- id: "testing.selectDefaultTestProfiles" ,
239
- title: ( localizeWithPath(
240
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
241
- 'testing.selectDefaultTestProfiles',
242
- 'Select Default Profile'
243
- )),
244
- icon: testingUpdateProfiles,
245
- category,
246
- });
247
- }
248
- async run(acessor, onlyGroup) {
249
- const commands = acessor.get(ICommandService);
250
- const testProfileService = acessor.get(ITestProfileService);
251
- const profiles = await commands.executeCommand('vscode.pickMultipleTestProfiles', {
252
- showConfigureButtons: false,
253
- selected: testProfileService.getGroupDefaultProfiles(onlyGroup),
254
- onlyGroup,
255
- });
256
- if (profiles?.length) {
257
- testProfileService.setGroupDefaultProfiles(onlyGroup, profiles);
258
- }
259
- }
260
- }
261
- class ContinuousRunTestAction extends Action2 {
262
- constructor() {
263
- super({
264
- id: "testing.toggleContinuousRunForTest" ,
265
- title: ( localizeWithPath(
266
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
267
- 'testing.toggleContinuousRunOn',
268
- 'Turn on Continuous Run'
269
- )),
270
- icon: testingTurnContinuousRunOn,
271
- precondition: ( ContextKeyExpr.or(( TestingContextKeys.isContinuousModeOn.isEqualTo(true)), ( TestingContextKeys.isParentRunningContinuously.isEqualTo(false)))),
272
- toggled: {
273
- condition: ( TestingContextKeys.isContinuousModeOn.isEqualTo(true)),
274
- icon: testingContinuousIsOn,
275
- title: ( localizeWithPath(
276
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
277
- 'testing.toggleContinuousRunOff',
278
- 'Turn off Continuous Run'
279
- )),
280
- },
281
- menu: testItemInlineAndInContext(2147483647 , ( TestingContextKeys.supportsContinuousRun.isEqualTo(true))),
282
- });
283
- }
284
- async run(accessor, ...elements) {
285
- const crService = accessor.get(ITestingContinuousRunService);
286
- for (const element of elements) {
287
- const id = element.test.item.extId;
288
- if (crService.isSpecificallyEnabledFor(id)) {
289
- crService.stop(id);
290
- continue;
291
- }
292
- crService.start(2 , id);
293
- }
294
- }
295
- }
296
- class ContinuousRunUsingProfileTestAction extends Action2 {
297
- constructor() {
298
- super({
299
- id: "testing.continuousRunUsingForTest" ,
300
- title: ( localizeWithPath(
301
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
302
- 'testing.startContinuousRunUsing',
303
- 'Start Continous Run Using...'
304
- )),
305
- icon: testingDebugIcon,
306
- menu: [
307
- {
308
- id: MenuId.TestItem,
309
- order: 14 ,
310
- group: 'builtin@2',
311
- when: ( ContextKeyExpr.and(( TestingContextKeys.supportsContinuousRun.isEqualTo(true)), ( TestingContextKeys.isContinuousModeOn.isEqualTo(false))))
312
- }
313
- ],
314
- });
315
- }
316
- async run(accessor, ...elements) {
317
- const crService = accessor.get(ITestingContinuousRunService);
318
- const profileService = accessor.get(ITestProfileService);
319
- const notificationService = accessor.get(INotificationService);
320
- const quickInputService = accessor.get(IQuickInputService);
321
- for (const element of elements) {
322
- const selected = await selectContinuousRunProfiles(crService, notificationService, quickInputService, [{ profiles: profileService.getControllerProfiles(element.test.controllerId) }]);
323
- if (selected.length) {
324
- crService.start(selected, element.test.item.extId);
325
- }
326
- }
327
- }
328
- }
329
- class ConfigureTestProfilesAction extends Action2 {
330
- constructor() {
331
- super({
332
- id: "testing.configureProfile" ,
333
- title: ( localize2WithPath(
334
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
335
- 'testing.configureProfile',
336
- "Configure Test Profiles"
337
- )),
338
- icon: testingUpdateProfiles,
339
- f1: true,
340
- category,
341
- menu: {
342
- id: MenuId.CommandPalette,
343
- when: ( TestingContextKeys.hasConfigurableProfile.isEqualTo(true)),
344
- },
345
- });
346
- }
347
- async run(acessor, onlyGroup) {
348
- const commands = acessor.get(ICommandService);
349
- const testProfileService = acessor.get(ITestProfileService);
350
- const profile = await commands.executeCommand('vscode.pickTestProfile', {
351
- placeholder: ( localizeWithPath(
352
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
353
- 'configureProfile',
354
- 'Select a profile to update'
355
- )),
356
- showConfigureButtons: false,
357
- onlyConfigurable: true,
358
- onlyGroup,
359
- });
360
- if (profile) {
361
- testProfileService.configure(profile.controllerId, profile.profileId);
362
- }
363
- }
364
- }
365
- const continuousMenus = (whenIsContinuousOn) => [
366
- {
367
- id: MenuId.ViewTitle,
368
- group: 'navigation',
369
- order: 15 ,
370
- when: ( ContextKeyExpr.and(( ContextKeyExpr.equals('view', "workbench.view.testing" )), ( TestingContextKeys.supportsContinuousRun.isEqualTo(true)), ( TestingContextKeys.isContinuousModeOn.isEqualTo(whenIsContinuousOn)))),
371
- },
372
- {
373
- id: MenuId.CommandPalette,
374
- when: ( TestingContextKeys.supportsContinuousRun.isEqualTo(true)),
375
- },
376
- ];
377
- class StopContinuousRunAction extends Action2 {
378
- constructor() {
379
- super({
380
- id: "testing.stopContinuousRun" ,
381
- title: ( localize2WithPath(
382
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
383
- 'testing.stopContinuous',
384
- 'Stop Continuous Run'
385
- )),
386
- category,
387
- icon: testingTurnContinuousRunOff,
388
- menu: continuousMenus(true),
389
- });
390
- }
391
- run(accessor) {
392
- accessor.get(ITestingContinuousRunService).stop();
393
- }
394
- }
395
- function selectContinuousRunProfiles(crs, notificationService, quickInputService, profilesToPickFrom) {
396
- const items = [];
397
- for (const { controller, profiles } of profilesToPickFrom) {
398
- for (const profile of profiles) {
399
- if (profile.supportsContinuousRun) {
400
- items.push({
401
- label: profile.label || controller?.label.value || '',
402
- description: controller?.label.value,
403
- profile,
404
- });
405
- }
406
- }
407
- }
408
- if (items.length === 0) {
409
- notificationService.info(( localizeWithPath(
410
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
411
- 'testing.noProfiles',
412
- 'No test continuous run-enabled profiles were found'
413
- )));
414
- return Promise.resolve([]);
415
- }
416
- if (items.length === 1) {
417
- return Promise.resolve([items[0].profile]);
418
- }
419
- const qpItems = [];
420
- const selectedItems = [];
421
- const lastRun = crs.lastRunProfileIds;
422
- items.sort((a, b) => a.profile.group - b.profile.group
423
- || a.profile.controllerId.localeCompare(b.profile.controllerId)
424
- || a.label.localeCompare(b.label));
425
- for (let i = 0; i < items.length; i++) {
426
- const item = items[i];
427
- if (i === 0 || items[i - 1].profile.group !== item.profile.group) {
428
- qpItems.push({ type: 'separator', label: testConfigurationGroupNames[item.profile.group] });
429
- }
430
- qpItems.push(item);
431
- if (( lastRun.has(item.profile.profileId))) {
432
- selectedItems.push(item);
433
- }
434
- }
435
- const quickpick = quickInputService.createQuickPick();
436
- quickpick.title = ( localizeWithPath(
437
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
438
- 'testing.selectContinuousProfiles',
439
- 'Select profiles to run when files change:'
440
- ));
441
- quickpick.canSelectMany = true;
442
- quickpick.items = qpItems;
443
- quickpick.selectedItems = selectedItems;
444
- quickpick.show();
445
- return ( new Promise((resolve, reject) => {
446
- quickpick.onDidAccept(() => {
447
- resolve(( quickpick.selectedItems.map(i => i.profile)));
448
- quickpick.dispose();
449
- });
450
- quickpick.onDidHide(() => {
451
- resolve([]);
452
- quickpick.dispose();
453
- });
454
- }));
455
- }
456
- class StartContinuousRunAction extends Action2 {
457
- constructor() {
458
- super({
459
- id: "testing.startContinuousRun" ,
460
- title: ( localize2WithPath(
461
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
462
- 'testing.startContinuous',
463
- "Start Continuous Run"
464
- )),
465
- category,
466
- icon: testingTurnContinuousRunOn,
467
- menu: continuousMenus(false),
468
- });
469
- }
470
- async run(accessor, ...args) {
471
- const crs = accessor.get(ITestingContinuousRunService);
472
- const selected = await selectContinuousRunProfiles(crs, accessor.get(INotificationService), accessor.get(IQuickInputService), accessor.get(ITestProfileService).all());
473
- if (selected.length) {
474
- crs.start(selected);
475
- }
476
- }
477
- }
478
- class ExecuteSelectedAction extends ViewAction {
479
- constructor(options, group) {
480
- super({
481
- ...options,
482
- menu: [{
483
- id: MenuId.ViewTitle,
484
- order: group === 2
485
- ? 11
486
- : group === 4
487
- ? 12
488
- : 13 ,
489
- group: 'navigation',
490
- when: ( ContextKeyExpr.and(( ContextKeyExpr.equals('view', "workbench.view.testing" )), ( TestingContextKeys.isRunning.isEqualTo(false)), ( TestingContextKeys.capabilityToContextKey[group].isEqualTo(true))))
491
- }],
492
- category,
493
- viewId: "workbench.view.testing" ,
494
- });
495
- this.group = group;
496
- }
497
- runInView(accessor, view) {
498
- const { include, exclude } = view.getTreeIncludeExclude();
499
- return accessor.get(ITestService).runTests({ tests: include, exclude, group: this.group });
500
- }
501
- }
502
- class GetSelectedProfiles extends Action2 {
503
- constructor() {
504
- super({ id: "testing.getSelectedProfiles" , title: ( localizeWithPath(
505
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
506
- 'getSelectedProfiles',
507
- 'Get Selected Profiles'
508
- )) });
509
- }
510
- run(accessor) {
511
- const profiles = accessor.get(ITestProfileService);
512
- return ( [
513
- ...profiles.getGroupDefaultProfiles(2 ),
514
- ...profiles.getGroupDefaultProfiles(4 ),
515
- ...profiles.getGroupDefaultProfiles(8 ),
516
- ].map(p => ({
517
- controllerId: p.controllerId,
518
- label: p.label,
519
- kind: p.group & 8
520
- ? 3
521
- : p.group & 4
522
- ? 2
523
- : 1 ,
524
- })));
525
- }
526
- }
527
- class GetExplorerSelection extends ViewAction {
528
- constructor() {
529
- super({ id: "_testing.getExplorerSelection" , title: ( localizeWithPath(
530
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
531
- 'getExplorerSelection',
532
- 'Get Explorer Selection'
533
- )), viewId: "workbench.view.testing" });
534
- }
535
- runInView(_accessor, view) {
536
- const { include, exclude } = view.getTreeIncludeExclude(undefined, undefined, 'selected');
537
- const mapper = (i) => i.item.extId;
538
- return { include: ( include.map(mapper)), exclude: ( exclude.map(mapper)) };
539
- }
540
- }
541
- class RunSelectedAction extends ExecuteSelectedAction {
542
- constructor() {
543
- super({
544
- id: "testing.runSelected" ,
545
- title: LABEL_RUN_TESTS,
546
- icon: testingRunAllIcon,
547
- }, 2 );
548
- }
549
- }
550
- class DebugSelectedAction extends ExecuteSelectedAction {
551
- constructor() {
552
- super({
553
- id: "testing.debugSelected" ,
554
- title: LABEL_DEBUG_TESTS,
555
- icon: testingDebugAllIcon,
556
- }, 4 );
557
- }
558
- }
559
- class CoverageSelectedAction extends ExecuteSelectedAction {
560
- constructor() {
561
- super({
562
- id: "testing.coverageSelected" ,
563
- title: LABEL_COVERAGE_TESTS,
564
- icon: testingCoverageAllIcon,
565
- }, 8 );
566
- }
567
- }
568
- const showDiscoveringWhile = (progress, task) => {
569
- return progress.withProgress({
570
- location: 10 ,
571
- title: ( localizeWithPath(
572
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
573
- 'discoveringTests',
574
- 'Discovering Tests'
575
- )),
576
- }, () => task);
577
- };
578
- class RunOrDebugAllTestsAction extends Action2 {
579
- constructor(options, group, noTestsFoundError) {
580
- super({
581
- ...options,
582
- category,
583
- menu: [{
584
- id: MenuId.CommandPalette,
585
- when: ( TestingContextKeys.capabilityToContextKey[group].isEqualTo(true)),
586
- }]
587
- });
588
- this.group = group;
589
- this.noTestsFoundError = noTestsFoundError;
590
- }
591
- async run(accessor) {
592
- const testService = accessor.get(ITestService);
593
- const notifications = accessor.get(INotificationService);
594
- const roots = [...testService.collection.rootItems];
595
- if (!roots.length) {
596
- notifications.info(this.noTestsFoundError);
597
- return;
598
- }
599
- await testService.runTests({ tests: roots, group: this.group });
600
- }
601
- }
602
- class RunAllAction extends RunOrDebugAllTestsAction {
603
- constructor() {
604
- super({
605
- id: "testing.runAll" ,
606
- title: ( localizeWithPath(
607
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
608
- 'runAllTests',
609
- 'Run All Tests'
610
- )),
611
- icon: testingRunAllIcon,
612
- keybinding: {
613
- weight: 200 ,
614
- primary: KeyChord(2048 | 85 , 31 ),
615
- },
616
- }, 2 , ( localizeWithPath(
617
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
618
- 'noTestProvider',
619
- 'No tests found in this workspace. You may need to install a test provider extension'
620
- )));
621
- }
622
- }
623
- class DebugAllAction extends RunOrDebugAllTestsAction {
624
- constructor() {
625
- super({
626
- id: "testing.debugAll" ,
627
- title: ( localizeWithPath(
628
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
629
- 'debugAllTests',
630
- 'Debug All Tests'
631
- )),
632
- icon: testingDebugIcon,
633
- keybinding: {
634
- weight: 200 ,
635
- primary: KeyChord(2048 | 85 , 2048 | 31 ),
636
- },
637
- }, 4 , ( localizeWithPath(
638
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
639
- 'noDebugTestProvider',
640
- 'No debuggable tests found in this workspace. You may need to install a test provider extension'
641
- )));
642
- }
643
- }
644
- class CoverageAllAction extends RunOrDebugAllTestsAction {
645
- constructor() {
646
- super({
647
- id: "testing.coverageAll" ,
648
- title: ( localizeWithPath(
649
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
650
- 'runAllWithCoverage',
651
- 'Run All Tests with Coverage'
652
- )),
653
- icon: testingCoverageIcon,
654
- keybinding: {
655
- weight: 200 ,
656
- primary: KeyChord(2048 | 85 , 2048 | 1024 | 31 ),
657
- },
658
- }, 8 , ( localizeWithPath(
659
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
660
- 'noCoverageTestProvider',
661
- 'No tests with coverage runners found in this workspace. You may need to install a test provider extension'
662
- )));
663
- }
664
- }
665
- class CancelTestRunAction extends Action2 {
666
- constructor() {
667
- super({
668
- id: "testing.cancelRun" ,
669
- title: ( localize2WithPath(
670
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
671
- 'testing.cancelRun',
672
- 'Cancel Test Run'
673
- )),
674
- icon: testingCancelIcon,
675
- keybinding: {
676
- weight: 200 ,
677
- primary: KeyChord(2048 | 85 , 2048 | 54 ),
678
- },
679
- menu: {
680
- id: MenuId.ViewTitle,
681
- order: 11 ,
682
- group: 'navigation',
683
- when: ( ContextKeyExpr.and(( ContextKeyExpr.equals('view', "workbench.view.testing" )), ( ContextKeyExpr.equals(TestingContextKeys.isRunning.serialize(), true))))
684
- }
685
- });
686
- }
687
- async run(accessor) {
688
- const resultService = accessor.get(ITestResultService);
689
- const testService = accessor.get(ITestService);
690
- for (const run of resultService.results) {
691
- if (!run.completedAt) {
692
- testService.cancelTestRun(run.id);
693
- }
694
- }
695
- }
696
- }
697
- class TestingViewAsListAction extends ViewAction {
698
- constructor() {
699
- super({
700
- id: "testing.viewAsList" ,
701
- viewId: "workbench.view.testing" ,
702
- title: ( localize2WithPath(
703
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
704
- 'testing.viewAsList',
705
- 'View as List'
706
- )),
707
- toggled: ( TestingContextKeys.viewMode.isEqualTo("list" )),
708
- menu: {
709
- id: MenuId.ViewTitle,
710
- order: 18 ,
711
- group: 'viewAs',
712
- when: ( ContextKeyExpr.equals('view', "workbench.view.testing" ))
713
- }
714
- });
715
- }
716
- runInView(_accessor, view) {
717
- view.viewModel.viewMode = "list" ;
718
- }
719
- }
720
- class TestingViewAsTreeAction extends ViewAction {
721
- constructor() {
722
- super({
723
- id: "testing.viewAsTree" ,
724
- viewId: "workbench.view.testing" ,
725
- title: ( localize2WithPath(
726
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
727
- 'testing.viewAsTree',
728
- 'View as Tree'
729
- )),
730
- toggled: ( TestingContextKeys.viewMode.isEqualTo("true" )),
731
- menu: {
732
- id: MenuId.ViewTitle,
733
- order: 18 ,
734
- group: 'viewAs',
735
- when: ( ContextKeyExpr.equals('view', "workbench.view.testing" ))
736
- }
737
- });
738
- }
739
- runInView(_accessor, view) {
740
- view.viewModel.viewMode = "true" ;
741
- }
742
- }
743
- class TestingSortByStatusAction extends ViewAction {
744
- constructor() {
745
- super({
746
- id: "testing.sortByStatus" ,
747
- viewId: "workbench.view.testing" ,
748
- title: ( localize2WithPath(
749
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
750
- 'testing.sortByStatus',
751
- 'Sort by Status'
752
- )),
753
- toggled: ( TestingContextKeys.viewSorting.isEqualTo("status" )),
754
- menu: {
755
- id: MenuId.ViewTitle,
756
- order: 19 ,
757
- group: 'sortBy',
758
- when: ( ContextKeyExpr.equals('view', "workbench.view.testing" ))
759
- }
760
- });
761
- }
762
- runInView(_accessor, view) {
763
- view.viewModel.viewSorting = "status" ;
764
- }
765
- }
766
- class TestingSortByLocationAction extends ViewAction {
767
- constructor() {
768
- super({
769
- id: "testing.sortByLocation" ,
770
- viewId: "workbench.view.testing" ,
771
- title: ( localize2WithPath(
772
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
773
- 'testing.sortByLocation',
774
- 'Sort by Location'
775
- )),
776
- toggled: ( TestingContextKeys.viewSorting.isEqualTo("location" )),
777
- menu: {
778
- id: MenuId.ViewTitle,
779
- order: 19 ,
780
- group: 'sortBy',
781
- when: ( ContextKeyExpr.equals('view', "workbench.view.testing" ))
782
- }
783
- });
784
- }
785
- runInView(_accessor, view) {
786
- view.viewModel.viewSorting = "location" ;
787
- }
788
- }
789
- class TestingSortByDurationAction extends ViewAction {
790
- constructor() {
791
- super({
792
- id: "testing.sortByDuration" ,
793
- viewId: "workbench.view.testing" ,
794
- title: ( localize2WithPath(
795
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
796
- 'testing.sortByDuration',
797
- 'Sort by Duration'
798
- )),
799
- toggled: ( TestingContextKeys.viewSorting.isEqualTo("duration" )),
800
- menu: {
801
- id: MenuId.ViewTitle,
802
- order: 19 ,
803
- group: 'sortBy',
804
- when: ( ContextKeyExpr.equals('view', "workbench.view.testing" ))
805
- }
806
- });
807
- }
808
- runInView(_accessor, view) {
809
- view.viewModel.viewSorting = "duration" ;
810
- }
811
- }
812
- class ShowMostRecentOutputAction extends Action2 {
813
- constructor() {
814
- super({
815
- id: "testing.showMostRecentOutput" ,
816
- title: ( localize2WithPath(
817
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
818
- 'testing.showMostRecentOutput',
819
- 'Show Output'
820
- )),
821
- category,
822
- icon: Codicon.terminal,
823
- keybinding: {
824
- weight: 200 ,
825
- primary: KeyChord(2048 | 85 , 2048 | 45 ),
826
- },
827
- precondition: ( TestingContextKeys.hasAnyResults.isEqualTo(true)),
828
- menu: [{
829
- id: MenuId.ViewTitle,
830
- order: 16 ,
831
- group: 'navigation',
832
- when: ( ContextKeyExpr.equals('view', "workbench.view.testing" )),
833
- }, {
834
- id: MenuId.CommandPalette,
835
- when: ( TestingContextKeys.hasAnyResults.isEqualTo(true))
836
- }]
837
- });
838
- }
839
- async run(accessor) {
840
- const viewService = accessor.get(IViewsService);
841
- const testView = await viewService.openView("workbench.panel.testResults.view" , true);
842
- testView?.showLatestRun();
843
- }
844
- }
845
- class CollapseAllAction extends ViewAction {
846
- constructor() {
847
- super({
848
- id: "testing.collapseAll" ,
849
- viewId: "workbench.view.testing" ,
850
- title: ( localize2WithPath(
851
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
852
- 'testing.collapseAll',
853
- 'Collapse All Tests'
854
- )),
855
- icon: Codicon.collapseAll,
856
- menu: {
857
- id: MenuId.ViewTitle,
858
- order: 16 ,
859
- group: 'displayAction',
860
- when: ( ContextKeyExpr.equals('view', "workbench.view.testing" ))
861
- }
862
- });
863
- }
864
- runInView(_accessor, view) {
865
- view.viewModel.collapseAll();
866
- }
867
- }
868
- class ClearTestResultsAction extends Action2 {
869
- constructor() {
870
- super({
871
- id: "testing.clearTestResults" ,
872
- title: ( localize2WithPath(
873
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
874
- 'testing.clearResults',
875
- 'Clear All Results'
876
- )),
877
- category,
878
- icon: Codicon.clearAll,
879
- menu: [{
880
- id: MenuId.TestPeekTitle,
881
- }, {
882
- id: MenuId.CommandPalette,
883
- when: ( TestingContextKeys.hasAnyResults.isEqualTo(true)),
884
- }, {
885
- id: MenuId.ViewTitle,
886
- order: 17 ,
887
- group: 'displayAction',
888
- when: ( ContextKeyExpr.equals('view', "workbench.view.testing" ))
889
- }, {
890
- id: MenuId.ViewTitle,
891
- order: 17 ,
892
- group: 'navigation',
893
- when: ( ContextKeyExpr.equals('view', "workbench.panel.testResults.view" ))
894
- }],
895
- });
896
- }
897
- run(accessor) {
898
- accessor.get(ITestResultService).clear();
899
- }
900
- }
901
- class GoToTest extends Action2 {
902
- constructor() {
903
- super({
904
- id: "testing.editFocusedTest" ,
905
- title: ( localize2WithPath(
906
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
907
- 'testing.editFocusedTest',
908
- 'Go to Test'
909
- )),
910
- icon: Codicon.goToFile,
911
- menu: testItemInlineAndInContext(20 , ( TestingContextKeys.testItemHasUri.isEqualTo(true))),
912
- keybinding: {
913
- weight: 100 - 10,
914
- when: ( FocusedViewContext.isEqualTo("workbench.view.testing" )),
915
- primary: 3 | 512 ,
916
- },
917
- });
918
- }
919
- async run(accessor, element, preserveFocus) {
920
- if (!element) {
921
- const view = accessor.get(IViewsService).getActiveViewWithId("workbench.view.testing" );
922
- element = view?.focusedTreeElements[0];
923
- }
924
- if (element && element instanceof TestItemTreeElement) {
925
- accessor.get(ICommandService).executeCommand('vscode.revealTest', element.test.item.extId, preserveFocus);
926
- }
927
- }
928
- }
929
- class ExecuteTestAtCursor extends Action2 {
930
- constructor(options, group) {
931
- super({
932
- ...options,
933
- menu: [{
934
- id: MenuId.CommandPalette,
935
- when: hasAnyTestProvider,
936
- }, {
937
- id: MenuId.EditorContext,
938
- group: 'testing',
939
- order: group === 2 ? 11 : 12 ,
940
- when: ( ContextKeyExpr.and(
941
- TestingContextKeys.activeEditorHasTests,
942
- TestingContextKeys.capabilityToContextKey[group]
943
- )),
944
- }]
945
- });
946
- this.group = group;
947
- }
948
- async run(accessor) {
949
- const editorService = accessor.get(IEditorService);
950
- const activeEditorPane = editorService.activeEditorPane;
951
- const activeControl = editorService.activeTextEditorControl;
952
- if (!activeEditorPane || !activeControl) {
953
- return;
954
- }
955
- const position = activeControl?.getPosition();
956
- const model = activeControl?.getModel();
957
- if (!position || !model || !('uri' in model)) {
958
- return;
959
- }
960
- const testService = accessor.get(ITestService);
961
- const profileService = accessor.get(ITestProfileService);
962
- const uriIdentityService = accessor.get(IUriIdentityService);
963
- const progressService = accessor.get(IProgressService);
964
- const configurationService = accessor.get(IConfigurationService);
965
- let bestNodes = [];
966
- let bestRange;
967
- let bestNodesBefore = [];
968
- let bestRangeBefore;
969
- const saveBeforeTest = getTestingConfiguration(configurationService, "testing.saveBeforeTest" );
970
- if (saveBeforeTest) {
971
- await editorService.save({ editor: activeEditorPane.input, groupId: activeEditorPane.group.id });
972
- await testService.syncTests();
973
- }
974
- await showDiscoveringWhile(progressService, (async () => {
975
- for await (const test of testsInFile(testService, uriIdentityService, model.uri)) {
976
- if (!test.item.range || !(profileService.capabilitiesForTest(test) & this.group)) {
977
- continue;
978
- }
979
- const irange = Range.lift(test.item.range);
980
- if (irange.containsPosition(position)) {
981
- if (bestRange && Range.equalsRange(test.item.range, bestRange)) {
982
- if (!( bestNodes.some(b => TestId.isChild(b.item.extId, test.item.extId)))) {
983
- bestNodes.push(test);
984
- }
985
- }
986
- else {
987
- bestRange = irange;
988
- bestNodes = [test];
989
- }
990
- }
991
- else if (Position.isBefore(irange.getStartPosition(), position)) {
992
- if (!bestRangeBefore || bestRangeBefore.getStartPosition().isBefore(irange.getStartPosition())) {
993
- bestRangeBefore = irange;
994
- bestNodesBefore = [test];
995
- }
996
- else if (irange.equalsRange(bestRangeBefore) && !( bestNodesBefore.some(b => TestId.isChild(b.item.extId, test.item.extId)))) {
997
- bestNodesBefore.push(test);
998
- }
999
- }
1000
- }
1001
- })());
1002
- const testsToRun = bestNodes.length ? bestNodes : bestNodesBefore;
1003
- if (testsToRun.length) {
1004
- await testService.runTests({
1005
- group: this.group,
1006
- tests: bestNodes.length ? bestNodes : bestNodesBefore,
1007
- });
1008
- }
1009
- else if (isCodeEditor(activeControl)) {
1010
- MessageController.get(activeControl)?.showMessage(( localizeWithPath(
1011
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
1012
- 'noTestsAtCursor',
1013
- "No tests found here"
1014
- )), position);
1015
- }
1016
- }
1017
- }
1018
- class RunAtCursor extends ExecuteTestAtCursor {
1019
- constructor() {
1020
- super({
1021
- id: "testing.runAtCursor" ,
1022
- title: ( localize2WithPath(
1023
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
1024
- 'testing.runAtCursor',
1025
- 'Run Test at Cursor'
1026
- )),
1027
- category,
1028
- keybinding: {
1029
- weight: 200 ,
1030
- when: EditorContextKeys.editorTextFocus,
1031
- primary: KeyChord(2048 | 85 , 33 ),
1032
- },
1033
- }, 2 );
1034
- }
1035
- }
1036
- class DebugAtCursor extends ExecuteTestAtCursor {
1037
- constructor() {
1038
- super({
1039
- id: "testing.debugAtCursor" ,
1040
- title: ( localize2WithPath(
1041
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
1042
- 'testing.debugAtCursor',
1043
- 'Debug Test at Cursor'
1044
- )),
1045
- category,
1046
- keybinding: {
1047
- weight: 200 ,
1048
- when: EditorContextKeys.editorTextFocus,
1049
- primary: KeyChord(2048 | 85 , 2048 | 33 ),
1050
- },
1051
- }, 4 );
1052
- }
1053
- }
1054
- class CoverageAtCursor extends ExecuteTestAtCursor {
1055
- constructor() {
1056
- super({
1057
- id: "testing.coverageAtCursor" ,
1058
- title: ( localize2WithPath(
1059
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
1060
- 'testing.coverageAtCursor',
1061
- 'Run Test at Cursor with Coverage'
1062
- )),
1063
- category,
1064
- keybinding: {
1065
- weight: 200 ,
1066
- when: EditorContextKeys.editorTextFocus,
1067
- primary: KeyChord(2048 | 85 , 2048 | 1024 | 33 ),
1068
- },
1069
- }, 8 );
1070
- }
1071
- }
1072
- class ExecuteTestsUnderUriAction extends Action2 {
1073
- constructor(options, group) {
1074
- super({
1075
- ...options,
1076
- menu: [{
1077
- id: MenuId.ExplorerContext,
1078
- when: ( TestingContextKeys.capabilityToContextKey[group].isEqualTo(true)),
1079
- group: '6.5_testing',
1080
- order: ((group === 2 ? 11 : 12) ) + 0.1,
1081
- }],
1082
- });
1083
- this.group = group;
1084
- }
1085
- async run(accessor, uri) {
1086
- const testService = accessor.get(ITestService);
1087
- const notificationService = accessor.get(INotificationService);
1088
- const tests = await Iterable.asyncToArray(testsUnderUri(testService, accessor.get(IUriIdentityService), uri));
1089
- if (!tests.length) {
1090
- notificationService.notify({ message: ( localizeWithPath(
1091
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
1092
- 'noTests',
1093
- 'No tests found in the selected file or folder'
1094
- )), severity: Severity.Info });
1095
- return;
1096
- }
1097
- return testService.runTests({ tests, group: this.group });
1098
- }
1099
- }
1100
- class RunTestsUnderUri extends ExecuteTestsUnderUriAction {
1101
- constructor() {
1102
- super({
1103
- id: "testing.run.uri" ,
1104
- title: LABEL_RUN_TESTS,
1105
- category,
1106
- }, 2 );
1107
- }
1108
- }
1109
- class DebugTestsUnderUri extends ExecuteTestsUnderUriAction {
1110
- constructor() {
1111
- super({
1112
- id: "testing.debug.uri" ,
1113
- title: LABEL_DEBUG_TESTS,
1114
- category,
1115
- }, 4 );
1116
- }
1117
- }
1118
- class CoverageTestsUnderUri extends ExecuteTestsUnderUriAction {
1119
- constructor() {
1120
- super({
1121
- id: "testing.coverage.uri" ,
1122
- title: LABEL_COVERAGE_TESTS,
1123
- category,
1124
- }, 8 );
1125
- }
1126
- }
1127
- class ExecuteTestsInCurrentFile extends Action2 {
1128
- constructor(options, group) {
1129
- super({
1130
- ...options,
1131
- menu: [{
1132
- id: MenuId.CommandPalette,
1133
- when: ( TestingContextKeys.capabilityToContextKey[group].isEqualTo(true)),
1134
- }, {
1135
- id: MenuId.EditorContext,
1136
- group: 'testing',
1137
- order: ((group === 2 ? 11 : 12) ) + 0.1,
1138
- when: ( ContextKeyExpr.and(
1139
- TestingContextKeys.activeEditorHasTests,
1140
- TestingContextKeys.capabilityToContextKey[group]
1141
- )),
1142
- }],
1143
- });
1144
- this.group = group;
1145
- }
1146
- run(accessor) {
1147
- const control = accessor.get(IEditorService).activeTextEditorControl;
1148
- const position = control?.getPosition();
1149
- const model = control?.getModel();
1150
- if (!position || !model || !('uri' in model)) {
1151
- return;
1152
- }
1153
- const testService = accessor.get(ITestService);
1154
- const demandedUri = ( model.uri.toString());
1155
- const queue = [testService.collection.rootIds];
1156
- const discovered = [];
1157
- while (queue.length) {
1158
- for (const id of queue.pop()) {
1159
- const node = testService.collection.getNodeById(id);
1160
- if (node.item.uri?.toString() === demandedUri) {
1161
- discovered.push(node);
1162
- }
1163
- else {
1164
- queue.push(node.children);
1165
- }
1166
- }
1167
- }
1168
- if (discovered.length) {
1169
- return testService.runTests({
1170
- tests: discovered,
1171
- group: this.group,
1172
- });
1173
- }
1174
- if (isCodeEditor(control)) {
1175
- MessageController.get(control)?.showMessage(( localizeWithPath(
1176
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
1177
- 'noTestsInFile',
1178
- "No tests found in this file"
1179
- )), position);
1180
- }
1181
- return undefined;
1182
- }
1183
- }
1184
- class RunCurrentFile extends ExecuteTestsInCurrentFile {
1185
- constructor() {
1186
- super({
1187
- id: "testing.runCurrentFile" ,
1188
- title: ( localize2WithPath(
1189
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
1190
- 'testing.runCurrentFile',
1191
- 'Run Tests in Current File'
1192
- )),
1193
- category,
1194
- keybinding: {
1195
- weight: 200 ,
1196
- when: EditorContextKeys.editorTextFocus,
1197
- primary: KeyChord(2048 | 85 , 36 ),
1198
- },
1199
- }, 2 );
1200
- }
1201
- }
1202
- class DebugCurrentFile extends ExecuteTestsInCurrentFile {
1203
- constructor() {
1204
- super({
1205
- id: "testing.debugCurrentFile" ,
1206
- title: ( localize2WithPath(
1207
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
1208
- 'testing.debugCurrentFile',
1209
- 'Debug Tests in Current File'
1210
- )),
1211
- category,
1212
- keybinding: {
1213
- weight: 200 ,
1214
- when: EditorContextKeys.editorTextFocus,
1215
- primary: KeyChord(2048 | 85 , 2048 | 36 ),
1216
- },
1217
- }, 4 );
1218
- }
1219
- }
1220
- class CoverageCurrentFile extends ExecuteTestsInCurrentFile {
1221
- constructor() {
1222
- super({
1223
- id: "testing.coverageCurrentFile" ,
1224
- title: ( localize2WithPath(
1225
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
1226
- 'testing.coverageCurrentFile',
1227
- 'Run Tests with Coverage in Current File'
1228
- )),
1229
- category,
1230
- keybinding: {
1231
- weight: 200 ,
1232
- when: EditorContextKeys.editorTextFocus,
1233
- primary: KeyChord(2048 | 85 , 2048 | 1024 | 36 ),
1234
- },
1235
- }, 8 );
1236
- }
1237
- }
1238
- const discoverAndRunTests = async (collection, progress, ids, runTests) => {
1239
- const todo = Promise.all(( ids.map(p => expandAndGetTestById(collection, p))));
1240
- const tests = (await showDiscoveringWhile(progress, todo)).filter(isDefined);
1241
- return tests.length ? await runTests(tests) : undefined;
1242
- };
1243
- class RunOrDebugExtsByPath extends Action2 {
1244
- async run(accessor, ...args) {
1245
- const testService = accessor.get(ITestService);
1246
- await discoverAndRunTests(accessor.get(ITestService).collection, accessor.get(IProgressService), [...this.getTestExtIdsToRun(accessor, ...args)], tests => this.runTest(testService, tests));
1247
- }
1248
- }
1249
- class RunOrDebugFailedTests extends RunOrDebugExtsByPath {
1250
- constructor(options) {
1251
- super({
1252
- ...options,
1253
- menu: {
1254
- id: MenuId.CommandPalette,
1255
- when: hasAnyTestProvider,
1256
- },
1257
- });
1258
- }
1259
- getTestExtIdsToRun(accessor) {
1260
- const { results } = accessor.get(ITestResultService);
1261
- const ids = ( new Set());
1262
- for (let i = results.length - 1; i >= 0; i--) {
1263
- const resultSet = results[i];
1264
- for (const test of resultSet.tests) {
1265
- if (isFailedState(test.ownComputedState)) {
1266
- ids.add(test.item.extId);
1267
- }
1268
- else {
1269
- ids.delete(test.item.extId);
1270
- }
1271
- }
1272
- }
1273
- return ids;
1274
- }
1275
- }
1276
- class RunOrDebugLastRun extends RunOrDebugExtsByPath {
1277
- constructor(options) {
1278
- super({
1279
- ...options,
1280
- menu: {
1281
- id: MenuId.CommandPalette,
1282
- when: ( ContextKeyExpr.and(hasAnyTestProvider, ( TestingContextKeys.hasAnyResults.isEqualTo(true)))),
1283
- },
1284
- });
1285
- }
1286
- *getTestExtIdsToRun(accessor, runId) {
1287
- const resultService = accessor.get(ITestResultService);
1288
- const lastResult = runId ? resultService.results.find(r => r.id === runId) : resultService.results[0];
1289
- if (!lastResult) {
1290
- return;
1291
- }
1292
- for (const test of lastResult.request.targets) {
1293
- for (const testId of test.testIds) {
1294
- yield testId;
1295
- }
1296
- }
1297
- }
1298
- }
1299
- class ReRunFailedTests extends RunOrDebugFailedTests {
1300
- constructor() {
1301
- super({
1302
- id: "testing.reRunFailTests" ,
1303
- title: ( localize2WithPath(
1304
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
1305
- 'testing.reRunFailTests',
1306
- 'Rerun Failed Tests'
1307
- )),
1308
- category,
1309
- keybinding: {
1310
- weight: 200 ,
1311
- primary: KeyChord(2048 | 85 , 35 ),
1312
- },
1313
- });
1314
- }
1315
- runTest(service, internalTests) {
1316
- return service.runTests({
1317
- group: 2 ,
1318
- tests: internalTests,
1319
- });
1320
- }
1321
- }
1322
- class DebugFailedTests extends RunOrDebugFailedTests {
1323
- constructor() {
1324
- super({
1325
- id: "testing.debugFailTests" ,
1326
- title: ( localize2WithPath(
1327
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
1328
- 'testing.debugFailTests',
1329
- 'Debug Failed Tests'
1330
- )),
1331
- category,
1332
- keybinding: {
1333
- weight: 200 ,
1334
- primary: KeyChord(2048 | 85 , 2048 | 35 ),
1335
- },
1336
- });
1337
- }
1338
- runTest(service, internalTests) {
1339
- return service.runTests({
1340
- group: 4 ,
1341
- tests: internalTests,
1342
- });
1343
- }
1344
- }
1345
- class ReRunLastRun extends RunOrDebugLastRun {
1346
- constructor() {
1347
- super({
1348
- id: "testing.reRunLastRun" ,
1349
- title: ( localize2WithPath(
1350
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
1351
- 'testing.reRunLastRun',
1352
- 'Rerun Last Run'
1353
- )),
1354
- category,
1355
- keybinding: {
1356
- weight: 200 ,
1357
- primary: KeyChord(2048 | 85 , 42 ),
1358
- },
1359
- });
1360
- }
1361
- runTest(service, internalTests) {
1362
- return service.runTests({
1363
- group: 2 ,
1364
- tests: internalTests,
1365
- });
1366
- }
1367
- }
1368
- class DebugLastRun extends RunOrDebugLastRun {
1369
- constructor() {
1370
- super({
1371
- id: "testing.debugLastRun" ,
1372
- title: ( localize2WithPath(
1373
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
1374
- 'testing.debugLastRun',
1375
- 'Debug Last Run'
1376
- )),
1377
- category,
1378
- keybinding: {
1379
- weight: 200 ,
1380
- primary: KeyChord(2048 | 85 , 2048 | 42 ),
1381
- },
1382
- });
1383
- }
1384
- runTest(service, internalTests) {
1385
- return service.runTests({
1386
- group: 4 ,
1387
- tests: internalTests,
1388
- });
1389
- }
1390
- }
1391
- class CoverageLastRun extends RunOrDebugLastRun {
1392
- constructor() {
1393
- super({
1394
- id: "testing.coverageLastRun" ,
1395
- title: ( localize2WithPath(
1396
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
1397
- 'testing.coverageLastRun',
1398
- 'Rerun Last Run with Coverage'
1399
- )),
1400
- category,
1401
- keybinding: {
1402
- weight: 200 ,
1403
- primary: KeyChord(2048 | 85 , 2048 | 1024 | 42 ),
1404
- },
1405
- });
1406
- }
1407
- runTest(service, internalTests) {
1408
- return service.runTests({
1409
- group: 8 ,
1410
- tests: internalTests,
1411
- });
1412
- }
1413
- }
1414
- class SearchForTestExtension extends Action2 {
1415
- constructor() {
1416
- super({
1417
- id: "testing.searchForTestExtension" ,
1418
- title: ( localize2WithPath(
1419
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
1420
- 'testing.searchForTestExtension',
1421
- 'Search for Test Extension'
1422
- )),
1423
- });
1424
- }
1425
- async run(accessor) {
1426
- const paneCompositeService = accessor.get(IPaneCompositePartService);
1427
- const viewlet = (await paneCompositeService.openPaneComposite(VIEWLET_ID, 0 , true))?.getViewPaneContainer();
1428
- viewlet.search('@category:"testing"');
1429
- viewlet.focus();
1430
- }
1431
- }
1432
- class OpenOutputPeek extends Action2 {
1433
- constructor() {
1434
- super({
1435
- id: "testing.openOutputPeek" ,
1436
- title: ( localize2WithPath(
1437
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
1438
- 'testing.openOutputPeek',
1439
- 'Peek Output'
1440
- )),
1441
- category,
1442
- keybinding: {
1443
- weight: 200 ,
1444
- primary: KeyChord(2048 | 85 , 2048 | 43 ),
1445
- },
1446
- menu: {
1447
- id: MenuId.CommandPalette,
1448
- when: ( TestingContextKeys.hasAnyResults.isEqualTo(true)),
1449
- },
1450
- });
1451
- }
1452
- async run(accessor) {
1453
- accessor.get(ITestingPeekOpener).open();
1454
- }
1455
- }
1456
- class ToggleInlineTestOutput extends Action2 {
1457
- constructor() {
1458
- super({
1459
- id: "testing.toggleInlineTestOutput" ,
1460
- title: ( localize2WithPath(
1461
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
1462
- 'testing.toggleInlineTestOutput',
1463
- 'Toggle Inline Test Output'
1464
- )),
1465
- category,
1466
- keybinding: {
1467
- weight: 200 ,
1468
- primary: KeyChord(2048 | 85 , 2048 | 39 ),
1469
- },
1470
- menu: {
1471
- id: MenuId.CommandPalette,
1472
- when: ( TestingContextKeys.hasAnyResults.isEqualTo(true)),
1473
- },
1474
- });
1475
- }
1476
- async run(accessor) {
1477
- const testService = accessor.get(ITestService);
1478
- testService.showInlineOutput.value = !testService.showInlineOutput.value;
1479
- }
1480
- }
1481
- const refreshMenus = (whenIsRefreshing) => [
1482
- {
1483
- id: MenuId.TestItem,
1484
- group: 'inline',
1485
- order: 10 ,
1486
- when: ( ContextKeyExpr.and(( TestingContextKeys.canRefreshTests.isEqualTo(true)), ( TestingContextKeys.isRefreshingTests.isEqualTo(whenIsRefreshing)))),
1487
- },
1488
- {
1489
- id: MenuId.ViewTitle,
1490
- group: 'navigation',
1491
- order: 10 ,
1492
- when: ( ContextKeyExpr.and(( ContextKeyExpr.equals('view', "workbench.view.testing" )), ( TestingContextKeys.canRefreshTests.isEqualTo(true)), ( TestingContextKeys.isRefreshingTests.isEqualTo(whenIsRefreshing)))),
1493
- },
1494
- {
1495
- id: MenuId.CommandPalette,
1496
- when: ( TestingContextKeys.canRefreshTests.isEqualTo(true)),
1497
- },
1498
- ];
1499
- class RefreshTestsAction extends Action2 {
1500
- constructor() {
1501
- super({
1502
- id: "testing.refreshTests" ,
1503
- title: ( localize2WithPath(
1504
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
1505
- 'testing.refreshTests',
1506
- 'Refresh Tests'
1507
- )),
1508
- category,
1509
- icon: testingRefreshTests,
1510
- keybinding: {
1511
- weight: 200 ,
1512
- primary: KeyChord(2048 | 85 , 2048 | 48 ),
1513
- when: ( TestingContextKeys.canRefreshTests.isEqualTo(true)),
1514
- },
1515
- menu: refreshMenus(false),
1516
- });
1517
- }
1518
- async run(accessor, ...elements) {
1519
- const testService = accessor.get(ITestService);
1520
- const progressService = accessor.get(IProgressService);
1521
- const controllerIds = distinct(( elements.filter(isDefined).map(e => e.test.controllerId)));
1522
- return progressService.withProgress({ location: "workbench.view.extension.test" }, async () => {
1523
- if (controllerIds.length) {
1524
- await Promise.all(( controllerIds.map(id => testService.refreshTests(id))));
1525
- }
1526
- else {
1527
- await testService.refreshTests();
1528
- }
1529
- });
1530
- }
1531
- }
1532
- class CancelTestRefreshAction extends Action2 {
1533
- constructor() {
1534
- super({
1535
- id: "testing.cancelTestRefresh" ,
1536
- title: ( localize2WithPath(
1537
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
1538
- 'testing.cancelTestRefresh',
1539
- 'Cancel Test Refresh'
1540
- )),
1541
- category,
1542
- icon: testingCancelRefreshTests,
1543
- menu: refreshMenus(true),
1544
- });
1545
- }
1546
- async run(accessor) {
1547
- accessor.get(ITestService).cancelRefreshTests();
1548
- }
1549
- }
1550
- class CleareCoverage extends Action2 {
1551
- constructor() {
1552
- super({
1553
- id: "testing.coverage.close" ,
1554
- title: ( localize2WithPath(
1555
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
1556
- 'testing.clearCoverage',
1557
- 'Clear Coverage'
1558
- )),
1559
- icon: widgetClose,
1560
- category,
1561
- menu: [{
1562
- id: MenuId.ViewTitle,
1563
- group: 'navigation',
1564
- order: 10 ,
1565
- when: ( ContextKeyExpr.equals('view', "workbench.view.testCoverage" ))
1566
- }, {
1567
- id: MenuId.CommandPalette,
1568
- when: ( TestingContextKeys.isTestCoverageOpen.isEqualTo(true)),
1569
- }]
1570
- });
1571
- }
1572
- run(accessor) {
1573
- accessor.get(ITestCoverageService).closeCoverage();
1574
- }
1575
- }
1576
- class OpenCoverage extends Action2 {
1577
- constructor() {
1578
- super({
1579
- id: "testing.openCoverage" ,
1580
- title: ( localize2WithPath(
1581
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
1582
- 'testing.openCoverage',
1583
- 'Open Coverage'
1584
- )),
1585
- category,
1586
- menu: [{
1587
- id: MenuId.CommandPalette,
1588
- when: ( TestingContextKeys.hasAnyResults.isEqualTo(true)),
1589
- }]
1590
- });
1591
- }
1592
- run(accessor) {
1593
- const results = accessor.get(ITestResultService).results;
1594
- const task = results.length && results[0].tasks.find(r => r.coverage);
1595
- if (!task) {
1596
- const notificationService = accessor.get(INotificationService);
1597
- notificationService.info(( localizeWithPath(
1598
- 'vs/workbench/contrib/testing/browser/testExplorerActions',
1599
- 'testing.noCoverage',
1600
- 'No coverage information available on the last test run.'
1601
- )));
1602
- return;
1603
- }
1604
- accessor.get(ITestCoverageService).openCoverage(task, true);
1605
- }
1606
- }
1607
- const allTestActions = [
1608
- CancelTestRefreshAction,
1609
- CancelTestRunAction,
1610
- ClearTestResultsAction,
1611
- CleareCoverage,
1612
- CollapseAllAction,
1613
- ConfigureTestProfilesAction,
1614
- ContinuousRunTestAction,
1615
- ContinuousRunUsingProfileTestAction,
1616
- CoverageAction,
1617
- CoverageAllAction,
1618
- CoverageAtCursor,
1619
- CoverageCurrentFile,
1620
- CoverageLastRun,
1621
- CoverageSelectedAction,
1622
- CoverageTestsUnderUri,
1623
- DebugAction,
1624
- DebugAllAction,
1625
- DebugAtCursor,
1626
- DebugCurrentFile,
1627
- DebugFailedTests,
1628
- DebugLastRun,
1629
- DebugSelectedAction,
1630
- DebugTestsUnderUri,
1631
- GetExplorerSelection,
1632
- GetSelectedProfiles,
1633
- GoToTest,
1634
- HideTestAction,
1635
- OpenCoverage,
1636
- OpenOutputPeek,
1637
- RefreshTestsAction,
1638
- ReRunFailedTests,
1639
- ReRunLastRun,
1640
- RunAction,
1641
- RunAllAction,
1642
- RunAtCursor,
1643
- RunCurrentFile,
1644
- RunSelectedAction,
1645
- RunTestsUnderUri,
1646
- RunUsingProfileAction,
1647
- SearchForTestExtension,
1648
- SelectDefaultTestProfiles,
1649
- ShowMostRecentOutputAction,
1650
- StartContinuousRunAction,
1651
- StopContinuousRunAction,
1652
- TestingSortByDurationAction,
1653
- TestingSortByLocationAction,
1654
- TestingSortByStatusAction,
1655
- TestingViewAsListAction,
1656
- TestingViewAsTreeAction,
1657
- ToggleInlineTestOutput,
1658
- UnhideAllTestsAction,
1659
- UnhideTestAction,
1660
- ];
1661
-
1662
- export { CancelTestRefreshAction, CancelTestRunAction, ClearTestResultsAction, CleareCoverage, CollapseAllAction, ConfigureTestProfilesAction, ContinuousRunTestAction, ContinuousRunUsingProfileTestAction, CoverageAction, CoverageAllAction, CoverageAtCursor, CoverageCurrentFile, CoverageLastRun, CoverageSelectedAction, DebugAction, DebugAllAction, DebugAtCursor, DebugCurrentFile, DebugFailedTests, DebugLastRun, DebugSelectedAction, GetExplorerSelection, GetSelectedProfiles, GoToTest, HideTestAction, OpenCoverage, OpenOutputPeek, ReRunFailedTests, ReRunLastRun, RefreshTestsAction, RunAction, RunAllAction, RunAtCursor, RunCurrentFile, RunSelectedAction, RunUsingProfileAction, SearchForTestExtension, SelectDefaultTestProfiles, ShowMostRecentOutputAction, TestingSortByDurationAction, TestingSortByLocationAction, TestingSortByStatusAction, TestingViewAsListAction, TestingViewAsTreeAction, ToggleInlineTestOutput, UnhideAllTestsAction, UnhideTestAction, allTestActions, discoverAndRunTests };