Skip to content

Commit e9ff78d

Browse files
Set clientOS debug option (#20805)
Closed: #20407
1 parent 467823d commit e9ff78d

File tree

6 files changed

+38
-7
lines changed

6 files changed

+38
-7
lines changed

src/client/debugger/extension/configuration/resolvers/attach.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export class AttachConfigurationResolver extends BaseConfigurationResolver<Attac
2626
(item, pos) => dbgConfig.debugOptions!.indexOf(item) === pos,
2727
);
2828
}
29+
if (debugConfiguration.clienOS === undefined) {
30+
debugConfiguration.clientOS = getOSType() === OSType.Windows ? 'windows' : 'unix';
31+
}
2932
return debugConfiguration;
3033
}
3134

@@ -77,10 +80,8 @@ export class AttachConfigurationResolver extends BaseConfigurationResolver<Attac
7780
if (getOSType() === OSType.Windows && isLocalHost) {
7881
AttachConfigurationResolver.debugOption(debugOptions, DebugOptions.FixFilePathCase);
7982
}
80-
if (getOSType() === OSType.Windows) {
81-
AttachConfigurationResolver.debugOption(debugOptions, DebugOptions.WindowsClient);
82-
} else {
83-
AttachConfigurationResolver.debugOption(debugOptions, DebugOptions.UnixClient);
83+
if (debugConfiguration.clienOS === undefined) {
84+
debugConfiguration.clientOS = getOSType() === OSType.Windows ? 'windows' : 'unix';
8485
}
8586
if (debugConfiguration.showReturnValue) {
8687
AttachConfigurationResolver.debugOption(debugOptions, DebugOptions.ShowReturnValue);

src/client/debugger/extension/configuration/resolvers/base.ts

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ export abstract class BaseConfigurationResolver<T extends DebugConfiguration>
4646
debugConfiguration: DebugConfiguration,
4747
_token?: CancellationToken,
4848
): Promise<T | undefined> {
49+
if (debugConfiguration.clienOS === undefined) {
50+
debugConfiguration.clientOS = getOSType() === OSType.Windows ? 'windows' : 'unix';
51+
}
4952
return debugConfiguration as T;
5053
}
5154

src/client/debugger/extension/configuration/resolvers/launch.ts

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ export class LaunchConfigurationResolver extends BaseConfigurationResolver<Launc
5050

5151
const workspaceFolder = LaunchConfigurationResolver.getWorkspaceFolder(folder);
5252
await this.resolveAndUpdatePaths(workspaceFolder, debugConfiguration);
53+
if (debugConfiguration.clienOS === undefined) {
54+
debugConfiguration.clientOS = getOSType() === OSType.Windows ? 'windows' : 'unix';
55+
}
5356
return debugConfiguration;
5457
}
5558

src/test/debugger/extension/configuration/resolvers/attach.unit.test.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
2626
const options = [DebugOptions.RedirectOutput];
2727
if (osType === platform.OSType.Windows) {
2828
options.push(DebugOptions.FixFilePathCase);
29-
options.push(DebugOptions.WindowsClient);
30-
} else {
31-
options.push(DebugOptions.UnixClient);
3229
}
3330
options.push(DebugOptions.ShowReturnValue);
31+
3432
return options;
3533
}
3634

@@ -76,6 +74,10 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
7674
}
7775
}
7876

77+
function getClientOS() {
78+
return osType === platform.OSType.Windows ? 'windows' : 'unix';
79+
}
80+
7981
function setupWorkspaces(folders: string[]) {
8082
const workspaceFolders = folders.map(createMoqWorkspaceFolder);
8183
getWorkspaceFoldersStub.returns(workspaceFolders);
@@ -119,6 +121,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
119121

120122
expect(Object.keys(debugConfig!)).to.have.lengthOf.above(3);
121123
expect(debugConfig).to.have.property('request', 'attach');
124+
expect(debugConfig).to.have.property('clientOS', getClientOS());
122125
expect(debugConfig).to.have.property('debugOptions').deep.equal(debugOptionsAvailable);
123126
});
124127

@@ -134,6 +137,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
134137

135138
expect(Object.keys(debugConfig!)).to.have.lengthOf.least(3);
136139
expect(debugConfig).to.have.property('request', 'attach');
140+
expect(debugConfig).to.have.property('clientOS', getClientOS());
137141
expect(debugConfig).to.have.property('debugOptions').deep.equal(debugOptionsAvailable);
138142
expect(debugConfig).to.have.property('host', 'localhost');
139143
});
@@ -148,6 +152,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
148152

149153
expect(Object.keys(debugConfig!)).to.have.lengthOf.least(3);
150154
expect(debugConfig).to.have.property('request', 'attach');
155+
expect(debugConfig).to.have.property('clientOS', getClientOS());
151156
expect(debugConfig).to.have.property('debugOptions').deep.equal(debugOptionsAvailable);
152157
expect(debugConfig).to.have.property('host', 'localhost');
153158
});
@@ -164,6 +169,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
164169

165170
expect(Object.keys(debugConfig!)).to.have.lengthOf.least(3);
166171
expect(debugConfig).to.have.property('request', 'attach');
172+
expect(debugConfig).to.have.property('clientOS', getClientOS());
167173
expect(debugConfig).to.have.property('debugOptions').deep.equal(debugOptionsAvailable);
168174
expect(debugConfig).to.not.have.property('localRoot');
169175
expect(debugConfig).to.have.property('host', 'localhost');
@@ -181,6 +187,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
181187

182188
expect(Object.keys(debugConfig!)).to.have.lengthOf.least(3);
183189
expect(debugConfig).to.have.property('request', 'attach');
190+
expect(debugConfig).to.have.property('clientOS', getClientOS());
184191
expect(debugConfig).to.have.property('debugOptions').deep.equal(debugOptionsAvailable);
185192
expect(debugConfig).to.have.property('host', 'localhost');
186193
});
@@ -486,6 +493,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
486493
debugOptions,
487494
});
488495

496+
expect(debugConfig).to.have.property('clientOS', getClientOS());
489497
expect(debugConfig).to.have.property('debugOptions').to.be.deep.equal(expectedDebugOptions);
490498
});
491499

src/test/debugger/extension/configuration/resolvers/launch.unit.test.ts

+13
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
5858
return folder.object;
5959
}
6060

61+
function getClientOS() {
62+
return osType === platform.OSType.Windows ? 'windows' : 'unix';
63+
}
64+
6165
function setupIoc(pythonPath: string, workspaceFolder?: WorkspaceFolder) {
6266
configService = TypeMoq.Mock.ofType<IConfigurationService>();
6367
diagnosticsService = TypeMoq.Mock.ofType<IInvalidPythonPathInDebuggerService>();
@@ -160,6 +164,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
160164
expect(Object.keys(debugConfig!)).to.have.lengthOf.above(3);
161165
expect(debugConfig).to.have.property('type', 'python');
162166
expect(debugConfig).to.have.property('request', 'launch');
167+
expect(debugConfig).to.have.property('clientOS', getClientOS());
163168
expect(debugConfig).to.not.have.property('pythonPath');
164169
expect(debugConfig).to.have.property('python', pythonPath);
165170
expect(debugConfig).to.have.property('debugAdapterPython', pythonPath);
@@ -188,6 +193,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
188193
expect(Object.keys(debugConfig!)).to.have.lengthOf.above(3);
189194
expect(debugConfig).to.have.property('type', 'python');
190195
expect(debugConfig).to.have.property('request', 'launch');
196+
expect(debugConfig).to.have.property('clientOS', getClientOS());
191197
expect(debugConfig).to.not.have.property('pythonPath');
192198
expect(debugConfig).to.have.property('python', pythonPath);
193199
expect(debugConfig).to.have.property('debugAdapterPython', pythonPath);
@@ -215,6 +221,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
215221
expect(Object.keys(debugConfig!)).to.have.lengthOf.above(3);
216222
expect(debugConfig).to.have.property('type', 'python');
217223
expect(debugConfig).to.have.property('request', 'launch');
224+
expect(debugConfig).to.have.property('clientOS', getClientOS());
218225
expect(debugConfig).to.not.have.property('pythonPath');
219226
expect(debugConfig).to.have.property('python', pythonPath);
220227
expect(debugConfig).to.have.property('debugAdapterPython', pythonPath);
@@ -239,6 +246,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
239246

240247
expect(Object.keys(debugConfig!)).to.have.lengthOf.above(3);
241248
expect(debugConfig).to.have.property('type', 'python');
249+
expect(debugConfig).to.have.property('clientOS', getClientOS());
242250
expect(debugConfig).to.not.have.property('pythonPath');
243251
expect(debugConfig).to.have.property('python', pythonPath);
244252
expect(debugConfig).to.have.property('debugAdapterPython', pythonPath);
@@ -264,6 +272,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
264272
expect(Object.keys(debugConfig!)).to.have.lengthOf.above(3);
265273
expect(debugConfig).to.have.property('type', 'python');
266274
expect(debugConfig).to.have.property('request', 'launch');
275+
expect(debugConfig).to.have.property('clientOS', getClientOS());
267276
expect(debugConfig).to.not.have.property('pythonPath');
268277
expect(debugConfig).to.have.property('python', pythonPath);
269278
expect(debugConfig).to.have.property('debugAdapterPython', pythonPath);
@@ -290,6 +299,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
290299
expect(Object.keys(debugConfig!)).to.have.lengthOf.above(3);
291300
expect(debugConfig).to.have.property('type', 'python');
292301
expect(debugConfig).to.have.property('request', 'launch');
302+
expect(debugConfig).to.have.property('clientOS', getClientOS());
293303
expect(debugConfig).to.not.have.property('pythonPath');
294304
expect(debugConfig).to.have.property('python', pythonPath);
295305
expect(debugConfig).to.have.property('debugAdapterPython', pythonPath);
@@ -692,6 +702,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
692702
});
693703

694704
expect(debugConfig).to.have.property('console', 'integratedTerminal');
705+
expect(debugConfig).to.have.property('clientOS', getClientOS());
695706
expect(debugConfig).to.have.property('stopOnEntry', false);
696707
expect(debugConfig).to.have.property('showReturnValue', true);
697708
expect(debugConfig).to.have.property('debugOptions');
@@ -717,6 +728,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
717728
});
718729

719730
expect(debugConfig).to.have.property('stopOnEntry', false);
731+
expect(debugConfig).to.have.property('clientOS', getClientOS());
720732
expect(debugConfig).to.have.property('showReturnValue', true);
721733
expect(debugConfig).to.have.property('debugOptions');
722734
expect((debugConfig as DebugConfiguration).debugOptions).to.be.deep.equal([]);
@@ -736,6 +748,7 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
736748
});
737749

738750
expect(debugConfig).to.have.property('console', 'integratedTerminal');
751+
expect(debugConfig).to.have.property('clientOS', getClientOS());
739752
expect(debugConfig).to.have.property('stopOnEntry', false);
740753
expect(debugConfig).to.have.property('showReturnValue', true);
741754
expect(debugConfig).to.have.property('redirectOutput', true);

src/test/testing/common/debugLauncher.unit.test.ts

+3
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ suite('Unit Tests - Debug Launcher', () => {
205205
if (!expected.python) {
206206
expected.python = 'python';
207207
}
208+
if (!expected.clientOS) {
209+
expected.clientOS = isOs(OSType.Windows) ? 'windows' : 'unix';
210+
}
208211
if (!expected.debugAdapterPython) {
209212
expected.debugAdapterPython = 'python';
210213
}

0 commit comments

Comments
 (0)