From a638c798cb12ffd3554bc4fb058812fe5536a276 Mon Sep 17 00:00:00 2001 From: eleanorjboyd Date: Tue, 16 Apr 2024 16:26:21 -0700 Subject: [PATCH 1/7] add logic to stop debugging on the use of cancelation token --- src/client/testing/common/debugLauncher.ts | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/client/testing/common/debugLauncher.ts b/src/client/testing/common/debugLauncher.ts index f9c7747d883a..8e9e1ed74751 100644 --- a/src/client/testing/common/debugLauncher.ts +++ b/src/client/testing/common/debugLauncher.ts @@ -1,6 +1,6 @@ import { inject, injectable, named } from 'inversify'; import * as path from 'path'; -import { DebugConfiguration, l10n, Uri, WorkspaceFolder } from 'vscode'; +import { debug, DebugConfiguration, Disposable, l10n, Uri, WorkspaceFolder } from 'vscode'; import { IApplicationShell, IDebugService } from '../../common/application/types'; import { EXTENSION_ROOT_DIR } from '../../common/constants'; import * as internalScripts from '../../common/process/internal/scripts'; @@ -48,7 +48,29 @@ export class DebugLauncher implements ITestDebugLauncher { ); const debugManager = this.serviceContainer.get(IDebugService); + let disposeOfDebugger: Disposable | undefined; + debugManager.onDidStartDebugSession((session) => { + if (options.token) { + disposeOfDebugger = options?.token.onCancellationRequested(() => { + debug.stopDebugging(session); + deferred.resolve(); + callback?.(); + }); + } + }); + + // if (options.token) { + // options?.token.onCancellationRequested(() => { + // // debugManager.stopDebugging(); + // deferred.resolve(); + // callback?.(); + // }); + // } + debugManager.onDidTerminateDebugSession(() => { + if (disposeOfDebugger !== undefined) { + disposeOfDebugger.dispose(); + } deferred.resolve(); callback?.(); }); From 2331c24be3cf9cd4dcdfe5bed5a0214a81a5dd9c Mon Sep 17 00:00:00 2001 From: eleanorjboyd Date: Thu, 18 Apr 2024 14:15:14 -0700 Subject: [PATCH 2/7] debugger disposal working --- src/client/testing/common/debugLauncher.ts | 19 +++++++++++++++---- .../testing/testController/common/utils.ts | 1 + .../pytest/pytestExecutionAdapter.ts | 2 ++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/client/testing/common/debugLauncher.ts b/src/client/testing/common/debugLauncher.ts index 8e9e1ed74751..5d5f49c0f290 100644 --- a/src/client/testing/common/debugLauncher.ts +++ b/src/client/testing/common/debugLauncher.ts @@ -49,12 +49,15 @@ export class DebugLauncher implements ITestDebugLauncher { const debugManager = this.serviceContainer.get(IDebugService); let disposeOfDebugger: Disposable | undefined; - debugManager.onDidStartDebugSession((session) => { + console.log('reset count to 0'); + let count = 0; + const disposeOfStartDebugging = debugManager.onDidStartDebugSession((session) => { + console.log('start session'); if (options.token) { disposeOfDebugger = options?.token.onCancellationRequested(() => { + count += 1; + console.log('Canceling debugger, count: ', count); debug.stopDebugging(session); - deferred.resolve(); - callback?.(); }); } }); @@ -67,14 +70,22 @@ export class DebugLauncher implements ITestDebugLauncher { // }); // } - debugManager.onDidTerminateDebugSession(() => { + const disposeTerminateWatcher = debugManager.onDidTerminateDebugSession(() => { + console.log('Debugging terminated'); if (disposeOfDebugger !== undefined) { + console.log('dispose of debugger'); disposeOfDebugger.dispose(); } + if (disposeOfStartDebugging !== undefined) { + console.log('dispose of start debugging'); + disposeOfStartDebugging.dispose(); + } + disposeTerminateWatcher.dispose(); deferred.resolve(); callback?.(); }); debugManager.startDebugging(workspaceFolder, launchArgs); + console.log('Debugging started'); return deferred.promise; } diff --git a/src/client/testing/testController/common/utils.ts b/src/client/testing/testController/common/utils.ts index aa7a5d115246..edf7f99e9893 100644 --- a/src/client/testing/testController/common/utils.ts +++ b/src/client/testing/testController/common/utils.ts @@ -233,6 +233,7 @@ export async function startRunResultNamedPipe( // this is called once the server close, once per run instance traceVerbose(`Test Result named pipe ${pipeName} closed. Disposing of listener/s.`); // dispose of all data listeners and cancelation listeners + console.log(`Test Result named pipe on server close`); disposeOfServer(); }); }); diff --git a/src/client/testing/testController/pytest/pytestExecutionAdapter.ts b/src/client/testing/testController/pytest/pytestExecutionAdapter.ts index 5099efde179c..9b4474766a07 100644 --- a/src/client/testing/testController/pytest/pytestExecutionAdapter.ts +++ b/src/client/testing/testController/pytest/pytestExecutionAdapter.ts @@ -167,9 +167,11 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter { }; traceInfo(`Running DEBUG pytest with arguments: ${testArgs} for workspace ${uri.fsPath} \r\n`); await debugLauncher!.launchDebugger(launchOptions, () => { + console.log('debug callback'); serverDispose(); // this will resolve deferredTillServerClose deferredTillEOT?.resolve(); }); + console.log('after debugging'); } else { // deferredTillExecClose is resolved when all stdout and stderr is read const deferredTillExecClose: Deferred = utils.createTestingDeferred(); From cd12f331a2db1c75083e0a4e3838618fe0eb5e51 Mon Sep 17 00:00:00 2001 From: eleanorjboyd Date: Thu, 18 Apr 2024 14:38:00 -0700 Subject: [PATCH 3/7] fix tests --- src/client/testing/common/debugLauncher.ts | 10 ++++++---- src/test/testing/common/debugLauncher.unit.test.ts | 6 ++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/client/testing/common/debugLauncher.ts b/src/client/testing/common/debugLauncher.ts index 5d5f49c0f290..966449a527c8 100644 --- a/src/client/testing/common/debugLauncher.ts +++ b/src/client/testing/common/debugLauncher.ts @@ -35,7 +35,7 @@ export class DebugLauncher implements ITestDebugLauncher { public async launchDebugger(options: LaunchOptions, callback?: () => void): Promise { const deferred = createDeferred(); if (options.token && options.token.isCancellationRequested) { - return undefined; + n nreturn undefined; deferred.resolve(); callback?.(); } @@ -69,8 +69,8 @@ export class DebugLauncher implements ITestDebugLauncher { // callback?.(); // }); // } - - const disposeTerminateWatcher = debugManager.onDidTerminateDebugSession(() => { + let disposeTerminateWatcher: Disposable | undefined; + disposeTerminateWatcher = debugManager.onDidTerminateDebugSession(() => { console.log('Debugging terminated'); if (disposeOfDebugger !== undefined) { console.log('dispose of debugger'); @@ -80,7 +80,9 @@ export class DebugLauncher implements ITestDebugLauncher { console.log('dispose of start debugging'); disposeOfStartDebugging.dispose(); } - disposeTerminateWatcher.dispose(); + if (disposeTerminateWatcher !== undefined) { + disposeTerminateWatcher.dispose(); + } deferred.resolve(); callback?.(); }); diff --git a/src/test/testing/common/debugLauncher.unit.test.ts b/src/test/testing/common/debugLauncher.unit.test.ts index ef3e678c13f7..6a72aa7586f0 100644 --- a/src/test/testing/common/debugLauncher.unit.test.ts +++ b/src/test/testing/common/debugLauncher.unit.test.ts @@ -139,6 +139,12 @@ suite('Unit Tests - Debug Launcher', () => { return undefined as any; }) .verifiable(TypeMoq.Times.once()); + debugService + .setup((d) => d.onDidStartDebugSession(TypeMoq.It.isAny())) + .returns(() => { + return undefined as any; + }) + .verifiable(TypeMoq.Times.once()); } function createWorkspaceFolder(folderPath: string): WorkspaceFolder { return { From 9752871c319804dead13c778341e77ba7fbd412c Mon Sep 17 00:00:00 2001 From: eleanorjboyd Date: Thu, 18 Apr 2024 14:38:20 -0700 Subject: [PATCH 4/7] fix mis-type --- src/client/testing/common/debugLauncher.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/testing/common/debugLauncher.ts b/src/client/testing/common/debugLauncher.ts index 966449a527c8..858ffbf41fff 100644 --- a/src/client/testing/common/debugLauncher.ts +++ b/src/client/testing/common/debugLauncher.ts @@ -35,7 +35,7 @@ export class DebugLauncher implements ITestDebugLauncher { public async launchDebugger(options: LaunchOptions, callback?: () => void): Promise { const deferred = createDeferred(); if (options.token && options.token.isCancellationRequested) { - n nreturn undefined; + return undefined; deferred.resolve(); callback?.(); } From bbfe87e99eb259fe3984a42158684b98ac8a3a21 Mon Sep 17 00:00:00 2001 From: eleanorjboyd Date: Fri, 19 Apr 2024 11:57:12 -0700 Subject: [PATCH 5/7] add tests! --- src/client/testing/common/debugLauncher.ts | 23 +- .../testing/testController/common/utils.ts | 3 +- .../pytest/pytestExecutionAdapter.ts | 3 +- .../testing/common/testingAdapter.test.ts | 205 +++++++++++++++++- 4 files changed, 209 insertions(+), 25 deletions(-) diff --git a/src/client/testing/common/debugLauncher.ts b/src/client/testing/common/debugLauncher.ts index 858ffbf41fff..bbb8253a56c6 100644 --- a/src/client/testing/common/debugLauncher.ts +++ b/src/client/testing/common/debugLauncher.ts @@ -9,7 +9,7 @@ import { DebuggerTypeName, PythonDebuggerTypeName } from '../../debugger/constan import { IDebugConfigurationResolver } from '../../debugger/extension/configuration/types'; import { DebugPurpose, LaunchRequestArguments } from '../../debugger/types'; import { IServiceContainer } from '../../ioc/types'; -import { traceError } from '../../logging'; +import { traceError, traceLog } from '../../logging'; import { TestProvider } from '../types'; import { ITestDebugLauncher, LaunchOptions } from './types'; import { getConfigurationsForWorkspace } from '../../debugger/extension/configuration/launch.json/launchJsonReader'; @@ -49,35 +49,21 @@ export class DebugLauncher implements ITestDebugLauncher { const debugManager = this.serviceContainer.get(IDebugService); let disposeOfDebugger: Disposable | undefined; - console.log('reset count to 0'); - let count = 0; const disposeOfStartDebugging = debugManager.onDidStartDebugSession((session) => { - console.log('start session'); if (options.token) { disposeOfDebugger = options?.token.onCancellationRequested(() => { - count += 1; - console.log('Canceling debugger, count: ', count); + console.log('Canceling debugger, due to cancelation token called.'); debug.stopDebugging(session); }); } }); - // if (options.token) { - // options?.token.onCancellationRequested(() => { - // // debugManager.stopDebugging(); - // deferred.resolve(); - // callback?.(); - // }); - // } - let disposeTerminateWatcher: Disposable | undefined; - disposeTerminateWatcher = debugManager.onDidTerminateDebugSession(() => { - console.log('Debugging terminated'); + const disposeTerminateWatcher: Disposable | undefined = debugManager.onDidTerminateDebugSession(() => { + traceLog('Terminating the debugging session and disposing of debugger listeners.'); if (disposeOfDebugger !== undefined) { - console.log('dispose of debugger'); disposeOfDebugger.dispose(); } if (disposeOfStartDebugging !== undefined) { - console.log('dispose of start debugging'); disposeOfStartDebugging.dispose(); } if (disposeTerminateWatcher !== undefined) { @@ -87,7 +73,6 @@ export class DebugLauncher implements ITestDebugLauncher { callback?.(); }); debugManager.startDebugging(workspaceFolder, launchArgs); - console.log('Debugging started'); return deferred.promise; } diff --git a/src/client/testing/testController/common/utils.ts b/src/client/testing/testController/common/utils.ts index edf7f99e9893..e24b768cc912 100644 --- a/src/client/testing/testController/common/utils.ts +++ b/src/client/testing/testController/common/utils.ts @@ -219,7 +219,7 @@ export async function startRunResultNamedPipe( perConnectionDisposables.push( // per connection, add a listener for the cancellation token and the data cancellationToken?.onCancellationRequested(() => { - console.log(`Test Result named pipe ${pipeName} cancelled`); + traceVerbose(`Test Result named pipe ${pipeName} cancelled`); // if cancel is called on one connection, dispose of all connections disposeOfServer(); }), @@ -233,7 +233,6 @@ export async function startRunResultNamedPipe( // this is called once the server close, once per run instance traceVerbose(`Test Result named pipe ${pipeName} closed. Disposing of listener/s.`); // dispose of all data listeners and cancelation listeners - console.log(`Test Result named pipe on server close`); disposeOfServer(); }); }); diff --git a/src/client/testing/testController/pytest/pytestExecutionAdapter.ts b/src/client/testing/testController/pytest/pytestExecutionAdapter.ts index 9b4474766a07..090ae787ed60 100644 --- a/src/client/testing/testController/pytest/pytestExecutionAdapter.ts +++ b/src/client/testing/testController/pytest/pytestExecutionAdapter.ts @@ -167,11 +167,10 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter { }; traceInfo(`Running DEBUG pytest with arguments: ${testArgs} for workspace ${uri.fsPath} \r\n`); await debugLauncher!.launchDebugger(launchOptions, () => { - console.log('debug callback'); + traceInfo("Debugger callback called, resolving 'till EOT' deferred for the workspace."); serverDispose(); // this will resolve deferredTillServerClose deferredTillEOT?.resolve(); }); - console.log('after debugging'); } else { // deferredTillExecClose is resolved when all stdout and stderr is read const deferredTillExecClose: Deferred = utils.createTestingDeferred(); diff --git a/src/test/testing/common/testingAdapter.test.ts b/src/test/testing/common/testingAdapter.test.ts index 2b6d4887cda1..c722682e9188 100644 --- a/src/test/testing/common/testingAdapter.test.ts +++ b/src/test/testing/common/testingAdapter.test.ts @@ -1,14 +1,16 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { TestController, TestRun, Uri } from 'vscode'; +import { CancellationTokenSource, DebugSession, Disposable, TestController, TestRun, Uri, debug } from 'vscode'; import * as typeMoq from 'typemoq'; import * as path from 'path'; import * as assert from 'assert'; import * as fs from 'fs'; +import * as sinon from 'sinon'; +import { Observable } from 'rxjs'; import { PytestTestDiscoveryAdapter } from '../../../client/testing/testController/pytest/pytestDiscoveryAdapter'; import { ITestController, ITestResultResolver } from '../../../client/testing/testController/common/types'; -import { IPythonExecutionFactory } from '../../../client/common/process/types'; +import { IPythonExecutionFactory, IPythonExecutionService, Output } from '../../../client/common/process/types'; import { IConfigurationService, ITestOutputChannel } from '../../../client/common/types'; import { IServiceContainer } from '../../../client/ioc/types'; import { EXTENSION_ROOT_DIR_FOR_TESTS, initialize } from '../../initialize'; @@ -20,6 +22,10 @@ import { PythonResultResolver } from '../../../client/testing/testController/com import { TestProvider } from '../../../client/testing/types'; import { PYTEST_PROVIDER, UNITTEST_PROVIDER } from '../../../client/testing/common/constants'; import { IEnvironmentVariablesProvider } from '../../../client/common/variables/types'; +import { ITestDebugLauncher } from '../../../client/testing/common/types'; +import { MockChildProcess } from '../../mocks/mockChildProcess'; +import { IDebugService } from '../../../client/common/application/types'; +import { createDeferred } from '../../../client/common/utils/async'; suite('End to End Tests: test adapters', () => { let resultResolver: ITestResultResolver; @@ -123,6 +129,9 @@ suite('End to End Tests: test adapters', () => { traceLog('Symlink was not found to remove after tests, exiting successfully'); } }); + teardown(async () => { + sinon.restore(); + }); test('unittest discovery adapter small workspace', async () => { // result resolver and saved data for assertions let actualData: { @@ -950,4 +959,196 @@ suite('End to End Tests: test adapters', () => { assert.strictEqual(failureOccurred, false, failureMsg); }); }); + test('Pytest debug cancelation', async () => { + const debugLauncher = serviceContainer.get(ITestDebugLauncher); + const stopDebuggingStub = sinon.stub(debug, 'stopDebugging'); + let calledStopDebugging = false; + stopDebuggingStub.callsFake(() => { + calledStopDebugging = true; + return Promise.resolve(); + }); + + // // mock exec service and exec factory, not very necessary for this test + const execServiceStub = typeMoq.Mock.ofType(); + const execFactoryStub = typeMoq.Mock.ofType(); + const cancellationTokenSource = new CancellationTokenSource(); + let mockProc: MockChildProcess; + execServiceStub + .setup((x) => x.execObservable(typeMoq.It.isAny(), typeMoq.It.isAny())) + .returns(() => ({ + proc: mockProc, + out: typeMoq.Mock.ofType>>().object, + dispose: () => { + /* no-body */ + }, + })); + execFactoryStub + .setup((x) => x.createActivatedEnvironment(typeMoq.It.isAny())) + .returns(() => Promise.resolve(execServiceStub.object)); + execFactoryStub.setup((p) => ((p as unknown) as any).then).returns(() => undefined); + execServiceStub.setup((p) => ((p as unknown) as any).then).returns(() => undefined); + + resultResolver = new PythonResultResolver(testController, pytestProvider, workspaceUri); + + const testId = `${rootPathErrorWorkspace}/test_seg_fault.py::TestSegmentationFault::test_segfault`; + const testIds: string[] = [testId]; + + // set workspace to test workspace folder + workspaceUri = Uri.parse(rootPathErrorWorkspace); + configService.getSettings(workspaceUri).testing.pytestArgs = []; + + const debugSessionStub = typeMoq.Mock.ofType(); + sinon.stub(debug, 'onDidStartDebugSession').callsFake((cb) => { + // run the callback right away to add the cancelation token listener + cb(debugSessionStub.object); + return { + dispose: () => { + /* no-body */ + }, + }; + }); + const awaitStopDebugging = createDeferred(); + + sinon.stub(debug, 'onDidTerminateDebugSession').callsFake((cb) => { + // wait for the stop debugging to be called before resolving the promise + // the terminate debug session does cleanup + awaitStopDebugging.promise.then(() => { + cb(debugSessionStub.object); + }); + return { + dispose: () => { + // void + }, + }; + }); + // handle cancelation token from debugger + sinon.stub(debug, 'startDebugging').callsFake((folder, nameOrConfiguration, _parentSession) => { + // check to make sure start debugging is called correctly + if (typeof nameOrConfiguration !== 'string') { + assert.strictEqual(nameOrConfiguration.type, 'debugpy', 'Expected debugpy'); + } else { + assert.fail('Expected nameOrConfiguration to be an object'); + } + assert.ok(folder, 'Expected folder to be defined'); + assert.strictEqual(folder.name, 'test', 'Expected folder name to be test'); + // cancel the token and trigger the stop debugging callback + awaitStopDebugging.resolve(); + cancellationTokenSource.cancel(); + return Promise.resolve(true); + }); + + // run pytest execution + const executionAdapter = new PytestTestExecutionAdapter( + configService, + testOutputChannel.object, + resultResolver, + envVarsService, + ); + + const testRun = typeMoq.Mock.ofType(); + testRun.setup((t) => t.token).returns(() => cancellationTokenSource.token); + + await executionAdapter + .runTests(workspaceUri, testIds, true, testRun.object, pythonExecFactory, debugLauncher) + .finally(() => { + // verify that the stop debugging was called + assert.ok(calledStopDebugging, 'Expected stopDebugging to be called'); + }); + }); + test('UNITTEST debug cancelation', async () => { + const debugLauncher = serviceContainer.get(ITestDebugLauncher); + const stopDebuggingStub = sinon.stub(debug, 'stopDebugging'); + let calledStopDebugging = false; + stopDebuggingStub.callsFake(() => { + calledStopDebugging = true; + return Promise.resolve(); + }); + + // // mock exec service and exec factory, not very necessary for this test + const execServiceStub = typeMoq.Mock.ofType(); + const execFactoryStub = typeMoq.Mock.ofType(); + const cancellationTokenSource = new CancellationTokenSource(); + let mockProc: MockChildProcess; + execServiceStub + .setup((x) => x.execObservable(typeMoq.It.isAny(), typeMoq.It.isAny())) + .returns(() => ({ + proc: mockProc, + out: typeMoq.Mock.ofType>>().object, + dispose: () => { + /* no-body */ + }, + })); + execFactoryStub + .setup((x) => x.createActivatedEnvironment(typeMoq.It.isAny())) + .returns(() => Promise.resolve(execServiceStub.object)); + execFactoryStub.setup((p) => ((p as unknown) as any).then).returns(() => undefined); + execServiceStub.setup((p) => ((p as unknown) as any).then).returns(() => undefined); + + resultResolver = new PythonResultResolver(testController, pytestProvider, workspaceUri); + + const testId = `${rootPathErrorWorkspace}/test_seg_fault.py::TestSegmentationFault::test_segfault`; + const testIds: string[] = [testId]; + + // set workspace to test workspace folder + workspaceUri = Uri.parse(rootPathErrorWorkspace); + configService.getSettings(workspaceUri).testing.pytestArgs = []; + + const debugSessionStub = typeMoq.Mock.ofType(); + sinon.stub(debug, 'onDidStartDebugSession').callsFake((cb) => { + // run the callback right away to add the cancelation token listener + cb(debugSessionStub.object); + return { + dispose: () => { + /* no-body */ + }, + }; + }); + const awaitStopDebugging = createDeferred(); + + sinon.stub(debug, 'onDidTerminateDebugSession').callsFake((cb) => { + // wait for the stop debugging to be called before resolving the promise + // the terminate debug session does cleanup + awaitStopDebugging.promise.then(() => { + cb(debugSessionStub.object); + }); + return { + dispose: () => { + // void + }, + }; + }); + // handle cancelation token from debugger + sinon.stub(debug, 'startDebugging').callsFake((folder, nameOrConfiguration, _parentSession) => { + // check to make sure start debugging is called correctly + if (typeof nameOrConfiguration !== 'string') { + assert.strictEqual(nameOrConfiguration.type, 'debugpy', 'Expected debugpy'); + } else { + assert.fail('Expected nameOrConfiguration to be an object'); + } + assert.ok(folder, 'Expected folder to be defined'); + assert.strictEqual(folder.name, 'test', 'Expected folder name to be test'); + // cancel the token and trigger the stop debugging callback + awaitStopDebugging.resolve(); + cancellationTokenSource.cancel(); + return Promise.resolve(true); + }); + + // run pytest execution + const executionAdapter = new UnittestTestExecutionAdapter( + configService, + testOutputChannel.object, + resultResolver, + envVarsService, + ); + + const testRun = typeMoq.Mock.ofType(); + testRun.setup((t) => t.token).returns(() => cancellationTokenSource.token); + + await executionAdapter + .runTests(workspaceUri, testIds, true, testRun.object, pythonExecFactory, debugLauncher) + .finally(() => { + // verify that the stop debugging was called + assert.ok(calledStopDebugging, 'Expected stopDebugging to be called'); + }); + }); }); From eb237a32c7f91ea75cae938f808b1cbe85571ac3 Mon Sep 17 00:00:00 2001 From: eleanorjboyd Date: Fri, 19 Apr 2024 12:00:13 -0700 Subject: [PATCH 6/7] fix linting --- src/test/testing/common/testingAdapter.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/testing/common/testingAdapter.test.ts b/src/test/testing/common/testingAdapter.test.ts index c06b784ac928..572ea7e19836 100644 --- a/src/test/testing/common/testingAdapter.test.ts +++ b/src/test/testing/common/testingAdapter.test.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import { CancellationTokenSource, DebugSession, Disposable, TestController, TestRun, Uri, debug } from 'vscode'; +import { CancellationTokenSource, DebugSession, TestController, TestRun, Uri, debug } from 'vscode'; import * as typeMoq from 'typemoq'; import * as path from 'path'; import * as assert from 'assert'; @@ -25,7 +25,6 @@ import { PYTEST_PROVIDER, UNITTEST_PROVIDER } from '../../../client/testing/comm import { IEnvironmentVariablesProvider } from '../../../client/common/variables/types'; import { ITestDebugLauncher } from '../../../client/testing/common/types'; import { MockChildProcess } from '../../mocks/mockChildProcess'; -import { IDebugService } from '../../../client/common/application/types'; import { createDeferred } from '../../../client/common/utils/async'; suite('End to End Tests: test adapters', () => { From f0793932a6b186d2dad4de477ee487867da36998 Mon Sep 17 00:00:00 2001 From: eleanorjboyd Date: Fri, 19 Apr 2024 12:07:00 -0700 Subject: [PATCH 7/7] fix disposal --- src/client/testing/common/debugLauncher.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client/testing/common/debugLauncher.ts b/src/client/testing/common/debugLauncher.ts index bbb8253a56c6..0ec38eb9c87c 100644 --- a/src/client/testing/common/debugLauncher.ts +++ b/src/client/testing/common/debugLauncher.ts @@ -58,7 +58,9 @@ export class DebugLauncher implements ITestDebugLauncher { } }); - const disposeTerminateWatcher: Disposable | undefined = debugManager.onDidTerminateDebugSession(() => { + let disposeTerminateWatcher: Disposable | undefined; + // eslint-disable-next-line prefer-const + disposeTerminateWatcher = debugManager.onDidTerminateDebugSession(() => { traceLog('Terminating the debugging session and disposing of debugger listeners.'); if (disposeOfDebugger !== undefined) { disposeOfDebugger.dispose();