Skip to content

Commit ef99517

Browse files
committed
introduce 'robotcode.robot.paths' and 'robotcode.robot.variableFiles' settings and launch properties
1 parent 73d611e commit ef99517

File tree

14 files changed

+537
-409
lines changed

14 files changed

+537
-409
lines changed

CHANGELOG.md

Lines changed: 388 additions & 383 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,16 @@
282282
"items": {
283283
"type": "string"
284284
},
285-
"description": "Specifies the arguments to be passed to robot module.",
285+
"description": "Specifies the arguments to be passed to robot.",
286+
"scope": "resource"
287+
},
288+
"robotcode.robot.paths": {
289+
"type": "array",
290+
"default": [],
291+
"items": {
292+
"type": "string"
293+
},
294+
"description": "Specifies the paths where robot/robotcode should discover tests. Corresponds to the 'paths' option of robot.",
286295
"scope": "resource"
287296
},
288297
"robotcode.robot.pythonPath": {
@@ -294,7 +303,7 @@
294303
"items": {
295304
"type": "string"
296305
},
297-
"description": "Specifies additional python paths to robotframework. Corresponds to the '--pythonpath' option of the robot module.",
306+
"description": "Specifies additional python paths for robotframework. Corresponds to the '--pythonpath' option of robot.",
298307
"scope": "resource"
299308
},
300309
"robotcode.robot.env": {
@@ -306,7 +315,16 @@
306315
"robotcode.robot.variables": {
307316
"type": "object",
308317
"default": {},
309-
"description": "Specifies the variables for robotframework. Corresponds to the '--variable name:value' option of the robot module.",
318+
"description": "Specifies the variables for robotframework. Corresponds to the '--variable name:value' option of robot.",
319+
"scope": "resource"
320+
},
321+
"robotcode.robot.variableFiles": {
322+
"type": "array",
323+
"default": [],
324+
"items": {
325+
"type": "string"
326+
},
327+
"description": "Specifies the variable files for robotframework. Corresponds to the '--variablefile' option of robot.",
310328
"scope": "resource"
311329
},
312330
"robotcode.robot.outputDir": {
@@ -324,8 +342,8 @@
324342
],
325343
"enumDescriptions": [
326344
"Mode is got from test/task header in data files.",
327-
"Turn on the generic automation mode. Corresponds to the '--rpa' option of the robot module.",
328-
"Force test automation mode. Corresponds to the '--norpa' option of the robot module."
345+
"Turn on the generic automation mode. Corresponds to the '--rpa' option of robot.",
346+
"Force test automation mode. Corresponds to the '--norpa' option of robot."
329347
],
330348
"description": "Specifies robot execution mode.",
331349
"default": "default",
@@ -514,6 +532,14 @@
514532
"description": "The .robot file or a folder containing .robot files to be launched.",
515533
"default": "${file}"
516534
},
535+
"paths": {
536+
"type": "array",
537+
"default": [],
538+
"items": {
539+
"type": "string"
540+
},
541+
"description": "Specifies the paths where robot should discover tests. Corresponds to the 'paths' option of robot."
542+
},
517543
"args": {
518544
"type": "array",
519545
"description": "Specifies additional command line arguments passed to robot.",
@@ -546,7 +572,7 @@
546572
},
547573
"dryRun": {
548574
"type": "boolean",
549-
"description": "Verifies test data and runs tests so that library keywords are not executed. Corresponds to the '--dryrun' option of the robot module.",
575+
"description": "Verifies test data and runs tests so that library keywords are not executed. Corresponds to the '--dryrun' option of robot.",
550576
"default": false
551577
},
552578
"python": {
@@ -556,7 +582,10 @@
556582
},
557583
"robotPythonPath": {
558584
"type": "array",
559-
"description": "Specifies additional python paths for robotframework. Corresponds to the '--pythonpath' option of the robot module.",
585+
"items": {
586+
"type": "string"
587+
},
588+
"description": "Specifies additional python paths for robotframework. Corresponds to the '--pythonpath' option of robot.",
560589
"default": []
561590
},
562591
"attachPython": {
@@ -572,7 +601,15 @@
572601
"variables": {
573602
"type": "object",
574603
"default": {},
575-
"description": "Specifies the variables for robotframework. Corresponds to the '--variable name:value' option of the robot module."
604+
"description": "Specifies the variables for robotframework. Corresponds to the '--variable name:value' option of robot."
605+
},
606+
"variableFiles": {
607+
"type": "array",
608+
"default": [],
609+
"items": {
610+
"type": "string"
611+
},
612+
"description": "Specifies the variable files for robotframework. Corresponds to the '--variablefile' option of robot."
576613
},
577614
"launcherArgs": {
578615
"type": "array",
@@ -613,8 +650,8 @@
613650
],
614651
"enumDescriptions": [
615652
"Mode is got from test/task header in data files.",
616-
"Turn on the generic automation mode. Corresponds to the '--rpa' option of the robot module.",
617-
"Force test automation mode. Corresponds to the '--norpa' option of the robot module."
653+
"Turn on the generic automation mode. Corresponds to the '--rpa' option of robot.",
654+
"Force test automation mode. Corresponds to the '--norpa' option of robot."
618655
],
619656
"description": "Specifies robot execution mode.",
620657
"default": "default"

robotcode/debugger/launcher/server.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ async def _launch(
125125
python: str,
126126
cwd: str = ".",
127127
target: Optional[str] = None,
128+
paths: Optional[List[str]] = None,
128129
args: Optional[List[str]] = None,
129130
env: Optional[Dict[str, Optional[Any]]] = None,
130131
console: Optional[Literal["internalConsole", "integratedTerminal", "externalTerminal"]] = "integratedTerminal",
@@ -140,9 +141,10 @@ async def _launch(
140141
outputLog: Optional[bool] = False,
141142
groupOutput: Optional[bool] = False,
142143
stopOnEntry: Optional[bool] = False, # noqa: N803
143-
arguments: Optional[LaunchRequestArguments] = None,
144144
dryRun: Optional[bool] = None,
145145
mode: Optional[str] = None,
146+
variableFiles: Optional[List[str]] = None,
147+
arguments: Optional[LaunchRequestArguments] = None,
146148
*_args: Any,
147149
**_kwargs: Any,
148150
) -> None:
@@ -197,12 +199,20 @@ async def _launch(
197199
for e in robotPythonPath:
198200
run_args += ["-P", e]
199201

202+
if variableFiles:
203+
for v in variableFiles:
204+
run_args += ["-V", v]
205+
200206
if variables:
201207
for k, v in variables.items():
202208
run_args += ["-v", f"{k}:{v}"]
203209

204210
run_args += args or []
205211

212+
if paths:
213+
for p in paths:
214+
run_args.append(p)
215+
206216
if target:
207217
run_args.append(target)
208218

robotcode/language_server/robotframework/configuration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class RobotConfig(ConfigBase):
1919
python_path: List[str] = field(default_factory=list)
2020
env: Dict[str, str] = field(default_factory=dict)
2121
variables: Dict[str, Any] = field(default_factory=dict)
22+
paths: List[str] = field(default_factory=list)
2223
output_dir: Optional[str] = None
2324
output_file: Optional[str] = None
2425
log_file: Optional[str] = None

robotcode/language_server/robotframework/parts/discovering.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
@dataclass(repr=False)
3030
class GetAllTestsParams(Model):
3131
workspace_folder: str
32-
paths: Optional[List[str]]
32+
paths: Optional[List[str]] = None
3333
suites: Optional[List[str]] = None
3434

3535

@@ -221,7 +221,8 @@ def generate(suite: TestSuite) -> TestItem:
221221
children.append(
222222
TestItem(
223223
type="test",
224-
id=f"{Path(test.source).resolve()};{test.longname};{test.lineno}",
224+
id=f"{Path(test.source).resolve() if test.source is not None else ''};"
225+
f"{test.longname};{test.lineno}",
225226
label=test.name,
226227
longname=test.longname,
227228
uri=str(Uri.from_path(test.source)) if test.source else None,
@@ -238,7 +239,7 @@ def generate(suite: TestSuite) -> TestItem:
238239

239240
return TestItem(
240241
type="suite",
241-
id=f"{Path(suite.source).resolve()};{suite.longname}",
242+
id=f"{Path(suite.source).resolve() if suite.source is not None else ''};{suite.longname}",
242243
label=suite.name,
243244
longname=suite.longname,
244245
uri=str(Uri.from_path(suite.source)) if suite.source else None,
@@ -257,6 +258,9 @@ def generate(suite: TestSuite) -> TestItem:
257258
config = await self.get_config(workspace_folder)
258259
mode = config.get_mode() if config is not None else None
259260

261+
if paths is None and config is not None:
262+
paths = config.paths
263+
260264
if paths and len(paths):
261265

262266
def normalize_paths(paths: List[str]) -> Iterator[str]:

robotcode/language_server/robotframework/parts/documents_cache.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,10 @@ async def default_imports_manager(self) -> ImportsManager:
305305
async def get_imports_manager(self, document: TextDocument) -> ImportsManager:
306306
folder = self.parent.workspace.get_workspace_folder(document.uri)
307307
if folder is None:
308-
return await self.default_imports_manager
308+
if len(self.parent.workspace.workspace_folders) == 1:
309+
folder = self.parent.workspace.workspace_folders[0]
310+
else:
311+
return await self.default_imports_manager
309312

310313
if folder not in self._imports_managers:
311314
async with self._imports_managers_lock:

tests/robotcode/language_server/robotframework/parts/data/.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@
2727
// "robotcode.debug.outputLog": true,
2828
// "robotcode.debug.outputMessages": true
2929
//"python.analysis.diagnosticMode": "workspace"
30+
"robotcode.robot.paths": ["./tests", "./tests1"]
3031
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*** Test Cases ***
2+
first
3+
Log blah
4+
Sleep 1s

tests/robotcode/language_server/robotframework/parts/test_references/test_references_robot_034_004_simple_keyword_call_.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,3 +1344,12 @@ result:
13441344
character: 69
13451345
line: 47
13461346
uri: tests/variables.robot
1347+
- !Location
1348+
range:
1349+
end:
1350+
character: 7
1351+
line: 2
1352+
start:
1353+
character: 4
1354+
line: 2
1355+
uri: tests1/first.robot

tests/robotcode/language_server/robotframework/parts/test_references/test_references_robot_034_005_simple_keyword_call_.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,3 +1344,12 @@ result:
13441344
character: 69
13451345
line: 47
13461346
uri: tests/variables.robot
1347+
- !Location
1348+
range:
1349+
end:
1350+
character: 7
1351+
line: 2
1352+
start:
1353+
character: 4
1354+
line: 2
1355+
uri: tests1/first.robot

0 commit comments

Comments
 (0)