Skip to content

Commit

Permalink
Set clientOS debug option (microsoft#20805)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulacamargo25 authored and karthiknadig committed Mar 8, 2023
1 parent 38c2111 commit b577cec
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export class AttachConfigurationResolver extends BaseConfigurationResolver<Attac
(item, pos) => dbgConfig.debugOptions!.indexOf(item) === pos,
);
}
if (debugConfiguration.clienOS === undefined) {
debugConfiguration.clientOS = getOSType() === OSType.Windows ? 'windows' : 'unix';
}
return debugConfiguration;
}

Expand Down Expand Up @@ -77,10 +80,8 @@ export class AttachConfigurationResolver extends BaseConfigurationResolver<Attac
if (getOSType() === OSType.Windows && isLocalHost) {
AttachConfigurationResolver.debugOption(debugOptions, DebugOptions.FixFilePathCase);
}
if (getOSType() === OSType.Windows) {
AttachConfigurationResolver.debugOption(debugOptions, DebugOptions.WindowsClient);
} else {
AttachConfigurationResolver.debugOption(debugOptions, DebugOptions.UnixClient);
if (debugConfiguration.clienOS === undefined) {
debugConfiguration.clientOS = getOSType() === OSType.Windows ? 'windows' : 'unix';
}
if (debugConfiguration.showReturnValue) {
AttachConfigurationResolver.debugOption(debugOptions, DebugOptions.ShowReturnValue);
Expand Down
3 changes: 3 additions & 0 deletions src/client/debugger/extension/configuration/resolvers/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export abstract class BaseConfigurationResolver<T extends DebugConfiguration>
debugConfiguration: DebugConfiguration,
_token?: CancellationToken,
): Promise<T | undefined> {
if (debugConfiguration.clienOS === undefined) {
debugConfiguration.clientOS = getOSType() === OSType.Windows ? 'windows' : 'unix';
}
return debugConfiguration as T;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ export class LaunchConfigurationResolver extends BaseConfigurationResolver<Launc

const workspaceFolder = LaunchConfigurationResolver.getWorkspaceFolder(folder);
await this.resolveAndUpdatePaths(workspaceFolder, debugConfiguration);
if (debugConfiguration.clienOS === undefined) {
debugConfiguration.clientOS = getOSType() === OSType.Windows ? 'windows' : 'unix';
}
return debugConfiguration;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
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;
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
});

Expand All @@ -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');
});
Expand All @@ -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');
});
Expand All @@ -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');
Expand All @@ -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');
});
Expand Down Expand Up @@ -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);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<IConfigurationService>();
diagnosticsService = TypeMoq.Mock.ofType<IInvalidPythonPathInDebuggerService>();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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');
Expand All @@ -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([]);
Expand All @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/test/testing/common/debugLauncher.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down

0 comments on commit b577cec

Please sign in to comment.