Skip to content

Commit 111e58c

Browse files
authored
Use built-in refresh tests mechanism (#19035)
* Fix restartLS command disposal * Use built-in refresh tests mechanism * Accidental testing.reRunFailTests deletion
1 parent 3164b3e commit 111e58c

File tree

8 files changed

+17
-96
lines changed

8 files changed

+17
-96
lines changed

news/2 Fixes/19012.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use built-in test refresh button.

package.json

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -327,27 +327,6 @@
327327
"icon": "$(refresh)",
328328
"title": "%python.command.python.refreshTensorBoard.title%"
329329
},
330-
{
331-
"category": "Test",
332-
"command": "python.refreshTests",
333-
"icon": "$(refresh)",
334-
"title": "%python.command.python.refreshTests.title%"
335-
},
336-
{
337-
"category": "Test",
338-
"command": "python.refreshingTests",
339-
"icon": {
340-
"dark": "resources/dark/discovering-tests.svg",
341-
"light": "resources/light/discovering-tests.svg"
342-
},
343-
"title": "%python.command.python.refreshingTests.title%"
344-
},
345-
{
346-
"category": "Test",
347-
"command": "python.stopRefreshingTests",
348-
"icon": "$(beaker-stop)",
349-
"title": "%python.command.python.stopRefreshingTests.title%"
350-
},
351330
{
352331
"category": "Python",
353332
"command": "python.reportIssue",
@@ -1607,30 +1586,6 @@
16071586
"title": "%python.command.python.refreshTensorBoard.title%",
16081587
"when": "!virtualWorkspace && shellExecutionSupported"
16091588
},
1610-
{
1611-
"category": "Test",
1612-
"command": "python.refreshTests",
1613-
"icon": "$(refresh)",
1614-
"title": "%python.command.python.refreshTests.title%",
1615-
"when": "!virtualWorkspace && shellExecutionSupported"
1616-
},
1617-
{
1618-
"category": "Test",
1619-
"command": "python.refreshingTests",
1620-
"icon": {
1621-
"dark": "resources/dark/discovering-tests.svg",
1622-
"light": "resources/light/discovering-tests.svg"
1623-
},
1624-
"title": "%python.command.python.refreshingTests.title%",
1625-
"when": "!virtualWorkspace && shellExecutionSupported"
1626-
},
1627-
{
1628-
"category": "Test",
1629-
"command": "python.stopRefreshingTests",
1630-
"icon": "$(beaker-stop)",
1631-
"title": "%python.command.python.stopRefreshingTests.title%",
1632-
"when": "!virtualWorkspace && shellExecutionSupported"
1633-
},
16341589
{
16351590
"category": "Python",
16361591
"command": "python.reportIssue",
@@ -1747,21 +1702,6 @@
17471702
}
17481703
],
17491704
"view/title": [
1750-
{
1751-
"command": "python.refreshTests",
1752-
"when": "view == workbench.view.testing && !refreshingTests && !virtualWorkspace && shellExecutionSupported",
1753-
"group": "navigation@0"
1754-
},
1755-
{
1756-
"command": "python.refreshingTests",
1757-
"when": "view == workbench.view.testing && refreshingTests && !virtualWorkspace && shellExecutionSupported",
1758-
"group": "navigation@0"
1759-
},
1760-
{
1761-
"command": "python.stopRefreshingTests",
1762-
"when": "view == workbench.view.testing && refreshingTests && !virtualWorkspace && shellExecutionSupported",
1763-
"group": "navigation@0"
1764-
},
17651705
{
17661706
"command": "testing.reRunFailTests",
17671707
"when": "view == workbench.view.testing && hasFailedTests && !virtualWorkspace && shellExecutionSupported",

package.nls.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
"python.command.python.viewOutput.title": "Show Output",
1212
"python.command.python.viewLanguageServerOutput.title": "Show Language Server Output",
1313
"python.command.python.configureTests.title": "Configure Tests",
14-
"python.command.python.refreshTests.title": "Refresh Tests",
15-
"python.command.python.refreshingTests.title": "Refreshing Tests",
16-
"python.command.python.stopRefreshingTests.title": "Stop Refreshing Tests",
1714
"python.command.testing.rerunFailedTests.title": "Rerun Failed Tests",
1815
"python.command.python.execSelectionInTerminal.title": "Run Selection/Line in Python Terminal",
1916
"python.command.python.execSelectionInDjangoShell.title": "Run Selection/Line in Django Shell",

package.nls.zh-cn.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
"python.command.python.viewOutput.title": "显示输出",
99
"python.command.python.viewLanguageServerOutput.title": "显示语言服务器输出",
1010
"python.command.python.configureTests.title": "配置单元测试",
11-
"python.command.python.refreshTests.title": "刷新单元测试",
12-
"python.command.python.refreshingTests.title": "正在刷新单元测试",
13-
"python.command.python.stopRefreshingTests.title": "停止刷新单元测试",
1411
"python.command.testing.rerunFailedTests.title": "重新进行出错的单元测试",
1512
"python.command.python.execSelectionInTerminal.title": "在 Python 终端中运行选定内容/行",
1613
"python.command.python.execSelectionInDjangoShell.title": "在 Django Shell 中运行选定内容/行",

src/client/common/application/commands.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ export interface ICommandNameArgumentTypeMapping extends ICommandNameWithoutArgu
9494
[Commands.Exec_In_Terminal_Icon]: [undefined, Uri];
9595
[Commands.Debug_In_Terminal]: [Uri];
9696
[Commands.Tests_Configure]: [undefined, undefined | CommandSource, undefined | Uri];
97-
[Commands.Test_Refresh]: [undefined, undefined | CommandSource, undefined | Uri];
98-
[Commands.Test_Refreshing]: [];
99-
[Commands.Test_Stop_Refreshing]: [];
10097
[Commands.LaunchTensorBoard]: [TensorBoardEntrypoint, TensorBoardEntrypointTrigger];
10198
['workbench.view.testing.focus']: [];
10299
}

src/client/common/constants.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ export namespace Commands {
4141
export const Exec_Selection_In_Terminal = 'python.execSelectionInTerminal';
4242
export const Exec_Selection_In_Django_Shell = 'python.execSelectionInDjangoShell';
4343
export const Tests_Configure = 'python.configureTests';
44-
export const Test_Refresh = 'python.refreshTests';
45-
// `python.refreshingTests` is a dummy command just to show the spinning icon
46-
export const Test_Refreshing = 'python.refreshingTests';
47-
export const Test_Stop_Refreshing = 'python.stopRefreshingTests';
4844
export const Sort_Imports = 'python.sortImports';
4945
export const ViewOutput = 'python.viewOutput';
5046
export const Start_REPL = 'python.startREPL';

src/client/testing/main.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -164,29 +164,6 @@ export class UnitTestManagementService implements IExtensionActivationService {
164164
this.testController?.refreshTestData(resource, { forceRefresh: true });
165165
},
166166
),
167-
commandManager.registerCommand(
168-
constants.Commands.Test_Refresh,
169-
async (
170-
_,
171-
cmdSource: constants.CommandSource = constants.CommandSource.commandPalette,
172-
resource?: Uri,
173-
) => {
174-
traceVerbose('Testing: Manually triggered test refresh');
175-
sendTelemetryEvent(EventName.UNITTEST_DISCOVERY_TRIGGER, undefined, {
176-
trigger: cmdSource,
177-
});
178-
this.testController?.refreshTestData(resource, { forceRefresh: true });
179-
},
180-
),
181-
commandManager.registerCommand(constants.Commands.Test_Refreshing, () => {
182-
// We don't do anything if this is clicked. This is just to show
183-
// the spinning refresh icon.
184-
}),
185-
commandManager.registerCommand(constants.Commands.Test_Stop_Refreshing, () => {
186-
traceVerbose('Testing: Stop refreshing clicked.');
187-
sendTelemetryEvent(EventName.UNITTEST_DISCOVERING_STOP);
188-
this.testController?.stopRefreshing();
189-
}),
190167
);
191168
}
192169

src/client/testing/testController/controller.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
} from 'vscode';
1919
import { IExtensionSingleActivationService } from '../../activation/types';
2020
import { IWorkspaceService } from '../../common/application/types';
21+
import * as constants from '../../common/constants';
2122
import { IPythonExecutionFactory } from '../../common/process/types';
2223
import { IConfigurationService, IDisposableRegistry, Resource } from '../../common/types';
2324
import { DelayedTrigger, IDelayedTrigger } from '../../common/utils/delayTrigger';
@@ -112,6 +113,21 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
112113
),
113114
);
114115
this.testController.resolveHandler = this.resolveChildren.bind(this);
116+
this.testController.refreshHandler = (token: CancellationToken) => {
117+
this.disposables.push(
118+
token.onCancellationRequested(() => {
119+
traceVerbose('Testing: Stop refreshing triggered');
120+
sendTelemetryEvent(EventName.UNITTEST_DISCOVERING_STOP);
121+
this.stopRefreshing();
122+
}),
123+
);
124+
125+
traceVerbose('Testing: Manually triggered test refresh');
126+
sendTelemetryEvent(EventName.UNITTEST_DISCOVERY_TRIGGER, undefined, {
127+
trigger: constants.CommandSource.commandPalette,
128+
});
129+
return this.refreshTestData(undefined, { forceRefresh: true });
130+
};
115131

116132
this.pythonTestServer = new PythonTestServer(this.pythonExecFactory);
117133
}

0 commit comments

Comments
 (0)