Skip to content

Commit 6b84986

Browse files
committed
feat: support for new --parseinclude option in robot config
1 parent 8622099 commit 6b84986

File tree

5 files changed

+163
-13
lines changed

5 files changed

+163
-13
lines changed

etc/robot.toml.json

Lines changed: 118 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,25 @@
373373
"null"
374374
]
375375
},
376+
"extra-parse-include": {
377+
"default": null,
378+
"description": "Appends entries to the --parseinclude option.\n\nParse only files matching `pattern`. It can be:\n- a file name or pattern like `example.robot` or\n`*.robot` to parse all files matching that name,\n- a file path like `path/to/example.robot`, or\n- a directory path like `path/to/example` to parse\nall files in that directory, recursively.\n\ncorresponds to the `-I --parseinclude pattern *` option of _robot_\n",
379+
"items": {
380+
"anyOf": [
381+
{
382+
"type": "string"
383+
},
384+
{
385+
"$ref": "#/definitions/StringExpression"
386+
}
387+
]
388+
},
389+
"title": "Extra parse include",
390+
"type": [
391+
"array",
392+
"null"
393+
]
394+
},
376395
"extra-pre-rebot-modifiers": {
377396
"additionalProperties": {
378397
"items": {
@@ -823,6 +842,25 @@
823842
"description": "Where to create output files. The default is the\ndirectory where tests are run from and the given path\nis considered relative to that unless it is absolute.\n\ncorresponds to the `-d --outputdir dir` option of _robot_\n",
824843
"title": "Output dir"
825844
},
845+
"parse-include": {
846+
"default": null,
847+
"description": "Parse only files matching `pattern`. It can be:\n- a file name or pattern like `example.robot` or\n`*.robot` to parse all files matching that name,\n- a file path like `path/to/example.robot`, or\n- a directory path like `path/to/example` to parse\nall files in that directory, recursively.\n\ncorresponds to the `-I --parseinclude pattern *` option of _robot_\n",
848+
"items": {
849+
"anyOf": [
850+
{
851+
"type": "string"
852+
},
853+
{
854+
"$ref": "#/definitions/StringExpression"
855+
}
856+
]
857+
},
858+
"title": "Parse include",
859+
"type": [
860+
"array",
861+
"null"
862+
]
863+
},
826864
"pre-rebot-modifiers": {
827865
"additionalProperties": {
828866
"items": {
@@ -1689,6 +1727,25 @@
16891727
"null"
16901728
]
16911729
},
1730+
"extra-parse-include": {
1731+
"default": null,
1732+
"description": "Appends entries to the --parseinclude option.\n\nParse only files matching `pattern`. It can be:\n- a file name or pattern like `example.robot` or\n`*.robot` to parse all files matching that name,\n- a file path like `path/to/example.robot`, or\n- a directory path like `path/to/example` to parse\nall files in that directory, recursively.\n\ncorresponds to the `-I --parseinclude pattern *` option of _robot_\n",
1733+
"items": {
1734+
"anyOf": [
1735+
{
1736+
"type": "string"
1737+
},
1738+
{
1739+
"$ref": "#/definitions/StringExpression"
1740+
}
1741+
]
1742+
},
1743+
"title": "Extra parse include",
1744+
"type": [
1745+
"array",
1746+
"null"
1747+
]
1748+
},
16921749
"extra-parsers": {
16931750
"additionalProperties": {
16941751
"items": {
@@ -2077,7 +2134,7 @@
20772134
]
20782135
},
20792136
"default": null,
2080-
"description": "Appends entries to the --variable option.\n\nSet variables in the test data. Only scalar\nvariables with string value are supported and name is\ngiven without `${}`. See --variablefile for a more\npowerful variable setting mechanism.\n\nExamples:\n\n```\n--variable str:Hello => ${str} = `Hello`\n-v hi:Hi_World -E space:_ => ${hi} = `Hi World`\n-v x: -v y:42 => ${x} = ``, ${y} = `42`\n```\n\ncorresponds to the `-v --variable name:value *` option of _rebot_\n",
2137+
"description": "Appends entries to the --variable option.\n\nSet variables in the test data. Only scalar\nvariables with string value are supported and name is\ngiven without `${}`. See --variablefile for a more\npowerful variable setting mechanism.\n\nExamples:\n\n```\n--variable name:Robot => ${name} = `Robot`\n-v \"hello:Hello world\" => ${hello} = `Hello world`\n-v x: -v y:42 => ${x} = ``, ${y} = `42`\n```\n\ncorresponds to the `-v --variable name:value *` option of _rebot_\n",
20812138
"title": "Extra variables",
20822139
"type": [
20832140
"object",
@@ -2339,6 +2396,25 @@
23392396
"description": "Where to create output files. The default is the\ndirectory where tests are run from and the given path\nis considered relative to that unless it is absolute.\n\ncorresponds to the `-d --outputdir dir` option of _robot_\n",
23402397
"title": "Output dir"
23412398
},
2399+
"parse-include": {
2400+
"default": null,
2401+
"description": "Parse only files matching `pattern`. It can be:\n- a file name or pattern like `example.robot` or\n`*.robot` to parse all files matching that name,\n- a file path like `path/to/example.robot`, or\n- a directory path like `path/to/example` to parse\nall files in that directory, recursively.\n\ncorresponds to the `-I --parseinclude pattern *` option of _robot_\n",
2402+
"items": {
2403+
"anyOf": [
2404+
{
2405+
"type": "string"
2406+
},
2407+
{
2408+
"$ref": "#/definitions/StringExpression"
2409+
}
2410+
]
2411+
},
2412+
"title": "Parse include",
2413+
"type": [
2414+
"array",
2415+
"null"
2416+
]
2417+
},
23422418
"parsers": {
23432419
"additionalProperties": {
23442420
"items": {
@@ -2993,7 +3069,7 @@
29933069
]
29943070
},
29953071
"default": null,
2996-
"description": "Set variables in the test data. Only scalar\nvariables with string value are supported and name is\ngiven without `${}`. See --variablefile for a more\npowerful variable setting mechanism.\n\nExamples:\n\n```\n--variable str:Hello => ${str} = `Hello`\n-v hi:Hi_World -E space:_ => ${hi} = `Hi World`\n-v x: -v y:42 => ${x} = ``, ${y} = `42`\n```\n\ncorresponds to the `-v --variable name:value *` option of _robot_\n",
3072+
"description": "Set variables in the test data. Only scalar\nvariables with string value are supported and name is\ngiven without `${}`. See --variablefile for a more\npowerful variable setting mechanism.\n\nExamples:\n\n```\n--variable name:Robot => ${name} = `Robot`\n-v \"hello:Hello world\" => ${hello} = `Hello world`\n-v x: -v y:42 => ${x} = ``, ${y} = `42`\n```\n\ncorresponds to the `-v --variable name:value *` option of _robot_\n",
29973073
"title": "Variables",
29983074
"type": [
29993075
"object",
@@ -3479,6 +3555,25 @@
34793555
"null"
34803556
]
34813557
},
3558+
"extra-parse-include": {
3559+
"default": null,
3560+
"description": "Appends entries to the --parseinclude option.\n\nParse only files matching `pattern`. It can be:\n- a file name or pattern like `example.robot` or\n`*.robot` to parse all files matching that name,\n- a file path like `path/to/example.robot`, or\n- a directory path like `path/to/example` to parse\nall files in that directory, recursively.\n\ncorresponds to the `-I --parseinclude pattern *` option of _robot_\n",
3561+
"items": {
3562+
"anyOf": [
3563+
{
3564+
"type": "string"
3565+
},
3566+
{
3567+
"$ref": "#/definitions/StringExpression"
3568+
}
3569+
]
3570+
},
3571+
"title": "Extra parse include",
3572+
"type": [
3573+
"array",
3574+
"null"
3575+
]
3576+
},
34823577
"extra-parsers": {
34833578
"additionalProperties": {
34843579
"items": {
@@ -3856,7 +3951,7 @@
38563951
]
38573952
},
38583953
"default": null,
3859-
"description": "Appends entries to the --variable option.\n\nSet variables in the test data. Only scalar\nvariables with string value are supported and name is\ngiven without `${}`. See --variablefile for a more\npowerful variable setting mechanism.\n\nExamples:\n\n```\n--variable str:Hello => ${str} = `Hello`\n-v hi:Hi_World -E space:_ => ${hi} = `Hi World`\n-v x: -v y:42 => ${x} = ``, ${y} = `42`\n```\n\ncorresponds to the `-v --variable name:value *` option of _rebot_\n",
3954+
"description": "Appends entries to the --variable option.\n\nSet variables in the test data. Only scalar\nvariables with string value are supported and name is\ngiven without `${}`. See --variablefile for a more\npowerful variable setting mechanism.\n\nExamples:\n\n```\n--variable name:Robot => ${name} = `Robot`\n-v \"hello:Hello world\" => ${hello} = `Hello world`\n-v x: -v y:42 => ${x} = ``, ${y} = `42`\n```\n\ncorresponds to the `-v --variable name:value *` option of _rebot_\n",
38603955
"title": "Extra variables",
38613956
"type": [
38623957
"object",
@@ -4118,6 +4213,25 @@
41184213
"description": "Where to create output files. The default is the\ndirectory where tests are run from and the given path\nis considered relative to that unless it is absolute.\n\ncorresponds to the `-d --outputdir dir` option of _robot_\n",
41194214
"title": "Output dir"
41204215
},
4216+
"parse-include": {
4217+
"default": null,
4218+
"description": "Parse only files matching `pattern`. It can be:\n- a file name or pattern like `example.robot` or\n`*.robot` to parse all files matching that name,\n- a file path like `path/to/example.robot`, or\n- a directory path like `path/to/example` to parse\nall files in that directory, recursively.\n\ncorresponds to the `-I --parseinclude pattern *` option of _robot_\n",
4219+
"items": {
4220+
"anyOf": [
4221+
{
4222+
"type": "string"
4223+
},
4224+
{
4225+
"$ref": "#/definitions/StringExpression"
4226+
}
4227+
]
4228+
},
4229+
"title": "Parse include",
4230+
"type": [
4231+
"array",
4232+
"null"
4233+
]
4234+
},
41214235
"parsers": {
41224236
"additionalProperties": {
41234237
"items": {
@@ -4765,7 +4879,7 @@
47654879
]
47664880
},
47674881
"default": null,
4768-
"description": "Set variables in the test data. Only scalar\nvariables with string value are supported and name is\ngiven without `${}`. See --variablefile for a more\npowerful variable setting mechanism.\n\nExamples:\n\n```\n--variable str:Hello => ${str} = `Hello`\n-v hi:Hi_World -E space:_ => ${hi} = `Hi World`\n-v x: -v y:42 => ${x} = ``, ${y} = `42`\n```\n\ncorresponds to the `-v --variable name:value *` option of _robot_\n",
4882+
"description": "Set variables in the test data. Only scalar\nvariables with string value are supported and name is\ngiven without `${}`. See --variablefile for a more\npowerful variable setting mechanism.\n\nExamples:\n\n```\n--variable name:Robot => ${name} = `Robot`\n-v \"hello:Hello world\" => ${hello} = `Hello world`\n-v x: -v y:42 => ${x} = ``, ${y} = `42`\n```\n\ncorresponds to the `-v --variable name:value *` option of _robot_\n",
47694883
"title": "Variables",
47704884
"type": [
47714885
"object",

hatch.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ test = "pytest {args}"
3939
test-reset = "test --regtest-reset"
4040
install-bundled-editable = "python ./scripts/install_bundled_editable.py"
4141
create-json-schema = "python ./scripts/create_robot_toml_json_schema.py"
42+
generate-rf-options = "python ./scripts/generate_rf_options.py"
4243
install-packages = "python ./scripts/install_packages.py"
4344

4445
[envs.rfmaster]
@@ -53,6 +54,10 @@ extra-dependencies=[
5354
"robotframework @ git+https://github.com/robotframework/robotframework.git"
5455
]
5556

57+
[envs.rfdevel]
58+
python = "3.11"
59+
post-install-commands = ["pip install -U -e {root:uri}/../robotframework"]
60+
5661
[envs.devel]
5762
python = "3.8"
5863

packages/robot/src/robotcode/robot/config/model.py

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,21 @@ class CommonOptions(BaseOptions):
537537
robot_priority=500,
538538
robot_short_name="d",
539539
)
540+
parse_include: Optional[List[Union[str, StringExpression]]] = field(
541+
description="""\
542+
Parse only files matching `pattern`. It can be:
543+
- a file name or pattern like `example.robot` or
544+
`*.robot` to parse all files matching that name,
545+
- a file path like `path/to/example.robot`, or
546+
- a directory path like `path/to/example` to parse
547+
all files in that directory, recursively.
548+
549+
corresponds to the `-I --parseinclude pattern *` option of _robot_
550+
""",
551+
robot_name="parseinclude",
552+
robot_priority=500,
553+
robot_short_name="I",
554+
)
540555
pre_rebot_modifiers: Optional[Dict[str, List[Union[str, StringExpression]]]] = field(
541556
description="""\
542557
Class to programmatically modify the result
@@ -941,6 +956,20 @@ class CommonExtraOptions(BaseOptions):
941956
corresponds to the `-M --metadata name:value *` option of _robot_
942957
""",
943958
)
959+
extra_parse_include: Optional[List[Union[str, StringExpression]]] = field(
960+
description="""\
961+
Appends entries to the --parseinclude option.
962+
963+
Parse only files matching `pattern`. It can be:
964+
- a file name or pattern like `example.robot` or
965+
`*.robot` to parse all files matching that name,
966+
- a file path like `path/to/example.robot`, or
967+
- a directory path like `path/to/example` to parse
968+
all files in that directory, recursively.
969+
970+
corresponds to the `-I --parseinclude pattern *` option of _robot_
971+
""",
972+
)
944973
extra_pre_rebot_modifiers: Optional[Dict[str, List[Union[str, StringExpression]]]] = field(
945974
description="""\
946975
Appends entries to the --prerebotmodifier option.
@@ -1488,9 +1517,9 @@ class RobotOptions(BaseOptions):
14881517
Examples:
14891518
14901519
```
1491-
--variable str:Hello => ${str} = `Hello`
1492-
-v hi:Hi_World -E space:_ => ${hi} = `Hi World`
1493-
-v x: -v y:42 => ${x} = ``, ${y} = `42`
1520+
--variable name:Robot => ${name} = `Robot`
1521+
-v "hello:Hello world" => ${hello} = `Hello world`
1522+
-v x: -v y:42 => ${x} = ``, ${y} = `42`
14941523
```
14951524
14961525
corresponds to the `-v --variable name:value *` option of _robot_
@@ -1607,9 +1636,9 @@ class RobotExtraOptions(BaseOptions):
16071636
Examples:
16081637
16091638
```
1610-
--variable str:Hello => ${str} = `Hello`
1611-
-v hi:Hi_World -E space:_ => ${hi} = `Hi World`
1612-
-v x: -v y:42 => ${x} = ``, ${y} = `42`
1639+
--variable name:Robot => ${name} = `Robot`
1640+
-v "hello:Hello world" => ${hello} = `Hello world`
1641+
-v x: -v y:42 => ${x} = ``, ${y} = `42`
16131642
```
16141643
16151644
corresponds to the `-v --variable name:value *` option of _rebot_

packages/runner/src/robotcode/runner/cli/discover/discover.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,11 @@ def handle_options(
344344
if settings.pythonpath:
345345
sys.path = settings.pythonpath + sys.path
346346

347-
if get_robot_version() > (6, 1, 0, "a", 1, None):
347+
if get_robot_version() > (6, 1, 0):
348348
builder = TestSuiteBuilder(
349-
settings["SuiteNames"],
350-
custom_parsers=settings.parsers,
351349
included_extensions=settings.extension,
350+
included_files=settings.parse_include,
351+
custom_parsers=settings.parsers,
352352
rpa=settings.rpa,
353353
lang=settings.languages,
354354
allow_empty_suite=settings.run_empty_suite,

packages/runner/src/robotcode/runner/cli/robot.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ def robot(
151151
The options and arguments are passed to `robot` as is.
152152
153153
Examples:
154+
155+
\b
154156
```
155157
robotcode run
156158
```

0 commit comments

Comments
 (0)