Skip to content

Commit bc3243a

Browse files
committed
implement some more configuration settings for debugging, use debugpy from python extension
1 parent a41c341 commit bc3243a

File tree

4 files changed

+75
-9
lines changed

4 files changed

+75
-9
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to the "robotcode" extension will be documented in this file
44

55
## [Unreleased]
66

7+
### added
8+
9+
- update readme
10+
- add some more configuration options for show log and messages at running test in debug console
11+
- debug console now shows source and line number from log message
12+
- use debugpy coming from vscode python extension, no need to install debugpy separately
13+
714
## 0.2.7
815

916
### added

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ To speedup things you can install the platform dependent versions of the followi
6666

6767
Example:
6868

69+
```bash
6970
python -m pipenv install --dev pydantic orjson
70-
71+
```
7172

7273

package.json

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,36 @@
290290
"description": "Specifies the default configuration to run or debug robot tests.",
291291
"scope": "resource"
292292
},
293+
"robotcode.debug.attachPython": {
294+
"type": "boolean",
295+
"description": "Attach also the python debugger if a robot test starts.",
296+
"default": false,
297+
"scope": "resource"
298+
},
299+
"robotcode.debug.outputMessages": {
300+
"type": "boolean",
301+
"description": "Output messages from robotframework in debug console.",
302+
"default": false,
303+
"scope": "resource"
304+
},
305+
"robotcode.debug.outputLog": {
306+
"type": "boolean",
307+
"description": "Output log messages from robotframework in debug console.",
308+
"default": true,
309+
"scope": "resource"
310+
},
311+
"robotcode.debug.groupOutput": {
312+
"type": "boolean",
313+
"description": "Group start and stop suite/test/keyword messages in debug console.",
314+
"default": false,
315+
"scope": "resource"
316+
},
317+
"robotcode.debug.useExternalDebugpy": {
318+
"type": "boolean",
319+
"description": "Use the debugpy in python environment, not from the python extension.",
320+
"default": false,
321+
"scope": "resource"
322+
},
293323
"robotcode.debug.defaultConsole": {
294324
"type": "string",
295325
"enum": [
@@ -500,7 +530,7 @@
500530
"outputLog": {
501531
"type": "boolean",
502532
"description": "Output log messages from robotframework in debug console.",
503-
"default": false
533+
"default": true
504534
},
505535
"groupOutput": {
506536
"type": "boolean",
@@ -558,8 +588,8 @@
558588
"@types/mocha": "^9.0.0",
559589
"@types/node": "^16.10.2",
560590
"@types/vscode": "^1.60.0",
561-
"@typescript-eslint/eslint-plugin": "^4.32.0",
562-
"@typescript-eslint/parser": "^4.32.0",
591+
"@typescript-eslint/eslint-plugin": "^4.33.0",
592+
"@typescript-eslint/parser": "^4.33.0",
563593
"eslint": "^7.32.0",
564594
"eslint-config-airbnb": "^18.2.1",
565595
"eslint-config-prettier": "^8.3.0",
@@ -582,7 +612,7 @@
582612
"vscode-debugadapter-testsupport": "^1.49.0",
583613
"vscode-dts": "^0.3.1",
584614
"vscode-test": "^1.6.1",
585-
"webpack": "^5.56.0",
615+
"webpack": "^5.56.1",
586616
"webpack-cli": "^4.8.0"
587617
}
588618
}

vscode-client/debugmanager.ts

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,19 @@ const DEBUG_ADAPTER_DEFAULT_HOST = "127.0.0.1";
1111
class RobotCodeDebugConfigurationProvider implements vscode.DebugConfigurationProvider {
1212
constructor(private readonly pythonManager: PythonManager) {}
1313

14-
resolveDebugConfigurationWithSubstitutedVariables?(
14+
resolveDebugConfigurationWithSubstitutedVariables(
1515
folder: vscode.WorkspaceFolder | undefined,
1616
debugConfiguration: vscode.DebugConfiguration,
1717
_token?: vscode.CancellationToken
1818
): vscode.ProviderResult<vscode.DebugConfiguration> {
19+
return this._resolveDebugConfigurationWithSubstitutedVariablesAsync(folder, debugConfiguration, _token);
20+
}
21+
22+
async _resolveDebugConfigurationWithSubstitutedVariablesAsync(
23+
folder: vscode.WorkspaceFolder | undefined,
24+
debugConfiguration: vscode.DebugConfiguration,
25+
_token?: vscode.CancellationToken
26+
): Promise<vscode.DebugConfiguration> {
1927
const config = vscode.workspace.getConfiguration(CONFIG_SECTION, folder);
2028

2129
try {
@@ -46,14 +54,34 @@ class RobotCodeDebugConfigurationProvider implements vscode.DebugConfigurationPr
4654
debugConfiguration.outputDir =
4755
debugConfiguration?.outputDir ?? config.get<string | undefined>("robot.outputDir", undefined);
4856

49-
// if (pythonDebugpyPath) {
50-
// debugConfiguration.env = { PYTHONPATH: path.dirname(pythonDebugpyPath), ...debugConfiguration.env };
51-
// }
57+
debugConfiguration.attachPython = debugConfiguration?.attachPython ?? config.get<boolean>("debug.attachPython");
58+
59+
debugConfiguration.outputMessages =
60+
debugConfiguration?.outputMessages ?? config.get<boolean>("debug.outputMessages");
61+
62+
debugConfiguration.outputLog = debugConfiguration?.outputLog ?? config.get<boolean>("debug.outputLog");
63+
64+
debugConfiguration.groupOutput = debugConfiguration?.groupOutput ?? config.get<boolean>("debug.groupOutput");
5265

5366
if (!debugConfiguration.attachPython || debugConfiguration.noDebug) {
5467
debugConfiguration.attachPython = false;
5568
}
5669

70+
if (debugConfiguration.attachPython && !config.get<boolean>("debug.useExternalDebugpy")) {
71+
const debugpyPath = await this.pythonManager.pythonExtension?.exports.debug.getDebuggerPackagePath();
72+
73+
if (debugpyPath) {
74+
const env = debugConfiguration.env ?? {};
75+
const envPythonPath: string = env.PYTHONPATH || "";
76+
77+
env.PYTHONPATH = [
78+
path.dirname(debugpyPath),
79+
...(envPythonPath ? envPythonPath.split(path.delimiter) : []),
80+
].join(path.delimiter);
81+
debugConfiguration.env = env;
82+
}
83+
}
84+
5785
const template = config.get("debug.defaultConfiguration", {});
5886

5987
return { ...template, ...debugConfiguration };

0 commit comments

Comments
 (0)