Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 618f6d7

Browse files
karthiknadigDonJayamanne
authored andcommitted
Add support for ShowReturnValue Debugger setting (microsoft#2852)
* Add showReturnValue debugger setting * Update tests to support showReturnValue setting * Address comments
1 parent 5507f5d commit 618f6d7

File tree

12 files changed

+38
-12
lines changed

12 files changed

+38
-12
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ obj/**
2222
.pytest_cache
2323
tmp/**
2424
.python-version
25+
.vs/

news/1 Enhancements/2463.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added a debugger setting to show return values of functions while stepping.

package.json

+5
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,11 @@
490490
"description": "Automatically stop after launch.",
491491
"default": false
492492
},
493+
"showReturnValue": {
494+
"type": "boolean",
495+
"description": "Show return value of functions when stepping.",
496+
"default": false
497+
},
493498
"console": {
494499
"enum": [
495500
"none",

src/client/debugger/debugAdapter/DebugClients/LocalDebugClient.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import { DebugClientHelper } from './helper';
2020
const VALID_DEBUG_OPTIONS = [
2121
'RedirectOutput',
2222
'DebugStdLib',
23-
'stopOnEntry',
23+
'StopOnEntry',
24+
'ShowReturnValue',
2425
'BreakOnSystemExitZero',
2526
'DjangoDebugging',
2627
'Django'];

src/client/debugger/extension/configProviders/baseProvider.ts

+3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ export abstract class BaseConfigurationProvider implements DebugConfigurationPro
7272
if (typeof debugConfiguration.stopOnEntry !== 'boolean') {
7373
debugConfiguration.stopOnEntry = false;
7474
}
75+
if (typeof debugConfiguration.showReturnValue !== 'boolean') {
76+
debugConfiguration.showReturnValue = false;
77+
}
7578
if (!debugConfiguration.console) {
7679
debugConfiguration.console = 'integratedTerminal';
7780
}

src/client/debugger/extension/configProviders/pythonV2Provider.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export class PythonV2DebugConfigurationProvider extends BaseConfigurationProvide
2828
if (debugConfiguration.stopOnEntry) {
2929
this.debugOption(debugOptions, DebugOptions.StopOnEntry);
3030
}
31+
if (debugConfiguration.showReturnValue) {
32+
this.debugOption(debugOptions, DebugOptions.ShowReturnValue);
33+
}
3134
if (debugConfiguration.django) {
3235
this.debugOption(debugOptions, DebugOptions.Django);
3336
}
@@ -136,7 +139,8 @@ export class PythonV2DebugConfigurationProvider extends BaseConfigurationProvide
136139
isSudo: !!debugConfiguration.sudo,
137140
jinja: !!debugConfiguration.jinja,
138141
pyramid: !!debugConfiguration.pyramid,
139-
stopOnEntry: !!debugConfiguration.stopOnEntry
142+
stopOnEntry: !!debugConfiguration.stopOnEntry,
143+
showReturnValue: !!debugConfiguration.showReturnValue
140144
};
141145
sendTelemetryEvent(DEBUGGER, undefined, telemetryProps);
142146
}

src/client/debugger/types.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export enum DebugOptions {
1717
FixFilePathCase = 'FixFilePathCase',
1818
WindowsClient = 'WindowsClient',
1919
UnixClient = 'UnixClient',
20-
StopOnEntry = 'StopOnEntry'
20+
StopOnEntry = 'StopOnEntry',
21+
ShowReturnValue = 'ShowReturnValue'
2122
}
2223

2324
// tslint:disable-next-line:interface-name
@@ -30,6 +31,7 @@ interface AdditionalLaunchDebugOptions {
3031
sudo?: boolean;
3132
pyramid?: boolean;
3233
stopOnEntry?: boolean;
34+
showReturnValue?: boolean;
3335
}
3436

3537
// tslint:disable-next-line:interface-name
@@ -50,6 +52,8 @@ export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArgum
5052
pythonPath: string;
5153
// Automatically stop target after launch. If not specified, target does not stop.
5254
stopOnEntry?: boolean;
55+
/** Show return values of functions while stepping. */
56+
showReturnValue?: boolean;
5357
args: string[];
5458
cwd?: string;
5559
debugOptions?: DebugOptions[];

src/client/telemetry/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export type DebuggerTelemetryV2 = {
5555
isModule: boolean;
5656
isSudo: boolean;
5757
stopOnEntry: boolean;
58+
showReturnValue: boolean;
5859
pyramid: boolean;
5960
};
6061
export type DebuggerPerformanceTelemetry = {

src/test/debugger/configProvider/provider.unit.test.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,9 @@ suite('Debugging - Config Provider', () => {
270270

271271
expect(debugConfig).to.have.property('console', 'integratedTerminal');
272272
expect(debugConfig).to.have.property('stopOnEntry', false);
273+
expect(debugConfig).to.have.property('showReturnValue', false);
273274
expect(debugConfig).to.have.property('debugOptions');
274-
expect((debugConfig as any).debugOptions).to.be.deep.equal(['RedirectOutput']);
275+
expect((debugConfig as any).debugOptions).to.be.deep.equal([DebugOptions.RedirectOutput]);
275276
});
276277
test('Test defaults of python debugger', async () => {
277278
if ('python' === DebuggerTypeName) {
@@ -286,6 +287,7 @@ suite('Debugging - Config Provider', () => {
286287
const debugConfig = await debugProvider.resolveDebugConfiguration!(workspaceFolder, {} as DebugConfiguration);
287288

288289
expect(debugConfig).to.have.property('stopOnEntry', false);
290+
expect(debugConfig).to.have.property('showReturnValue', false);
289291
expect(debugConfig).to.have.property('debugOptions');
290292
expect((debugConfig as any).debugOptions).to.be.deep.equal([DebugOptions.RedirectOutput]);
291293
});
@@ -300,6 +302,7 @@ suite('Debugging - Config Provider', () => {
300302

301303
expect(debugConfig).to.have.property('console', 'integratedTerminal');
302304
expect(debugConfig).to.have.property('stopOnEntry', false);
305+
expect(debugConfig).to.have.property('showReturnValue', false);
303306
expect(debugConfig).to.have.property('debugOptions');
304307
expect((debugConfig as any).debugOptions).to.be.deep.equal([]);
305308
});

src/test/debugger/misc.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,14 @@ suite(`Standard Debugging - Misc tests: ${debuggerType}`, () => {
5656
return new DebugClientEx(testAdapterFilePath, debuggerType, coverageDirectory, { cwd: EXTENSION_ROOT_DIR });
5757
}
5858
}
59-
function buildLaunchArgs(pythonFile: string, stopOnEntry: boolean = false): LaunchRequestArguments {
59+
function buildLaunchArgs(pythonFile: string, stopOnEntry: boolean = false, showReturnValue: boolean = false): LaunchRequestArguments {
6060
const env = { PYTHONPATH: PTVSD_PATH };
6161
// tslint:disable-next-line:no-unnecessary-local-variable
6262
const options = {
6363
program: path.join(debugFilesPath, pythonFile),
6464
cwd: debugFilesPath,
6565
stopOnEntry,
66+
showReturnValue,
6667
debugOptions: [DebugOptions.RedirectOutput],
6768
pythonPath: PYTHON_PATH,
6869
args: [],

src/test/debugger/portAndHost.test.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ suite(`Standard Debugging of ports and hosts: ${debuggerType}`, () => {
4444
} catch (ex) { }
4545
});
4646

47-
function buildLauncArgs(pythonFile: string, stopOnEntry: boolean = false, port?: number, host?: string): LaunchRequestArguments {
47+
function buildLaunchArgs(pythonFile: string, stopOnEntry: boolean = false, port?: number, host?: string, showReturnValue: boolean = false): LaunchRequestArguments {
4848
return {
4949
program: path.join(debugFilesPath, pythonFile),
5050
cwd: debugFilesPath,
5151
stopOnEntry,
52+
showReturnValue,
5253
logToFile: true,
5354
debugOptions: [DebugOptions.RedirectOutput],
5455
pythonPath: PYTHON_PATH,
@@ -64,7 +65,7 @@ suite(`Standard Debugging of ports and hosts: ${debuggerType}`, () => {
6465
async function testDebuggingWithProvidedPort(port?: number | undefined, host?: string | undefined) {
6566
await Promise.all([
6667
debugClient.configurationSequence(),
67-
debugClient.launch(buildLauncArgs('startAndWait.py', false, port, host)),
68+
debugClient.launch(buildLaunchArgs('startAndWait.py', false, port, host)),
6869
debugClient.waitForEvent('initialized')
6970
]);
7071

src/test/debugger/run.test.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@ suite('Run without Debugging', () => {
4040
} catch (ex) { }
4141
await sleep(1000);
4242
});
43-
function buildLauncArgs(pythonFile: string, stopOnEntry: boolean = false): LaunchRequestArguments {
43+
function buildLaunchArgs(pythonFile: string, stopOnEntry: boolean = false, showReturnValue: boolean = false): LaunchRequestArguments {
4444
// tslint:disable-next-line:no-unnecessary-local-variable
4545
return {
4646
program: path.join(debugFilesPath, pythonFile),
4747
cwd: debugFilesPath,
4848
stopOnEntry,
49+
showReturnValue,
4950
noDebug: true,
5051
debugOptions: [DebugOptions.RedirectOutput],
5152
pythonPath: PYTHON_PATH,
@@ -62,15 +63,15 @@ suite('Run without Debugging', () => {
6263
test('Should run program to the end', async () => {
6364
await Promise.all([
6465
debugClient.configurationSequence(),
65-
debugClient.launch(buildLauncArgs('simplePrint.py', false)),
66+
debugClient.launch(buildLaunchArgs('simplePrint.py', false)),
6667
debugClient.waitForEvent('initialized'),
6768
debugClient.waitForEvent('terminated')
6869
]);
6970
});
7071
test('test stderr output for Python', async () => {
7172
await Promise.all([
7273
debugClient.configurationSequence(),
73-
debugClient.launch(buildLauncArgs('stdErrOutput.py', false)),
74+
debugClient.launch(buildLaunchArgs('stdErrOutput.py', false)),
7475
debugClient.waitForEvent('initialized'),
7576
debugClient.assertOutput('stderr', 'error output'),
7677
debugClient.waitForEvent('terminated')
@@ -79,7 +80,7 @@ suite('Run without Debugging', () => {
7980
test('Test stdout output', async () => {
8081
await Promise.all([
8182
debugClient.configurationSequence(),
82-
debugClient.launch(buildLauncArgs('stdOutOutput.py', false)),
83+
debugClient.launch(buildLaunchArgs('stdOutOutput.py', false)),
8384
debugClient.waitForEvent('initialized'),
8485
debugClient.assertOutput('stdout', 'normal output'),
8586
debugClient.waitForEvent('terminated')
@@ -102,7 +103,7 @@ suite('Run without Debugging', () => {
102103
});
103104
await Promise.all([
104105
debugClient.configurationSequence(),
105-
debugClient.launch(buildLauncArgs('sampleWithSleep.py', false)),
106+
debugClient.launch(buildLaunchArgs('sampleWithSleep.py', false)),
106107
debugClient.waitForEvent('initialized'),
107108
processIdOutput
108109
]);

0 commit comments

Comments
 (0)