Skip to content

Commit 6e3282a

Browse files
committed
Merge branch 'mr/1462' into 'master'
Add a test driver allowing to write tests in python See merge request eng/ide/ada_language_server!1730
2 parents f5b60c3 + 9d06c1c commit 6e3282a

File tree

14 files changed

+936
-808
lines changed

14 files changed

+936
-808
lines changed

testsuite/ada_lsp/called_by/test.json

Lines changed: 0 additions & 512 deletions
This file was deleted.

testsuite/ada_lsp/called_by/test.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
from drivers.lsp_python_driver import LSP, complex_test
2+
from drivers.lsp_ada_requests import (
3+
didOpen_from_disk,
4+
prepareCallHierarchy,
5+
incomingCalls,
6+
initialize,
7+
initialized,
8+
didChangeConfiguration,
9+
)
10+
import os
11+
12+
13+
# Use a complex_test rather than a simple_test
14+
# so we can inspect the results of initialize()
15+
@complex_test
16+
def test_called_by(wd) -> list[str] | None:
17+
program = os.environ.get("ALS", "ada_language_server")
18+
lsp = LSP(program, wd)
19+
# Send the initialize request
20+
response = lsp.send(initialize())
21+
# Verify that the right capability is advertised
22+
response.assertField("capabilities.callHierarchyProvider", True)
23+
24+
# Send the initialized notification and the didChangeConfiguration notification
25+
lsp.send(initialized())
26+
lsp.send(didChangeConfiguration())
27+
# Send a didOpen for main.adb
28+
main_adb = os.path.join(wd, "main.adb")
29+
p_adb = os.path.join(wd, "p.adb")
30+
31+
lsp.send(didOpen_from_disk(main_adb))
32+
33+
# Send a textDocument/prepareCallHierarchy request
34+
response = lsp.send(prepareCallHierarchy(main_adb, 3, 44))
35+
response.assertLocationsList([("p.adb", 2)])
36+
37+
# Now send the callHierarchy/incomingCalls request
38+
response = lsp.send(incomingCalls(p_adb, 2, 14))
39+
40+
# Expect these locations
41+
response.assertLocationsList(
42+
[
43+
("main.adb", 10),
44+
("main.adb", 14),
45+
("p.adb", 2),
46+
("main.adb", 2),
47+
("p.ads", 1),
48+
("p.adb", 8),
49+
]
50+
)
51+
lsp.shutdown()
52+
return []

testsuite/ada_lsp/called_by/test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
title: 'called_by'
2+
driver: python

testsuite/ada_lsp/called_by_dispatching/test.json

Lines changed: 0 additions & 287 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""test that callHierarchy/incomingCalls works for dispatching calls"""
2+
3+
from drivers.lsp_python_driver import simple_test
4+
from drivers.lsp_ada_requests import didOpen_from_disk, prepareCallHierarchy, incomingCalls
5+
from drivers.lsp_types import LSPMessage, URI
6+
import os
7+
8+
9+
@simple_test
10+
def test_called_by(lsp, wd):
11+
# Send a didOpen for main.adb
12+
main_adb = os.path.join(wd, "main.adb")
13+
root_ads = os.path.join(wd, "root.ads")
14+
p_adb = os.path.join(wd, "p.adb")
15+
16+
lsp.send(didOpen_from_disk(main_adb))
17+
18+
# Send a textDocument/prepareCallHierarchy request
19+
response = lsp.send(prepareCallHierarchy(main_adb, 7, 4))
20+
21+
# Expect these locations
22+
response.assertLocationsList([("root.ads",5)])
23+
24+
# Now send the callHierarchy/incomingCalls request
25+
response = lsp.send(incomingCalls(root_ads, 5, 14))
26+
27+
# Expect these locations
28+
response.assertLocationsList([("main.adb", 3)])
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
title: 'called_by_dispatching'
2+
driver: python

0 commit comments

Comments
 (0)