From 2308648871ff592467644707e9ce70b3fca3c0f0 Mon Sep 17 00:00:00 2001 From: Eleanor Boyd Date: Fri, 4 Oct 2024 17:10:03 -0700 Subject: [PATCH] only show coverage button for rewrite (#24249) fixes https://github.com/microsoft/vscode-python/issues/24241 --- .../testing/testController/controller.ts | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/client/testing/testController/controller.ts b/src/client/testing/testController/controller.ts index 12d0fec23134..f969760c45b6 100644 --- a/src/client/testing/testController/controller.ts +++ b/src/client/testing/testController/controller.ts @@ -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', @@ -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( @@ -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,