Skip to content

Commit

Permalink
Fix debug arg error (microsoft#23814)
Browse files Browse the repository at this point in the history
Set justMyCode only in the python debugger, not in the python extension.
Closed: microsoft/vscode-python-debugger#335
  • Loading branch information
paulacamargo25 authored and eleanorjboyd committed Jul 30, 2024
1 parent 9a9d4ab commit c326428
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 163 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,10 @@ export class AttachConfigurationResolver extends BaseConfigurationResolver<Attac
// Connect and listen cannot be mixed with host property.
debugConfiguration.host = 'localhost';
}
if (debugConfiguration.justMyCode === undefined) {
// Populate justMyCode using debugStdLib
debugConfiguration.justMyCode = !debugConfiguration.debugStdLib;
}
debugConfiguration.showReturnValue = debugConfiguration.showReturnValue !== false;
// Pass workspace folder so we can get this when we get debug events firing.
debugConfiguration.workspaceFolder = workspaceFolder ? workspaceFolder.fsPath : undefined;
const debugOptions = debugConfiguration.debugOptions!;
if (!debugConfiguration.justMyCode) {
AttachConfigurationResolver.debugOption(debugOptions, DebugOptions.DebugStdLib);
}
if (debugConfiguration.django) {
AttachConfigurationResolver.debugOption(debugOptions, DebugOptions.Django);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,7 @@ export class LaunchConfigurationResolver extends BaseConfigurationResolver<Launc
if (!Array.isArray(debugConfiguration.debugOptions)) {
debugConfiguration.debugOptions = [];
}
if (debugConfiguration.justMyCode === undefined) {
// Populate justMyCode using debugStdLib
debugConfiguration.justMyCode = !debugConfiguration.debugStdLib;
}
const debugOptions = debugConfiguration.debugOptions!;
if (!debugConfiguration.justMyCode) {
LaunchConfigurationResolver.debugOption(debugOptions, DebugOptions.DebugStdLib);
}
if (debugConfiguration.stopOnEntry) {
LaunchConfigurationResolver.debugOption(debugOptions, DebugOptions.StopOnEntry);
}
Expand Down
1 change: 0 additions & 1 deletion src/client/debugger/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export enum DebugOptions {
RedirectOutput = 'RedirectOutput',
Django = 'Django',
Jinja = 'Jinja',
DebugStdLib = 'DebugStdLib',
Sudo = 'Sudo',
Pyramid = 'Pyramid',
FixFilePathCase = 'FixFilePathCase',
Expand Down
2 changes: 0 additions & 2 deletions src/client/testing/common/debugLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ export class DebugLauncher implements ITestDebugLauncher {
) {
// cfg.pythonPath is handled by LaunchConfigurationResolver.

// Default value of justMyCode is not provided intentionally, for now we derive its value required for launchArgs using debugStdLib
// Have to provide it if and when we remove complete support for debugStdLib
if (!cfg.console) {
cfg.console = 'internalConsole';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,74 +496,5 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
expect(debugConfig).to.have.property('clientOS', getClientOS());
expect(debugConfig).to.have.property('debugOptions').to.be.deep.equal(expectedDebugOptions);
});

const testsForJustMyCode = [
{
justMyCode: false,
debugStdLib: true,
expectedResult: false,
},
{
justMyCode: false,
debugStdLib: false,
expectedResult: false,
},
{
justMyCode: false,
debugStdLib: undefined,
expectedResult: false,
},
{
justMyCode: true,
debugStdLib: false,
expectedResult: true,
},
{
justMyCode: true,
debugStdLib: true,
expectedResult: true,
},
{
justMyCode: true,
debugStdLib: undefined,
expectedResult: true,
},
{
justMyCode: undefined,
debugStdLib: false,
expectedResult: true,
},
{
justMyCode: undefined,
debugStdLib: true,
expectedResult: false,
},
{
justMyCode: undefined,
debugStdLib: undefined,
expectedResult: true,
},
];
test('Ensure justMyCode property is correctly derived from debugStdLib', async () => {
const activeFile = 'xyz.py';
const workspaceFolder = createMoqWorkspaceFolder(__dirname);
setupActiveEditor(activeFile, PYTHON_LANGUAGE);
const defaultWorkspace = path.join('usr', 'desktop');
setupWorkspaces([defaultWorkspace]);

const debugOptions = debugOptionsAvailable
.slice()
.concat(DebugOptions.Jinja, DebugOptions.Sudo) as DebugOptions[];

testsForJustMyCode.forEach(async (testParams) => {
const debugConfig = await resolveDebugConfiguration(workspaceFolder, {
...attach,
debugOptions,
justMyCode: testParams.justMyCode,
debugStdLib: testParams.debugStdLib,
});
expect(debugConfig).to.have.property('justMyCode', testParams.expectedResult);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -768,80 +768,13 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
expect(debugConfig).to.have.property('redirectOutput', true);
expect(debugConfig).to.have.property('justMyCode', false);
expect(debugConfig).to.have.property('debugOptions');
const expectedOptions = [
DebugOptions.DebugStdLib,
DebugOptions.ShowReturnValue,
DebugOptions.RedirectOutput,
];
const expectedOptions = [DebugOptions.ShowReturnValue, DebugOptions.RedirectOutput];
if (osType === platform.OSType.Windows) {
expectedOptions.push(DebugOptions.FixFilePathCase);
}
expect((debugConfig as DebugConfiguration).debugOptions).to.be.deep.equal(expectedOptions);
});

const testsForJustMyCode = [
{
justMyCode: false,
debugStdLib: true,
expectedResult: false,
},
{
justMyCode: false,
debugStdLib: false,
expectedResult: false,
},
{
justMyCode: false,
debugStdLib: undefined,
expectedResult: false,
},
{
justMyCode: true,
debugStdLib: false,
expectedResult: true,
},
{
justMyCode: true,
debugStdLib: true,
expectedResult: true,
},
{
justMyCode: true,
debugStdLib: undefined,
expectedResult: true,
},
{
justMyCode: undefined,
debugStdLib: false,
expectedResult: true,
},
{
justMyCode: undefined,
debugStdLib: true,
expectedResult: false,
},
{
justMyCode: undefined,
debugStdLib: undefined,
expectedResult: true,
},
];
test('Ensure justMyCode property is correctly derived from debugStdLib', async () => {
const pythonPath = `PythonPath_${new Date().toString()}`;
const workspaceFolder = createMoqWorkspaceFolder(__dirname);
const pythonFile = 'xyz.py';
setupIoc(pythonPath);
setupActiveEditor(pythonFile, PYTHON_LANGUAGE);
testsForJustMyCode.forEach(async (testParams) => {
const debugConfig = await resolveDebugConfiguration(workspaceFolder, {
...launch,
debugStdLib: testParams.debugStdLib,
justMyCode: testParams.justMyCode,
});
expect(debugConfig).to.have.property('justMyCode', testParams.expectedResult);
});
});

const testsForRedirectOutput = [
{
console: 'internalConsole',
Expand Down
9 changes: 0 additions & 9 deletions src/test/testing/common/debugLauncher.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,6 @@ suite('Unit Tests - Debug Launcher', () => {
}
expected.workspaceFolder = workspaceFolders[0].uri.fsPath;
expected.debugOptions = [];
if (expected.justMyCode === undefined) {
// Populate justMyCode using debugStdLib
expected.justMyCode = !expected.debugStdLib;
}
if (!expected.justMyCode) {
expected.debugOptions.push(DebugOptions.DebugStdLib);
}
if (expected.stopOnEntry) {
expected.debugOptions.push(DebugOptions.StopOnEntry);
}
Expand Down Expand Up @@ -379,7 +372,6 @@ suite('Unit Tests - Debug Launcher', () => {
envFile: 'some/dir/.env',
redirectOutput: false,
debugStdLib: true,
justMyCode: false,
// added by LaunchConfigurationResolver:
internalConsoleOptions: 'neverOpen',
subProcess: true,
Expand All @@ -399,7 +391,6 @@ suite('Unit Tests - Debug Launcher', () => {
envFile: expected.envFile,
redirectOutput: expected.redirectOutput,
debugStdLib: expected.debugStdLib,
justMyCode: undefined,
},
]);

Expand Down

0 comments on commit c326428

Please sign in to comment.