Skip to content

Commit f948bb5

Browse files
committed
Merge branch 'topic/pylsp' into 'master'
Improve pylsp test helpers See merge request eng/ide/ada_language_server!1850
2 parents c94da49 + f4e01ae commit f948bb5

File tree

7 files changed

+140
-129
lines changed

7 files changed

+140
-129
lines changed

testsuite/ada_lsp/called_by_dispatching/test.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
URI,
55
ALSLanguageClient,
66
assertLocationsList,
7-
callHierarchyIncomingCallsParams,
8-
callHierarchyPrepareParams,
97
didOpenTextDocumentParams,
108
test,
119
)
@@ -19,18 +17,14 @@ async def test_called_by(lsp: ALSLanguageClient):
1917
lsp.text_document_did_open(open_params)
2018

2119
# Send a textDocument/prepareCallHierarchy request
22-
result1 = await lsp.text_document_prepare_call_hierarchy_async(
23-
callHierarchyPrepareParams(main_adb_uri, 7, 4)
24-
)
20+
result1 = await lsp.prepareCallHierarchy(main_adb_uri, 7, 4)
2521
assert result1
2622

2723
# Expect these locations
2824
assertLocationsList(result1, [("root.ads", 5)])
2925

3026
# Now send the callHierarchy/incomingCalls request
31-
result2 = await lsp.call_hierarchy_incoming_calls_async(
32-
callHierarchyIncomingCallsParams(root_ads_uri, 5, 14)
33-
)
27+
result2 = await lsp.callHierarchyIncomingCalls(root_ads_uri, 5, 14)
3428
assert result2
3529

3630
# Expect these locations

testsuite/ada_lsp/config_base/test.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
ALSLanguageClient,
3939
ALSSettings,
4040
assertEqual,
41-
awaitIndexingEnd,
4241
test,
4342
)
4443

@@ -68,18 +67,18 @@ async def test1(lsp: ALSLanguageClient) -> None:
6867
)
6968
# Because no project file was set, we need a didOpen to load the project
7069
lsp.didOpenVirtual()
71-
await awaitIndexingEnd(lsp)
70+
await lsp.awaitIndexingEnd()
7271
assertEqual(await lsp.getObjDirBasename(), "value-from-init")
7372

7473
# Now let's change the settings
7574
lsp.didChangeConfig({"scenarioVariables": {"Var": "new-value"}})
76-
await awaitIndexingEnd(lsp)
75+
await lsp.awaitIndexingEnd()
7776
assertEqual(await lsp.getObjDirBasename(), "new-value")
7877

7978
# Now we send a null value to revert to the base config which should be the config
8079
# file, not the initialize request.
8180
lsp.didChangeConfig({"scenarioVariables": None})
82-
await awaitIndexingEnd(lsp)
81+
await lsp.awaitIndexingEnd()
8382
assertEqual(await lsp.getObjDirBasename(), "value-from-config-file")
8483

8584

@@ -99,17 +98,17 @@ async def test2(lsp: ALSLanguageClient) -> None:
9998
)
10099
# Because no project file was set, we need a didOpen to load the project
101100
lsp.didOpenVirtual()
102-
await awaitIndexingEnd(lsp)
101+
await lsp.awaitIndexingEnd()
103102
assertEqual(await lsp.getObjDirBasename(), "value-from-init")
104103

105104
# Now let's change the settings and revert back to see if we revert to the right
106105
# value.
107106
lsp.didChangeConfig({"scenarioVariables": {"Var": "new-value"}})
108-
await awaitIndexingEnd(lsp)
107+
await lsp.awaitIndexingEnd()
109108
assertEqual(await lsp.getObjDirBasename(), "new-value")
110109

111110
lsp.didChangeConfig({"scenarioVariables": None})
112-
await awaitIndexingEnd(lsp)
111+
await lsp.awaitIndexingEnd()
113112
assertEqual(await lsp.getObjDirBasename(), "value-from-init")
114113

115114

@@ -130,19 +129,19 @@ async def test3(lsp: ALSLanguageClient) -> None:
130129
)
131130
# Because no project file was set, we need a didOpen to load the project
132131
lsp.didOpenVirtual()
133-
await awaitIndexingEnd(lsp)
132+
await lsp.awaitIndexingEnd()
134133
# No value was provided for the scenario variable, so we should get the default
135134
# value defined in the project.
136135
assertEqual(await lsp.getObjDirBasename(), "value-from-prj")
137136

138137
# Now let's change the settings and revert back to see if we revert to the right
139138
# value.
140139
lsp.didChangeConfig({"scenarioVariables": {"Var": "new-value"}})
141-
await awaitIndexingEnd(lsp)
140+
await lsp.awaitIndexingEnd()
142141
assertEqual(await lsp.getObjDirBasename(), "new-value")
143142

144143
lsp.didChangeConfig({"scenarioVariables": None})
145-
await awaitIndexingEnd(lsp)
144+
await lsp.awaitIndexingEnd()
146145
assertEqual(await lsp.getObjDirBasename(), "value-from-prj")
147146

148147

@@ -158,7 +157,7 @@ async def test4(lsp: ALSLanguageClient) -> None:
158157
)
159158
# Because no project file was set, we need a didOpen to load the project
160159
lsp.didOpenVirtual()
161-
await awaitIndexingEnd(lsp)
160+
await lsp.awaitIndexingEnd()
162161
# No value was provided for the scenario variable, so we should get the default
163162
# value defined in the project.
164163
assertEqual(await lsp.getObjDirBasename(), "value-from-prj")
@@ -168,14 +167,14 @@ async def test4(lsp: ALSLanguageClient) -> None:
168167
lsp.didChangeConfig(
169168
{"scenarioVariables": {"Var": "value-from-first-config-change"}}
170169
)
171-
await awaitIndexingEnd(lsp)
170+
await lsp.awaitIndexingEnd()
172171
assertEqual(await lsp.getObjDirBasename(), "value-from-first-config-change")
173172

174173
# Now we change to another value, and revert with a null value.
175174
lsp.didChangeConfig({"scenarioVariables": {"Var": "new-value"}})
176-
await awaitIndexingEnd(lsp)
175+
await lsp.awaitIndexingEnd()
177176
assertEqual(await lsp.getObjDirBasename(), "new-value")
178177

179178
lsp.didChangeConfig({"scenarioVariables": None})
180-
await awaitIndexingEnd(lsp)
179+
await lsp.awaitIndexingEnd()
181180
assertEqual(await lsp.getObjDirBasename(), "value-from-first-config-change")

testsuite/ada_lsp/config_cli/test.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
from drivers.pylsp import (
1818
URI,
1919
ALSClientServerConfig,
20-
LanguageClient,
20+
ALSLanguageClient,
2121
assertEqual,
22-
getCurrentProject,
2322
test,
2423
)
2524

@@ -29,7 +28,7 @@
2928
[os.environ.get("ALS", "ada_language_server"), "--config", "my_config.json"]
3029
)
3130
)
32-
async def test_func(lsp: LanguageClient) -> None:
33-
response = await lsp.workspace_execute_command_async(getCurrentProject())
31+
async def test_func(lsp: ALSLanguageClient) -> None:
32+
response = await lsp.getCurrentProject()
3433
assert response
3534
assertEqual(response, URI("non-root/p2.gpr"))

testsuite/ada_lsp/config_global/test.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
from drivers.pylsp import (
1919
URI,
2020
ALSClientServerConfig,
21-
LanguageClient,
21+
ALSLanguageClient,
2222
assertEqual,
23-
getCurrentProject,
2423
test,
2524
)
2625

@@ -31,7 +30,7 @@
3130
server_env=os.environ | {"XDG_CONFIG_HOME": os.path.abspath("xdg_config_home")},
3231
)
3332
)
34-
async def func(lsp: LanguageClient) -> None:
35-
response = await lsp.workspace_execute_command_async(getCurrentProject())
33+
async def func(lsp: ALSLanguageClient) -> None:
34+
response = await lsp.getCurrentProject()
3635
assert response
3736
assertEqual(response, URI("non-root/p2.gpr"))

testsuite/ada_lsp/config_local/test.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
Then the test queries for the current project to determine the success or failure.
1212
"""
1313

14-
from pytest_lsp import LanguageClient
15-
from drivers.pylsp import URI, assertEqual, getCurrentProject, test
14+
from drivers.pylsp import URI, ALSLanguageClient, assertEqual, test
1615

1716

1817
@test()
19-
async def func(lsp: LanguageClient) -> None:
20-
response = await lsp.workspace_execute_command_async(getCurrentProject())
18+
async def func(lsp: ALSLanguageClient) -> None:
19+
response = await lsp.getCurrentProject()
2120
assert response
2221
assertEqual(response, URI("non-root/p2.gpr"))

testsuite/ada_lsp/config_priority/test.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
from drivers.pylsp import (
1818
URI,
1919
ALSClientServerConfig,
20-
LanguageClient,
20+
ALSLanguageClient,
2121
assertEqual,
22-
getCurrentProject,
2322
test,
2423
)
2524

@@ -30,9 +29,9 @@
3029
server_env=os.environ | {"XDG_CONFIG_HOME": os.path.abspath("xdg_config_home")},
3130
)
3231
)
33-
async def test_global_local(lsp: LanguageClient) -> None:
32+
async def test_global_local(lsp: ALSLanguageClient) -> None:
3433
"""Test that the local .als.json takes priority over the global config file"""
35-
response = await lsp.workspace_execute_command_async(getCurrentProject())
34+
response = await lsp.getCurrentProject()
3635
assertEqual(response, URI("non-root/p4.gpr"))
3736

3837

@@ -42,9 +41,9 @@ async def test_global_local(lsp: LanguageClient) -> None:
4241
server_env=os.environ | {"XDG_CONFIG_HOME": "some_non_existing_path"},
4342
)
4443
)
45-
async def test_local_cli(lsp: LanguageClient) -> None:
44+
async def test_local_cli(lsp: ALSLanguageClient) -> None:
4645
"""Test that the CLI config file takes priority over the local .als.json one"""
47-
response = await lsp.workspace_execute_command_async(getCurrentProject())
46+
response = await lsp.getCurrentProject()
4847
assertEqual(response, URI("non-root/p2.gpr"))
4948

5049

@@ -54,7 +53,7 @@ async def test_local_cli(lsp: LanguageClient) -> None:
5453
server_env=os.environ | {"XDG_CONFIG_HOME": os.path.abspath("xdg_config_home")},
5554
)
5655
)
57-
async def test_all(lsp: LanguageClient) -> None:
56+
async def test_all(lsp: ALSLanguageClient) -> None:
5857
"""Test that the CLI config file takes priority over both"""
59-
response = await lsp.workspace_execute_command_async(getCurrentProject())
58+
response = await lsp.getCurrentProject()
6059
assertEqual(response, URI("non-root/p2.gpr"))

0 commit comments

Comments
 (0)