Skip to content

Commit f37a7b6

Browse files
committed
fix debug restart
1 parent ec67825 commit f37a7b6

File tree

5 files changed

+33
-14
lines changed

5 files changed

+33
-14
lines changed

src/client/common/application/debugService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
DebugConsole,
1414
DebugSession,
1515
DebugSessionCustomEvent,
16+
DebugSessionOptions,
1617
Disposable,
1718
Event,
1819
WorkspaceFolder,
@@ -57,7 +58,7 @@ export class DebugService implements IDebugService {
5758
public startDebugging(
5859
folder: WorkspaceFolder | undefined,
5960
nameOrConfiguration: string | DebugConfiguration,
60-
parentSession?: DebugSession,
61+
parentSession?: DebugSession | DebugSessionOptions,
6162
): Thenable<boolean> {
6263
return debug.startDebugging(folder, nameOrConfiguration, parentSession);
6364
}

src/client/testing/common/debugLauncher.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { inject, injectable, named } from 'inversify';
22
import * as path from 'path';
3-
import { DebugConfiguration, l10n, Uri, WorkspaceFolder, DebugSession } from 'vscode';
3+
import { DebugConfiguration, l10n, Uri, WorkspaceFolder, DebugSession, DebugSessionOptions } from 'vscode';
44
import { IApplicationShell, IDebugService } from '../../common/application/types';
55
import { EXTENSION_ROOT_DIR } from '../../common/constants';
66
import * as internalScripts from '../../common/process/internal/scripts';
@@ -32,7 +32,11 @@ export class DebugLauncher implements ITestDebugLauncher {
3232
this.configService = this.serviceContainer.get<IConfigurationService>(IConfigurationService);
3333
}
3434

35-
public async launchDebugger(options: LaunchOptions, callback?: () => void): Promise<void> {
35+
public async launchDebugger(
36+
options: LaunchOptions,
37+
callback?: () => void,
38+
sessionOptions?: DebugSessionOptions,
39+
): Promise<void> {
3640
const deferred = createDeferred<void>();
3741
let hasCallbackBeenCalled = false;
3842
if (options.token && options.token.isCancellationRequested) {
@@ -57,7 +61,7 @@ export class DebugLauncher implements ITestDebugLauncher {
5761
const debugManager = this.serviceContainer.get<IDebugService>(IDebugService);
5862

5963
let activatedDebugSession: DebugSession | undefined;
60-
debugManager.startDebugging(workspaceFolder, launchArgs).then(() => {
64+
debugManager.startDebugging(workspaceFolder, launchArgs, sessionOptions).then(() => {
6165
// Save the debug session after it is started so we can check if it is the one that was terminated.
6266
activatedDebugSession = debugManager.activeDebugSession;
6367
});

src/client/testing/common/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CancellationToken, Disposable, OutputChannel, Uri } from 'vscode';
1+
import { CancellationToken, DebugSessionOptions, Disposable, OutputChannel, Uri } from 'vscode';
22
import { Product } from '../../common/types';
33
import { TestSettingsPropertyNames } from '../configuration/types';
44
import { TestProvider } from '../types';
@@ -89,7 +89,7 @@ export interface ITestConfigurationManagerFactory {
8989
}
9090
export const ITestDebugLauncher = Symbol('ITestDebugLauncher');
9191
export interface ITestDebugLauncher {
92-
launchDebugger(options: LaunchOptions, callback?: () => void): Promise<void>;
92+
launchDebugger(options: LaunchOptions, callback?: () => void, sessionOptions?: DebugSessionOptions): Promise<void>;
9393
}
9494

9595
export const IUnitTestSocketServer = Symbol('IUnitTestSocketServer');

src/client/testing/testController/pytest/pytestExecutionAdapter.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
import { CancellationTokenSource, TestRun, TestRunProfileKind, Uri } from 'vscode';
4+
import { CancellationTokenSource, DebugSessionOptions, TestRun, TestRunProfileKind, Uri } from 'vscode';
55
import * as path from 'path';
66
import { ChildProcess } from 'child_process';
77
import { IConfigurationService, ITestOutputChannel } from '../../../common/types';
@@ -167,10 +167,17 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
167167
runTestIdsPort: testIdsFileName,
168168
pytestPort: resultNamedPipeName,
169169
};
170+
const sessionOptions: DebugSessionOptions = {
171+
testRun: runInstance,
172+
};
170173
traceInfo(`Running DEBUG pytest with arguments: ${testArgs} for workspace ${uri.fsPath} \r\n`);
171-
await debugLauncher!.launchDebugger(launchOptions, () => {
172-
serverCancel.cancel();
173-
});
174+
await debugLauncher!.launchDebugger(
175+
launchOptions,
176+
() => {
177+
serverCancel.cancel();
178+
},
179+
sessionOptions,
180+
);
174181
} else {
175182
// deferredTillExecClose is resolved when all stdout and stderr is read
176183
const deferredTillExecClose: Deferred<void> = utils.createTestingDeferred();

src/client/testing/testController/unittest/testExecutionAdapter.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT License.
33

44
import * as path from 'path';
5-
import { CancellationTokenSource, TestRun, TestRunProfileKind, Uri } from 'vscode';
5+
import { CancellationTokenSource, DebugSessionOptions, TestRun, TestRunProfileKind, Uri } from 'vscode';
66
import { ChildProcess } from 'child_process';
77
import { IConfigurationService, ITestOutputChannel } from '../../../common/types';
88
import { Deferred, createDeferred } from '../../../common/utils/async';
@@ -166,15 +166,22 @@ export class UnittestTestExecutionAdapter implements ITestExecutionAdapter {
166166
runTestIdsPort: testIdsFileName,
167167
pytestPort: resultNamedPipeName, // change this from pytest
168168
};
169+
const sessionOptions: DebugSessionOptions = {
170+
testRun: runInstance,
171+
};
169172
traceInfo(`Running DEBUG unittest for workspace ${options.cwd} with arguments: ${args}\r\n`);
170173

171174
if (debugLauncher === undefined) {
172175
traceError('Debug launcher is not defined');
173176
throw new Error('Debug launcher is not defined');
174177
}
175-
await debugLauncher.launchDebugger(launchOptions, () => {
176-
serverCancel.cancel();
177-
});
178+
await debugLauncher.launchDebugger(
179+
launchOptions,
180+
() => {
181+
serverCancel.cancel();
182+
},
183+
sessionOptions,
184+
);
178185
} else {
179186
// This means it is running the test
180187
traceInfo(`Running unittests for workspace ${cwd} with arguments: ${args}\r\n`);

0 commit comments

Comments
 (0)