Skip to content

Commit

Permalink
testing: complete test run experience update
Browse files Browse the repository at this point in the history
Fixes #127096
  • Loading branch information
connor4312 committed Jul 14, 2021
1 parent fa9255c commit e4ac0cd
Show file tree
Hide file tree
Showing 12 changed files with 362 additions and 126 deletions.
9 changes: 4 additions & 5 deletions src/vs/workbench/api/common/extHostTesting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,8 @@ export class ExtHostTesting implements ExtHostTestingShape {
await this.proxy.$runTests({
targets: [{
testIds: req.tests.map(t => t.id),
configGroup: configGroupToBitset[config.group],
configLabel: config.label,
configId: config.configId,
profileGroup: configGroupToBitset[config.group],
profileId: config.configId,
controllerId: config.controllerId,
}],
exclude: req.exclude
Expand Down Expand Up @@ -256,7 +255,7 @@ export class ExtHostTesting implements ExtHostTestingShape {
const tracker = this.runTracker.prepareForMainThreadTestRun(publicReq, TestRunDto.fromInternal(req), token);

try {
configuration.runHandler(publicReq, token);
await configuration.runHandler(publicReq, token);
} finally {
if (tracker.isRunning && !token.isCancellationRequested) {
await Event.toPromise(tracker.onEnd);
Expand Down Expand Up @@ -866,7 +865,7 @@ export class TestRunConfigurationImpl implements vscode.TestRunConfiguration {
}

this.#proxy.$publishTestRunConfig({
configId,
profileId: configId,
controllerId,
label: _label,
group: groupBitset,
Expand Down
92 changes: 83 additions & 9 deletions src/vs/workbench/contrib/testing/browser/testExplorerActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@ const enum ActionOrder {
Run = 10,
Debug,
Coverage,
RunUsing,
AutoRun,

// Submenu:
Collapse,
DisplayMode,
Sort,
GoToTest,
HideTest,
}

const hasAnyTestProvider = ContextKeyGreaterExpr.create(TestingContextKeys.providerCount.key, 0);
Expand Down Expand Up @@ -90,6 +93,7 @@ export class UnhideTestAction extends Action2 {
title: localize('unhideTest', 'Unhide Test'),
menu: {
id: MenuId.TestItem,
order: ActionOrder.HideTest,
when: TestingContextKeys.testItemIsHidden.isEqualTo(true)
},
});
Expand Down Expand Up @@ -130,6 +134,46 @@ export class DebugAction extends Action2 {
}
}

export class RunUsingProfileAction extends Action2 {
public static readonly ID = 'testing.runUsing';
constructor() {
super({
id: RunUsingProfileAction.ID,
title: localize('testing.runUsing', 'Execute Using Profile...'),
icon: icons.testingDebugIcon,
menu: {
id: MenuId.TestItem,
order: ActionOrder.RunUsing,
when: TestingContextKeys.hasNonDefaultProfile.isEqualTo(true),
},
});
}

public override async run(acessor: ServicesAccessor, ...elements: IActionableTestTreeElement[]): Promise<any> {
const testElements = elements.filter((e): e is TestItemTreeElement => e instanceof TestItemTreeElement);
if (testElements.length === 0) {
return;
}

const commandService = acessor.get(ICommandService);
const testService = acessor.get(ITestService);
const controllerId = testElements[0].test.controllerId;
const profile: ITestRunConfiguration | undefined = await commandService.executeCommand('vscode.pickTestProfile', { onlyControllerId: controllerId });
if (!profile) {
return;
}

testService.runResolvedTests({
targets: [{
profileGroup: profile.group,
profileId: profile.profileId,
controllerId: profile.controllerId,
testIds: testElements.filter(t => controllerId === t.test.controllerId).map(t => t.test.item.extId)
}]
});
}
}

export class RunAction extends Action2 {
public static readonly ID = 'testing.run';
constructor() {
Expand Down Expand Up @@ -157,12 +201,38 @@ export class RunAction extends Action2 {
}
}

export class ConfigureTestsAction extends Action2 {
public static readonly ID = 'testing.configureTests';
export class SelectDefaultTestProfiles extends Action2 {
public static readonly ID = 'testing.selectDefaultTestProfiles';
constructor() {
super({
id: SelectDefaultTestProfiles.ID,
title: localize('testing.selectDefaultTestProfiles', 'Select Default Profile'),
icon: icons.testingUpdateConfiguration,
category,
});
}

public override async run(acessor: ServicesAccessor, onlyGroup: TestRunConfigurationBitset) {
const commands = acessor.get(ICommandService);
const testConfigurationService = acessor.get(ITestConfigurationService);
const configurations = await commands.executeCommand<ITestRunConfiguration[]>('vscode.pickMultipleTestProfiles', {
showConfigureButtons: false,
selected: testConfigurationService.getGroupDefaultConfigurations(onlyGroup),
onlyGroup,
});

if (configurations?.length) {
testConfigurationService.setGroupDefaultConfigurations(onlyGroup, configurations);
}
}
}

export class ConfigureTestProfilesAction extends Action2 {
public static readonly ID = 'testing.configureProfile';
constructor() {
super({
id: ConfigureTestsAction.ID,
title: localize('testing.configureTests', 'Configure Tests'),
id: ConfigureTestProfilesAction.ID,
title: localize('testing.configureProfile', 'Configure Test Profiles'),
icon: icons.testingUpdateConfiguration,
f1: true,
category,
Expand All @@ -173,17 +243,18 @@ export class ConfigureTestsAction extends Action2 {
});
}

public override async run(acessor: ServicesAccessor) {
public override async run(acessor: ServicesAccessor, onlyGroup?: TestRunConfigurationBitset) {
const commands = acessor.get(ICommandService);
const testConfigurationService = acessor.get(ITestConfigurationService);
const configuration = await commands.executeCommand<ITestRunConfiguration>('vscode.pickTestConfiguration', {
placeholder: localize('configureTests', 'Select a configuration to update'),
const configuration = await commands.executeCommand<ITestRunConfiguration>('vscode.pickTestProfile', {
placeholder: localize('configureProfile', 'Select a profile to update'),
showConfigureButtons: false,
onlyConfigurable: true,
onlyGroup,
});

if (configuration) {
testConfigurationService.configure(configuration.controllerId, configuration.configId);
testConfigurationService.configure(configuration.controllerId, configuration.profileId);
}
}
}
Expand Down Expand Up @@ -569,6 +640,7 @@ export class GoToTest extends Action2 {
menu: {
id: MenuId.TestItem,
when: TestingContextKeys.testItemHasUri.isEqualTo(true),
order: ActionOrder.GoToTest,
},
keybinding: {
weight: KeybindingWeight.EditorContrib - 10,
Expand Down Expand Up @@ -1088,7 +1160,7 @@ export const allTestActions = [
CancelTestRunAction,
ClearTestResultsAction,
CollapseAllAction,
ConfigureTestsAction,
ConfigureTestProfilesAction,
DebugAction,
DebugAllAction,
DebugAtCursor,
Expand All @@ -1106,7 +1178,9 @@ export const allTestActions = [
RunAtCursor,
RunCurrentFile,
RunSelectedAction,
RunUsingProfileAction,
SearchForTestExtension,
SelectDefaultTestProfiles,
ShowMostRecentOutputAction,
TestingSortByLocationAction,
TestingSortByStatusAction,
Expand Down
Loading

0 comments on commit e4ac0cd

Please sign in to comment.