Skip to content

Adopt lifecycle managed by parent #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/extension/debugger/hooks/childProcessAttachService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

'use strict';

import { debug, DebugConfiguration, DebugSession, l10n, WorkspaceFolder } from 'vscode';
import { debug, DebugConfiguration, DebugSession, DebugSessionOptions, l10n, WorkspaceFolder } from 'vscode';
import { captureTelemetry } from '../../telemetry';
import { EventName } from '../../telemetry/constants';
import { AttachRequestArguments } from '../../types';
Expand All @@ -22,11 +22,17 @@ export class ChildProcessAttachService implements IChildProcessAttachService {
@captureTelemetry(EventName.DEBUGGER_ATTACH_TO_CHILD_PROCESS)
public async attach(data: AttachRequestArguments & DebugConfiguration, parentSession: DebugSession): Promise<void> {
const debugConfig: AttachRequestArguments & DebugConfiguration = data;
const processId = debugConfig.subProcessId!;
const debugSessionOption: DebugSessionOptions = {
parentSession: parentSession,
lifecycleManagedByParent: true,
};
const folder = this.getRelatedWorkspaceFolder(debugConfig);
const launched = await debug.startDebugging(folder, debugConfig, parentSession);
const launched = await debug.startDebugging(folder, debugConfig, debugSessionOption);
if (!launched) {
showErrorMessage(l10n.t('Failed to launch debugger for child process {0}', processId)).then(noop, noop);
showErrorMessage(l10n.t('Failed to launch debugger for child process {0}', debugConfig.subProcessId!)).then(
noop,
noop,
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ suite('Debug - Attach to Child Process', () => {
sinon.assert.calledOnceWithExactly(startDebuggingStub, undefined, sinon.match.any, sinon.match.any);
sinon.assert.notCalled(showErrorMessageStub);
});
test('Validate debug config is passed as is', async () => {
test('Validate debug config is passed with the correct params', async () => {
const data: LaunchRequestArguments | AttachRequestArguments = {
request: 'attach',
type: 'debugpy',
Expand All @@ -136,7 +136,7 @@ suite('Debug - Attach to Child Process', () => {
sinon.assert.calledOnceWithExactly(startDebuggingStub, undefined, sinon.match.any, sinon.match.any);
const [, secondArg, thirdArg] = startDebuggingStub.args[0];
expect(secondArg).to.deep.equal(debugConfig);
expect(thirdArg).to.deep.equal(session);
expect(thirdArg).to.deep.equal({ parentSession: session, lifecycleManagedByParent: true });
sinon.assert.notCalled(showErrorMessageStub);
});
test('Pass data as is if data is attach debug configuration', async () => {
Expand All @@ -157,7 +157,7 @@ suite('Debug - Attach to Child Process', () => {
sinon.assert.calledOnceWithExactly(startDebuggingStub, undefined, sinon.match.any, sinon.match.any);
const [, secondArg, thirdArg] = startDebuggingStub.args[0];
expect(secondArg).to.deep.equal(debugConfig);
expect(thirdArg).to.deep.equal(session);
expect(thirdArg).to.deep.equal({ parentSession: session, lifecycleManagedByParent: true });
sinon.assert.notCalled(showErrorMessageStub);
});
test('Validate debug config when parent/root parent was attached', async () => {
Expand Down Expand Up @@ -185,7 +185,7 @@ suite('Debug - Attach to Child Process', () => {
sinon.assert.calledOnceWithExactly(startDebuggingStub, undefined, sinon.match.any, sinon.match.any);
const [, secondArg, thirdArg] = startDebuggingStub.args[0];
expect(secondArg).to.deep.equal(debugConfig);
expect(thirdArg).to.deep.equal(session);
expect(thirdArg).to.deep.equal({ parentSession: session, lifecycleManagedByParent: true });
sinon.assert.notCalled(showErrorMessageStub);
});
});