Skip to content

Commit 8ede93a

Browse files
committed
discovering testcases now ignores erroneous files
1 parent 239c8d6 commit 8ede93a

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

robotcode/language_server/robotframework/parts/discovering.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from dataclasses import dataclass
66
from itertools import chain
77
from pathlib import Path
8-
from typing import TYPE_CHECKING, Any, Iterator, List, Optional, cast
8+
from typing import TYPE_CHECKING, Any, Callable, Iterator, List, Optional, cast
99

1010
from ....jsonrpc2.protocol import rpc_method
1111
from ....utils.async_tools import run_coroutine_in_thread
@@ -104,6 +104,7 @@ async def _get_tests_from_workspace(
104104
) -> List[TestItem]:
105105

106106
from robot.output.logger import LOGGER
107+
from robot.parsing import get_model
107108
from robot.parsing.suitestructure import SuiteStructureBuilder
108109
from robot.running import TestCase, TestSuite
109110
from robot.running.builder.builders import (
@@ -112,6 +113,7 @@ async def _get_tests_from_workspace(
112113
SuiteStructureParser,
113114
TestSuiteBuilder,
114115
)
116+
from robot.running.builder.testsettings import TestDefaults
115117

116118
def get_document_text(source: str) -> str:
117119
if self.parent._loop:
@@ -127,6 +129,30 @@ class MyRobotParser(RobotParser):
127129
def _get_source(self, source: str) -> Any:
128130
return get_document_text(source)
129131

132+
def _build(
133+
self,
134+
suite: TestSuite,
135+
source: str,
136+
defaults: TestDefaults,
137+
model: Optional[ast.AST] = None,
138+
get_model: Callable[..., Any] = get_model,
139+
) -> TestSuite:
140+
141+
from robot.running.builder.transformers import (
142+
SettingsBuilder,
143+
SuiteBuilder,
144+
)
145+
146+
if defaults is None:
147+
defaults = TestDefaults()
148+
if model is None:
149+
model = get_model(self._get_source(source), data_only=True, curdir=self._get_curdir(source))
150+
151+
SettingsBuilder(suite, defaults).visit(model)
152+
SuiteBuilder(suite, defaults).visit(model)
153+
suite.rpa = self._get_rpa_mode(model)
154+
return suite
155+
130156
class MyRestParser(MyRobotParser):
131157
def _get_source(self, source: str) -> Any:
132158
from robot.utils import read_rest_data
@@ -152,6 +178,7 @@ def _get_parsers(self, extensions: List[str], process_curdir: bool) -> RobotPars
152178

153179
class MyTestSuiteBuilder(TestSuiteBuilder):
154180
def _validate_test_counts(self, suite: TestSuite, multisource: bool = False) -> None:
181+
# we don't need this
155182
pass
156183

157184
def build(self, *paths: str) -> TestSuite:

0 commit comments

Comments
 (0)