Skip to content

Commit 327b122

Browse files
committed
test: let collect data in languages server test run in his own thread
1 parent 9403f72 commit 327b122

File tree

6 files changed

+23
-8
lines changed

6 files changed

+23
-8
lines changed

tests/robotcode/language_server/robotframework/parts/test_document_highlight.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from robotcode.language_server.robotframework.protocol import (
1010
RobotLanguageServerProtocol,
1111
)
12+
from robotcode.utils.async_tools import run_coroutine_in_thread
1213

1314
from ..tools import (
1415
GeneratedTestData,
@@ -32,8 +33,12 @@ async def test(
3233
test_document: TextDocument,
3334
data: GeneratedTestData,
3435
) -> None:
35-
result = await protocol.robot_document_highlight.collect(
36-
protocol.robot_document_highlight, test_document, Position(line=data.line, character=data.character)
36+
37+
result = result = await run_coroutine_in_thread(
38+
protocol.robot_document_highlight.collect,
39+
protocol.robot_document_highlight,
40+
test_document,
41+
Position(line=data.line, character=data.character),
3742
)
3843
regtest.write(
3944
yaml.dump(

tests/robotcode/language_server/robotframework/parts/test_foldingrange.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from robotcode.language_server.robotframework.protocol import (
1515
RobotLanguageServerProtocol,
1616
)
17+
from robotcode.utils.async_tools import run_coroutine_in_thread
1718

1819
from ..tools import (
1920
GeneratedTestData,
@@ -70,6 +71,8 @@ async def test(
7071
data: GeneratedTestData,
7172
) -> None:
7273

73-
result = await protocol.robot_folding_ranges.collect(protocol.robot_folding_ranges, test_document)
74+
result = await run_coroutine_in_thread(
75+
protocol.robot_folding_ranges.collect, protocol.robot_folding_ranges, test_document
76+
)
7477

7578
regtest.write(yaml.dump({"data": data, "result": result}))

tests/robotcode/language_server/robotframework/parts/test_goto_definition.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from robotcode.language_server.robotframework.protocol import (
1010
RobotLanguageServerProtocol,
1111
)
12+
from robotcode.utils.async_tools import run_coroutine_in_thread
1213

1314
from ..tools import (
1415
GeneratedTestData,
@@ -34,7 +35,8 @@ async def test_definition(
3435
data: GeneratedTestData,
3536
) -> None:
3637

37-
result = await protocol.robot_goto.collect_definition(
38+
result = await run_coroutine_in_thread(
39+
protocol.robot_goto.collect_definition,
3840
protocol.robot_goto,
3941
test_document,
4042
Position(line=data.line, character=data.character),

tests/robotcode/language_server/robotframework/parts/test_goto_implementation.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from robotcode.language_server.robotframework.protocol import (
1111
RobotLanguageServerProtocol,
1212
)
13+
from robotcode.utils.async_tools import run_coroutine_in_thread
1314
from robotcode.utils.uri import Uri
1415

1516
from ..tools import (
@@ -58,7 +59,8 @@ async def test_implementation(
5859
data: GeneratedTestData,
5960
) -> None:
6061

61-
result = await protocol.robot_goto.collect_implementation(
62+
result = await run_coroutine_in_thread(
63+
protocol.robot_goto.collect_implementation,
6264
protocol.robot_goto,
6365
test_document,
6466
Position(line=data.line, character=data.character),

tests/robotcode/language_server/robotframework/parts/test_hover.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from robotcode.language_server.robotframework.protocol import (
1111
RobotLanguageServerProtocol,
1212
)
13+
from robotcode.utils.async_tools import run_coroutine_in_thread
1314

1415
from ..tools import (
1516
GeneratedTestData,
@@ -33,8 +34,8 @@ async def test(
3334
test_document: TextDocument,
3435
data: GeneratedTestData,
3536
) -> None:
36-
result = await protocol.robot_hover.collect(
37-
protocol.hover, test_document, Position(line=data.line, character=data.character)
37+
result = await run_coroutine_in_thread(
38+
protocol.robot_hover.collect, protocol.hover, test_document, Position(line=data.line, character=data.character)
3839
)
3940

4041
def split(hover: Optional[Hover]) -> Optional[Hover]:

tests/robotcode/language_server/robotframework/parts/test_references.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from robotcode.language_server.robotframework.protocol import (
1414
RobotLanguageServerProtocol,
1515
)
16+
from robotcode.utils.async_tools import run_coroutine_in_thread
1617

1718
from ..tools import (
1819
GeneratedTestData,
@@ -39,7 +40,8 @@ async def test(
3940
def split(location: Location) -> Location:
4041
return Location("/".join(location.uri.split("/")[-2:]), location.range)
4142

42-
result = await protocol.robot_references.collect(
43+
result = await run_coroutine_in_thread(
44+
protocol.robot_references.collect,
4345
protocol.robot_references,
4446
test_document,
4547
Position(line=data.line, character=data.character),

0 commit comments

Comments
 (0)