Skip to content

Commit d2f73f8

Browse files
authored
Update when unittest disabled telemetry is sent. (#18800)
1 parent 09e98d3 commit d2f73f8

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/client/testing/testController/controller.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
5151

5252
public readonly onRunWithoutConfiguration = this.runWithoutConfigurationEvent.event;
5353

54+
private sendTestDisabledTelemetry = true;
55+
5456
constructor(
5557
@inject(IWorkspaceService) private readonly workspaceService: IWorkspaceService,
5658
@inject(IConfigurationService) private readonly configSettings: IConfigurationService,
@@ -137,15 +139,26 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
137139
private async refreshTestDataInternal(uri?: Resource): Promise<void> {
138140
this.refreshingStartedEvent.fire();
139141
if (uri) {
140-
traceVerbose(`Testing: Refreshing test data for ${uri.fsPath}`);
141-
142142
const settings = this.configSettings.getSettings(uri);
143143
if (settings.testing.pytestEnabled) {
144+
traceVerbose(`Testing: Refreshing test data for ${uri.fsPath}`);
145+
146+
// Ensure we send test telemetry if it gets disabled again
147+
this.sendTestDisabledTelemetry = true;
148+
144149
await this.pytest.refreshTestData(this.testController, uri, this.refreshCancellation.token);
145150
} else if (settings.testing.unittestEnabled) {
151+
traceVerbose(`Testing: Refreshing test data for ${uri.fsPath}`);
152+
153+
// Ensure we send test telemetry if it gets disabled again
154+
this.sendTestDisabledTelemetry = true;
155+
146156
await this.unittest.refreshTestData(this.testController, uri, this.refreshCancellation.token);
147157
} else {
148-
sendTelemetryEvent(EventName.UNITTEST_DISABLED);
158+
if (this.sendTestDisabledTelemetry) {
159+
this.sendTestDisabledTelemetry = false;
160+
sendTelemetryEvent(EventName.UNITTEST_DISABLED);
161+
}
149162
// If we are here we may have to remove an existing node from the tree
150163
// This handles the case where user removes test settings. Which should remove the
151164
// tests for that particular case from the tree view

0 commit comments

Comments
 (0)