From b577cec454e299d27a0a61e22a1030e91f12d35d Mon Sep 17 00:00:00 2001 From: paulacamargo25 Date: Mon, 6 Mar 2023 23:13:22 -0800 Subject: [PATCH 1/2] Set clientOS debug option (#20805) Closed: https://github.com/microsoft/vscode-python/issues/20407 --- .../extension/configuration/resolvers/attach.ts | 9 +++++---- .../extension/configuration/resolvers/base.ts | 3 +++ .../extension/configuration/resolvers/launch.ts | 3 +++ .../configuration/resolvers/attach.unit.test.ts | 14 +++++++++++--- .../configuration/resolvers/launch.unit.test.ts | 13 +++++++++++++ src/test/testing/common/debugLauncher.unit.test.ts | 3 +++ 6 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/client/debugger/extension/configuration/resolvers/attach.ts b/src/client/debugger/extension/configuration/resolvers/attach.ts index 635dc88dbac4..096317bb065b 100644 --- a/src/client/debugger/extension/configuration/resolvers/attach.ts +++ b/src/client/debugger/extension/configuration/resolvers/attach.ts @@ -26,6 +26,9 @@ export class AttachConfigurationResolver extends BaseConfigurationResolver dbgConfig.debugOptions!.indexOf(item) === pos, ); } + if (debugConfiguration.clienOS === undefined) { + debugConfiguration.clientOS = getOSType() === OSType.Windows ? 'windows' : 'unix'; + } return debugConfiguration; } @@ -77,10 +80,8 @@ export class AttachConfigurationResolver extends BaseConfigurationResolver debugConfiguration: DebugConfiguration, _token?: CancellationToken, ): Promise { + if (debugConfiguration.clienOS === undefined) { + debugConfiguration.clientOS = getOSType() === OSType.Windows ? 'windows' : 'unix'; + } return debugConfiguration as T; } diff --git a/src/client/debugger/extension/configuration/resolvers/launch.ts b/src/client/debugger/extension/configuration/resolvers/launch.ts index d5cb419e031d..9513384f1277 100644 --- a/src/client/debugger/extension/configuration/resolvers/launch.ts +++ b/src/client/debugger/extension/configuration/resolvers/launch.ts @@ -50,6 +50,9 @@ export class LaunchConfigurationResolver extends BaseConfigurationResolver { const options = [DebugOptions.RedirectOutput]; if (osType === platform.OSType.Windows) { options.push(DebugOptions.FixFilePathCase); - options.push(DebugOptions.WindowsClient); - } else { - options.push(DebugOptions.UnixClient); } options.push(DebugOptions.ShowReturnValue); + return options; } @@ -76,6 +74,10 @@ getInfoPerOS().forEach(([osName, osType, path]) => { } } + function getClientOS() { + return osType === platform.OSType.Windows ? 'windows' : 'unix'; + } + function setupWorkspaces(folders: string[]) { const workspaceFolders = folders.map(createMoqWorkspaceFolder); getWorkspaceFoldersStub.returns(workspaceFolders); @@ -119,6 +121,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => { expect(Object.keys(debugConfig!)).to.have.lengthOf.above(3); expect(debugConfig).to.have.property('request', 'attach'); + expect(debugConfig).to.have.property('clientOS', getClientOS()); expect(debugConfig).to.have.property('debugOptions').deep.equal(debugOptionsAvailable); }); @@ -134,6 +137,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => { expect(Object.keys(debugConfig!)).to.have.lengthOf.least(3); expect(debugConfig).to.have.property('request', 'attach'); + expect(debugConfig).to.have.property('clientOS', getClientOS()); expect(debugConfig).to.have.property('debugOptions').deep.equal(debugOptionsAvailable); expect(debugConfig).to.have.property('host', 'localhost'); }); @@ -148,6 +152,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => { expect(Object.keys(debugConfig!)).to.have.lengthOf.least(3); expect(debugConfig).to.have.property('request', 'attach'); + expect(debugConfig).to.have.property('clientOS', getClientOS()); expect(debugConfig).to.have.property('debugOptions').deep.equal(debugOptionsAvailable); expect(debugConfig).to.have.property('host', 'localhost'); }); @@ -164,6 +169,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => { expect(Object.keys(debugConfig!)).to.have.lengthOf.least(3); expect(debugConfig).to.have.property('request', 'attach'); + expect(debugConfig).to.have.property('clientOS', getClientOS()); expect(debugConfig).to.have.property('debugOptions').deep.equal(debugOptionsAvailable); expect(debugConfig).to.not.have.property('localRoot'); expect(debugConfig).to.have.property('host', 'localhost'); @@ -181,6 +187,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => { expect(Object.keys(debugConfig!)).to.have.lengthOf.least(3); expect(debugConfig).to.have.property('request', 'attach'); + expect(debugConfig).to.have.property('clientOS', getClientOS()); expect(debugConfig).to.have.property('debugOptions').deep.equal(debugOptionsAvailable); expect(debugConfig).to.have.property('host', 'localhost'); }); @@ -486,6 +493,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => { debugOptions, }); + expect(debugConfig).to.have.property('clientOS', getClientOS()); expect(debugConfig).to.have.property('debugOptions').to.be.deep.equal(expectedDebugOptions); }); diff --git a/src/test/debugger/extension/configuration/resolvers/launch.unit.test.ts b/src/test/debugger/extension/configuration/resolvers/launch.unit.test.ts index e7e256468f84..4830b88a34fb 100644 --- a/src/test/debugger/extension/configuration/resolvers/launch.unit.test.ts +++ b/src/test/debugger/extension/configuration/resolvers/launch.unit.test.ts @@ -58,6 +58,10 @@ getInfoPerOS().forEach(([osName, osType, path]) => { return folder.object; } + function getClientOS() { + return osType === platform.OSType.Windows ? 'windows' : 'unix'; + } + function setupIoc(pythonPath: string, workspaceFolder?: WorkspaceFolder) { configService = TypeMoq.Mock.ofType(); diagnosticsService = TypeMoq.Mock.ofType(); @@ -160,6 +164,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => { expect(Object.keys(debugConfig!)).to.have.lengthOf.above(3); expect(debugConfig).to.have.property('type', 'python'); expect(debugConfig).to.have.property('request', 'launch'); + expect(debugConfig).to.have.property('clientOS', getClientOS()); expect(debugConfig).to.not.have.property('pythonPath'); expect(debugConfig).to.have.property('python', pythonPath); expect(debugConfig).to.have.property('debugAdapterPython', pythonPath); @@ -188,6 +193,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => { expect(Object.keys(debugConfig!)).to.have.lengthOf.above(3); expect(debugConfig).to.have.property('type', 'python'); expect(debugConfig).to.have.property('request', 'launch'); + expect(debugConfig).to.have.property('clientOS', getClientOS()); expect(debugConfig).to.not.have.property('pythonPath'); expect(debugConfig).to.have.property('python', pythonPath); expect(debugConfig).to.have.property('debugAdapterPython', pythonPath); @@ -215,6 +221,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => { expect(Object.keys(debugConfig!)).to.have.lengthOf.above(3); expect(debugConfig).to.have.property('type', 'python'); expect(debugConfig).to.have.property('request', 'launch'); + expect(debugConfig).to.have.property('clientOS', getClientOS()); expect(debugConfig).to.not.have.property('pythonPath'); expect(debugConfig).to.have.property('python', pythonPath); expect(debugConfig).to.have.property('debugAdapterPython', pythonPath); @@ -239,6 +246,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => { expect(Object.keys(debugConfig!)).to.have.lengthOf.above(3); expect(debugConfig).to.have.property('type', 'python'); + expect(debugConfig).to.have.property('clientOS', getClientOS()); expect(debugConfig).to.not.have.property('pythonPath'); expect(debugConfig).to.have.property('python', pythonPath); expect(debugConfig).to.have.property('debugAdapterPython', pythonPath); @@ -264,6 +272,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => { expect(Object.keys(debugConfig!)).to.have.lengthOf.above(3); expect(debugConfig).to.have.property('type', 'python'); expect(debugConfig).to.have.property('request', 'launch'); + expect(debugConfig).to.have.property('clientOS', getClientOS()); expect(debugConfig).to.not.have.property('pythonPath'); expect(debugConfig).to.have.property('python', pythonPath); expect(debugConfig).to.have.property('debugAdapterPython', pythonPath); @@ -290,6 +299,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => { expect(Object.keys(debugConfig!)).to.have.lengthOf.above(3); expect(debugConfig).to.have.property('type', 'python'); expect(debugConfig).to.have.property('request', 'launch'); + expect(debugConfig).to.have.property('clientOS', getClientOS()); expect(debugConfig).to.not.have.property('pythonPath'); expect(debugConfig).to.have.property('python', pythonPath); expect(debugConfig).to.have.property('debugAdapterPython', pythonPath); @@ -692,6 +702,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => { }); expect(debugConfig).to.have.property('console', 'integratedTerminal'); + expect(debugConfig).to.have.property('clientOS', getClientOS()); expect(debugConfig).to.have.property('stopOnEntry', false); expect(debugConfig).to.have.property('showReturnValue', true); expect(debugConfig).to.have.property('debugOptions'); @@ -717,6 +728,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => { }); expect(debugConfig).to.have.property('stopOnEntry', false); + expect(debugConfig).to.have.property('clientOS', getClientOS()); expect(debugConfig).to.have.property('showReturnValue', true); expect(debugConfig).to.have.property('debugOptions'); expect((debugConfig as DebugConfiguration).debugOptions).to.be.deep.equal([]); @@ -736,6 +748,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => { }); expect(debugConfig).to.have.property('console', 'integratedTerminal'); + expect(debugConfig).to.have.property('clientOS', getClientOS()); expect(debugConfig).to.have.property('stopOnEntry', false); expect(debugConfig).to.have.property('showReturnValue', true); expect(debugConfig).to.have.property('redirectOutput', true); diff --git a/src/test/testing/common/debugLauncher.unit.test.ts b/src/test/testing/common/debugLauncher.unit.test.ts index dfe9e8ce5e99..b8841c380308 100644 --- a/src/test/testing/common/debugLauncher.unit.test.ts +++ b/src/test/testing/common/debugLauncher.unit.test.ts @@ -205,6 +205,9 @@ suite('Unit Tests - Debug Launcher', () => { if (!expected.python) { expected.python = 'python'; } + if (!expected.clientOS) { + expected.clientOS = isOs(OSType.Windows) ? 'windows' : 'unix'; + } if (!expected.debugAdapterPython) { expected.debugAdapterPython = 'python'; } From 9dc0613e8fa35811b8ab7c609471093e709bf71c Mon Sep 17 00:00:00 2001 From: Karthik Nadig Date: Wed, 8 Mar 2023 11:05:02 -0800 Subject: [PATCH 2/2] Fix typo with `clientOS` (#20819) --- .../debugger/extension/configuration/resolvers/attach.ts | 4 ++-- src/client/debugger/extension/configuration/resolvers/base.ts | 2 +- .../debugger/extension/configuration/resolvers/launch.ts | 2 +- src/client/debugger/types.ts | 1 + 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/client/debugger/extension/configuration/resolvers/attach.ts b/src/client/debugger/extension/configuration/resolvers/attach.ts index 096317bb065b..bdc72680d861 100644 --- a/src/client/debugger/extension/configuration/resolvers/attach.ts +++ b/src/client/debugger/extension/configuration/resolvers/attach.ts @@ -26,7 +26,7 @@ export class AttachConfigurationResolver extends BaseConfigurationResolver dbgConfig.debugOptions!.indexOf(item) === pos, ); } - if (debugConfiguration.clienOS === undefined) { + if (debugConfiguration.clientOS === undefined) { debugConfiguration.clientOS = getOSType() === OSType.Windows ? 'windows' : 'unix'; } return debugConfiguration; @@ -80,7 +80,7 @@ export class AttachConfigurationResolver extends BaseConfigurationResolver debugConfiguration: DebugConfiguration, _token?: CancellationToken, ): Promise { - if (debugConfiguration.clienOS === undefined) { + if (debugConfiguration.clientOS === undefined) { debugConfiguration.clientOS = getOSType() === OSType.Windows ? 'windows' : 'unix'; } return debugConfiguration as T; diff --git a/src/client/debugger/extension/configuration/resolvers/launch.ts b/src/client/debugger/extension/configuration/resolvers/launch.ts index 9513384f1277..485091119eb3 100644 --- a/src/client/debugger/extension/configuration/resolvers/launch.ts +++ b/src/client/debugger/extension/configuration/resolvers/launch.ts @@ -50,7 +50,7 @@ export class LaunchConfigurationResolver extends BaseConfigurationResolver