Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep testing configuration alive after losing focus #4316

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/test_plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,6 @@ class FailingTests(unittest.TestCase):
- [ ] `Run Test` works
- [ ] `Debug Test` works
- [ ] Module/suite setup methods are also run (run the `test_setup` method to verify)
- [ ] `Configure Unit Tests` works
- [ ] quick pick for framework (and its settings)
- [ ] selected framework enabled in workspace settings
- [ ] framework's config added (and old config removed)
- [ ] other frameworks disabled in workspace settings

#### [`pytest`](https://code.visualstudio.com/docs/python/unit-testing#_pytest-configuration-settings)
```python
Expand Down Expand Up @@ -326,5 +321,11 @@ def test_failure():
- [ ] `Run Unit Test Method ...` works
- [ ] `View Unit Test Output` works
- [ ] After having at least one failure, `Run Failed Tests` works
- [ ] `Configure Unit Tests` works
- [ ] quick pick for framework (and its settings)
- [ ] selected framework enabled in workspace settings
- [ ] framework's config added (and old config removed)
- [ ] other frameworks disabled in workspace settings
- [ ] `Configure Unit Tests` does not close if it loses focus

</details>
1 change: 1 addition & 0 deletions news/1 Enhancements/4288.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Keep testing configuration alive when losing UI focus.
11 changes: 8 additions & 3 deletions src/client/unittests/common/managers/testConfigurationManager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as path from 'path';
import { OutputChannel, QuickPickItem, Uri, window } from 'vscode';
import { OutputChannel, QuickPickItem, Uri } from 'vscode';
import { IApplicationShell } from '../../../common/application/types';
import { IInstaller, IOutputChannel, Product } from '../../../common/types';
import { createDeferred } from '../../../common/utils/async';
import { getSubDirectories } from '../../../common/utils/fs';
Expand Down Expand Up @@ -38,6 +39,7 @@ export abstract class TestConfigurationManager implements ITestConfigurationMana
}
protected selectTestDir(rootDir: string, subDirs: string[], customOptions: QuickPickItem[] = []): Promise<string> {
const options = {
ignoreFocusOut: true,
matchOnDescription: true,
matchOnDetail: true,
placeHolder: 'Select the directory containing the unit tests'
Expand All @@ -59,7 +61,8 @@ export abstract class TestConfigurationManager implements ITestConfigurationMana
items = [{ label: '.', description: 'Root directory' }, ...items];
items = customOptions.concat(items);
const def = createDeferred<string>();
window.showQuickPick(items, options).then(item => {
const appShell = this.serviceContainer.get<IApplicationShell>(IApplicationShell);
appShell.showQuickPick(items, options).then(item => {
if (!item) {
return def.resolve();
}
Expand All @@ -72,6 +75,7 @@ export abstract class TestConfigurationManager implements ITestConfigurationMana

protected selectTestFilePattern(): Promise<string> {
const options = {
ignoreFocusOut: true,
matchOnDescription: true,
matchOnDetail: true,
placeHolder: 'Select the pattern to identify test files'
Expand All @@ -85,7 +89,8 @@ export abstract class TestConfigurationManager implements ITestConfigurationMana
];

const def = createDeferred<string>();
window.showQuickPick(items, options).then(item => {
const appShell = this.serviceContainer.get<IApplicationShell>(IApplicationShell);
appShell.showQuickPick(items, options).then(item => {
if (!item) {
return def.resolve();
}
Expand Down
7 changes: 3 additions & 4 deletions src/client/unittests/common/testUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { inject, injectable, named } from 'inversify';
import * as path from 'path';
import { Uri, window, workspace } from 'vscode';
import { Uri, workspace } from 'vscode';
import { IApplicationShell, ICommandManager } from '../../common/application/types';
import * as constants from '../../common/constants';
import { IUnitTestSettings, Product } from '../../common/types';
Expand All @@ -9,14 +9,13 @@ import { CommandSource } from './constants';
import { TestFlatteningVisitor } from './testVisitors/flatteningVisitor';
import { ITestsHelper, ITestVisitor, TestFile, TestFolder, TestProvider, Tests, TestSettingsPropertyNames, TestsToRun, UnitTestProduct } from './types';

export async function selectTestWorkspace(): Promise<Uri | undefined> {
export async function selectTestWorkspace(appShell: IApplicationShell): Promise<Uri | undefined> {
if (!Array.isArray(workspace.workspaceFolders) || workspace.workspaceFolders.length === 0) {
return undefined;
} else if (workspace.workspaceFolders.length === 1) {
return workspace.workspaceFolders[0].uri;
} else {
// tslint:disable-next-line:no-any prefer-type-cast
const workspaceFolder = await (window as any).showWorkspaceFolderPick({ placeHolder: 'Select a workspace' });
const workspaceFolder = await appShell.showWorkspaceFolderPick({ placeHolder: 'Select a workspace' });
return workspaceFolder ? workspaceFolder.uri : undefined;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/client/unittests/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class UnitTestConfigurationService implements IUnitTestConfigurationServi
detail: 'https://nose.readthedocs.io/'
}];
const options = {
ignoreFocusOut: true,
matchOnDescription: true,
matchOnDetail: true,
placeHolder: placeHolderMessage
Expand Down
8 changes: 5 additions & 3 deletions src/client/unittests/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
OutputChannel, TextDocument, Uri, window
} from 'vscode';
import {
ICommandManager, IDocumentManager, IWorkspaceService
IApplicationShell, ICommandManager, IDocumentManager, IWorkspaceService
} from '../common/application/types';
import * as constants from '../common/constants';
import '../common/extensions';
Expand Down Expand Up @@ -89,7 +89,8 @@ export class UnitTestManagementService implements IUnitTestManagementService, Di
const wkspaceFolder = this.workspaceService.getWorkspaceFolder(resource);
wkspace = wkspaceFolder ? wkspaceFolder.uri : undefined;
} else {
wkspace = await selectTestWorkspace();
const appShell = this.serviceContainer.get<IApplicationShell>(IApplicationShell);
wkspace = await selectTestWorkspace(appShell);
}
if (!wkspace) {
return;
Expand Down Expand Up @@ -322,7 +323,8 @@ export class UnitTestManagementService implements IUnitTestManagementService, Di
const wkspaceFolder = this.workspaceService.getWorkspaceFolder(resource);
wkspace = wkspaceFolder ? wkspaceFolder.uri : undefined;
} else {
wkspace = await selectTestWorkspace();
const appShell = this.serviceContainer.get<IApplicationShell>(IApplicationShell);
wkspace = await selectTestWorkspace(appShell);
}
if (!wkspace) {
return;
Expand Down