Skip to content

Commit

Permalink
only show coverage button for rewrite (#24249)
Browse files Browse the repository at this point in the history
fixes #24241
  • Loading branch information
eleanorjboyd authored and karthiknadig committed Oct 7, 2024
1 parent ff65066 commit 2308648
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/client/testing/testController/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,6 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
this.disposables.push(delayTrigger);
this.refreshData = delayTrigger;

const coverageProfile = this.testController.createRunProfile(
'Coverage Tests',
TestRunProfileKind.Coverage,
this.runTests.bind(this),
true,
RunTestTag,
);

this.disposables.push(
this.testController.createRunProfile(
'Run Tests',
Expand All @@ -142,8 +134,19 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
true,
DebugTestTag,
),
coverageProfile,
);
if (pythonTestAdapterRewriteEnabled(this.serviceContainer)) {
// only add the coverage profile if the new test adapter is enabled
const coverageProfile = this.testController.createRunProfile(
'Coverage Tests',
TestRunProfileKind.Coverage,
this.runTests.bind(this),
true,
RunTestTag,
);

this.disposables.push(coverageProfile);
}
this.testController.resolveHandler = this.resolveChildren.bind(this);
this.testController.refreshHandler = (token: CancellationToken) => {
this.disposables.push(
Expand Down Expand Up @@ -420,11 +423,11 @@ export class PythonTestController implements ITestController, IExtensionSingleAc

const settings = this.configSettings.getSettings(workspace.uri);
if (testItems.length > 0) {
// coverage??
const testAdapter =
this.testAdapters.get(workspace.uri) ||
(this.testAdapters.values().next().value as WorkspaceTestAdapter);

// no profile will have TestRunProfileKind.Coverage if rewrite isn't enabled
if (request.profile?.kind && request.profile?.kind === TestRunProfileKind.Coverage) {
request.profile.loadDetailedCoverage = (
_testRun: TestRun,
Expand Down

0 comments on commit 2308648

Please sign in to comment.