Skip to content

Commit e16f09c

Browse files
committed
fix: checks for robot version 6.1
1 parent 3d8a702 commit e16f09c

File tree

2 files changed

+48
-41
lines changed

2 files changed

+48
-41
lines changed

hatch.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ install-packages = "python ./scripts/install_packages.py"
4444

4545
[envs.rfmaster]
4646
python = "3.11"
47-
extra-dependencies=[
48-
"robotframework @ git+https://github.com/robotframework/robotframework.git"
47+
extra-dependencies = [
48+
"robotframework @ git+https://github.com/robotframework/robotframework.git",
4949
]
5050

5151
[envs.py312_rfmaster]
5252
python = "3.12"
53-
extra-dependencies=[
54-
"robotframework @ git+https://github.com/robotframework/robotframework.git"
53+
extra-dependencies = [
54+
"robotframework @ git+https://github.com/robotframework/robotframework.git",
5555
]
5656

5757
[envs.rfdevel]
@@ -63,7 +63,7 @@ python = "3.8"
6363

6464
[[envs.devel.matrix]]
6565
python = ["3.8", "3.9", "3.10", "3.11"]
66-
rf = ["rf41", "rf50", "rf60", "61rc1"]
66+
rf = ["rf41", "rf50", "rf60", "rf61"]
6767

6868
[envs.devel.overrides]
6969
matrix.rf.dependencies = [
@@ -76,13 +76,13 @@ matrix.rf.dependencies = [
7676
{ value = "robotframework>6.0.0, <6.1", if = [
7777
"rf60",
7878
] },
79-
{ value = "robotframework==6.1rc1", if = [
80-
"61rc1",
79+
{ value = "robotframework>=6.1, <7.0", if = [
80+
"rf61",
8181
] },
8282
]
8383

8484
[[envs.test.matrix]]
85-
rf = ["rf41", "rf50", "rf60", "61rc1"]
85+
rf = ["rf41", "rf50", "rf60", "rf61"]
8686

8787
[envs.test.overrides]
8888
matrix.rf.dependencies = [
@@ -95,8 +95,8 @@ matrix.rf.dependencies = [
9595
{ value = "robotframework>6.0.0, <6.1", if = [
9696
"rf60",
9797
] },
98-
{ value = "robotframework==6.1rc1", if = [
99-
"61rc1",
98+
{ value = "robotframework>=6.1, <7.0", if = [
99+
"rf61",
100100
] },
101101
]
102102

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

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def _patch() -> None:
4444
return
4545
__patched = True
4646

47-
if get_robot_version() <= (6, 1, 0, "a", 1, None):
47+
if get_robot_version() <= (6, 1):
4848
if get_robot_version() > (5, 0) and get_robot_version() < (6, 0, 0) or get_robot_version() < (5, 0):
4949
from robot.running.builder.testsettings import TestDefaults # pyright: ignore[reportMissingImports]
5050
else:
@@ -69,7 +69,7 @@ def build_suite(self: SuiteStructureParser, structure: Any) -> Tuple[TestSuite,
6969
except DataError as e:
7070
LOGGER.error(str(e))
7171
parent_defaults = self._stack[-1][-1] if self._stack else None
72-
if get_robot_version() < (6, 1, 0, "a", 1, None):
72+
if get_robot_version() < (6, 1):
7373
from robot.running.builder.parsers import format_name
7474

7575
return ErroneousTestSuite(
@@ -82,7 +82,7 @@ def build_suite(self: SuiteStructureParser, structure: Any) -> Tuple[TestSuite,
8282

8383
SuiteStructureParser._build_suite = build_suite
8484

85-
elif get_robot_version() >= (6, 1, 0, "a", 1, None):
85+
elif get_robot_version() >= (6, 1):
8686
from robot.parsing.suitestructure import SuiteDirectory, SuiteFile
8787
from robot.running.builder.settings import TestDefaults # pyright: ignore[reportMissingImports]
8888

@@ -170,7 +170,7 @@ def __init__(self) -> None:
170170
super().__init__()
171171
self.all: TestItem = TestItem(
172172
type="workspace",
173-
id=str(Path.cwd().resolve()),
173+
id=str(Path.cwd().absolute()),
174174
name=Path.cwd().name,
175175
longname=Path.cwd().name,
176176
uri=str(Uri.from_path(Path.cwd())),
@@ -182,21 +182,24 @@ def __init__(self) -> None:
182182
self.statistics = Statistics()
183183

184184
def visit_suite(self, suite: TestSuite) -> None:
185-
item = TestItem(
186-
type="suite",
187-
id=f"{Path(suite.source).resolve() if suite.source is not None else ''};{suite.longname}",
188-
name=suite.name,
189-
longname=suite.longname,
190-
uri=str(Uri.from_path(suite.source)) if suite.source else None,
191-
range=Range(
192-
start=Position(line=0, character=0),
193-
end=Position(line=0, character=0),
185+
try:
186+
item = TestItem(
187+
type="suite",
188+
id=f"{Path(suite.source).absolute() if suite.source is not None else ''};{suite.longname}",
189+
name=suite.name,
190+
longname=suite.longname,
191+
uri=str(Uri.from_path(Path(suite.source).absolute())) if suite.source else None,
192+
range=Range(
193+
start=Position(line=0, character=0),
194+
end=Position(line=0, character=0),
195+
)
196+
if suite.source and Path(suite.source).is_file()
197+
else None,
198+
children=[],
199+
error=suite.error_message if isinstance(suite, ErroneousTestSuite) else None,
194200
)
195-
if suite.source and Path(suite.source).is_file()
196-
else None,
197-
children=[],
198-
error=suite.error_message if isinstance(suite, ErroneousTestSuite) else None,
199-
)
201+
except ValueError as e:
202+
raise ValueError(f"Error while parsing suite {suite.source}: {e}") from e
200203

201204
self.suites.append(item)
202205

@@ -218,18 +221,22 @@ def visit_suite(self, suite: TestSuite) -> None:
218221
def visit_test(self, test: TestCase) -> None:
219222
if self._current.children is None:
220223
self._current.children = []
221-
item = TestItem(
222-
type="test",
223-
id=f"{Path(test.source).resolve() if test.source is not None else ''};{test.longname};{test.lineno}",
224-
name=test.name,
225-
longname=test.longname,
226-
uri=str(Uri.from_path(test.source)) if test.source else None,
227-
range=Range(
228-
start=Position(line=test.lineno - 1, character=0),
229-
end=Position(line=test.lineno - 1, character=0),
230-
),
231-
tags=list(test.tags) if test.tags else None,
232-
)
224+
try:
225+
item = TestItem(
226+
type="test",
227+
id=f"{Path(test.source).absolute() if test.source is not None else ''};{test.longname};{test.lineno}",
228+
name=test.name,
229+
longname=test.longname,
230+
uri=str(Uri.from_path(Path(test.source).absolute())) if test.source else None,
231+
range=Range(
232+
start=Position(line=test.lineno - 1, character=0),
233+
end=Position(line=test.lineno - 1, character=0),
234+
),
235+
tags=list(test.tags) if test.tags else None,
236+
)
237+
except ValueError as e:
238+
raise ValueError(f"Error while parsing suite {test.source}: {e}") from e
239+
233240
for tag in test.tags:
234241
self.tags[str(tag)].append(item)
235242

@@ -344,7 +351,7 @@ def handle_options(
344351
if settings.pythonpath:
345352
sys.path = settings.pythonpath + sys.path
346353

347-
if get_robot_version() > (6, 1, 0):
354+
if get_robot_version() > (6, 1):
348355
builder = TestSuiteBuilder(
349356
included_extensions=settings.extension,
350357
included_files=settings.parse_include,

0 commit comments

Comments
 (0)