Skip to content

Commit ccb06fc

Browse files
author
automatic-merge
committed
Merge remote branch 'origin/master' into edge
2 parents bd5707c + bd61801 commit ccb06fc

File tree

24 files changed

+849
-45
lines changed

24 files changed

+849
-45
lines changed

.flake8

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[flake8]
2+
# This is intented for compatibility with Black. See
3+
# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8
4+
max-line-length = 80
5+
extend-select = B950
6+
extend-ignore = E203,E501,E701

.gitlab-ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,18 @@ include:
88
# Issue check
99
- component: $CI_SERVER_FQDN/eng/gitlab-templates/check-issue@~latest
1010

11+
# pre-commit
12+
- component: $CI_SERVER_FQDN/eng/gitlab-templates/pre-commit@~latest
13+
inputs:
14+
on-diff: true
15+
stage: check
16+
1117
# Build
1218
- component: $CI_SERVER_FQDN/eng/gitlab-templates/build@~latest
1319
inputs:
1420
anod-args: run build_$ACI_TRACK
1521
cpus: 16
22+
disk: 80
1623
image: systemgtk
1724
save-component: true
1825

@@ -22,13 +29,15 @@ include:
2229
job-name: als
2330
anod-args: run test_als_$ACI_TRACK
2431
image: systemgtk
32+
disk: 80
2533

2634
# Testing of the ALS with coverage
2735
- component: $CI_SERVER_FQDN/eng/gitlab-templates/test@~latest
2836
inputs:
2937
job-name: als-cov
3038
anod-args: run test_als_cov_$ACI_TRACK --latest
3139
image: systemgtk
40+
disk: 80
3241
# This job needs to rebuild ALS in coverage mode, so it doesn't need to
3342
# depend on the build job. The following will get it to run in parallel
3443
# with the build job.
@@ -52,6 +61,7 @@ include:
5261
anod-args: run test_integration_testsuite
5362
image: systemgtk
5463
cpus: 4
64+
disk: 80
5565
rules:
5666
# Does not work on edge
5767
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_TARGET_BRANCH_NAME != 'edge'
@@ -63,6 +73,7 @@ include:
6373
job-name: gs
6474
anod-args: run build_test_gs_$ACI_TRACK
6575
image: systemgtk
76+
disk: 80
6677
stage: optional
6778
rules:
6879
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'

.pre-commit-config.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
repos:
2+
- repo: https://github.com/pycqa/flake8
3+
rev: 7.0.0
4+
hooks:
5+
- id: flake8
6+
types: [file]
7+
files: \.(py|anod|plan)$
8+
additional_dependencies:
9+
- flake8-bugbear
10+
- flake8-builtins
11+
- flake8-comprehensions
12+
# - flake8-docstrings
13+
# - flake8-rst-docstrings
14+
- repo: https://github.com/ambv/black
15+
rev: 24.2.0
16+
hooks:
17+
- id: black
18+
types_or: [file]
19+
files: \.(py|plan)$
20+
- repo: https://github.com/pre-commit/mirrors-mypy
21+
rev: v1.8.0
22+
hooks:
23+
- id: mypy
24+
files: '\.py$'
25+
# exclude: "^tests/.+$"
26+
additional_dependencies:
27+
- --extra-index-url
28+
- https://gitlab.adacore-it.com/api/v4/projects/it%2Fpackage-registry/packages/pypi/simple
29+
- pytest-lsp

.vscode/settings.json.tmpl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
"flake8.args": ["--max-line-length", "88"],
2323
"[python]": {
2424
// Use the same line length as black and flake8
25-
"vim.textwidth": 88
25+
"vim.textwidth": 88,
26+
"editor.defaultFormatter": "ms-python.black-formatter",
27+
"editor.formatOnSave": true
2628
},
2729
"[yaml]": {
2830
"editor.defaultFormatter": "esbenp.prettier-vscode"
Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
11
"""test that callHierarchy/incomingCalls works for dispatching calls"""
22

3-
import os
4-
5-
from drivers.lsp_ada_requests import (
6-
didOpen_from_disk,
7-
incomingCalls,
8-
prepareCallHierarchy,
3+
from drivers.pylsp import (
4+
URI,
5+
ALSLanguageClient,
6+
assertLocationsList,
7+
callHierarchyIncomingCallsParams,
8+
callHierarchyPrepareParams,
9+
didOpenTextDocumentParams,
10+
test,
911
)
10-
from drivers.lsp_python_driver import simple_test
1112

1213

13-
@simple_test
14-
def test_called_by(lsp, wd):
14+
@test()
15+
async def test_called_by(lsp: ALSLanguageClient):
1516
# Send a didOpen for main.adb
16-
main_adb = os.path.join(wd, "main.adb")
17-
root_ads = os.path.join(wd, "root.ads")
18-
p_adb = os.path.join(wd, "p.adb")
19-
20-
lsp.send(didOpen_from_disk(main_adb))
17+
open_params, main_adb_uri = didOpenTextDocumentParams("main.adb")
18+
root_ads_uri = URI("root.ads")
19+
lsp.text_document_did_open(open_params)
2120

2221
# Send a textDocument/prepareCallHierarchy request
23-
response = lsp.send(prepareCallHierarchy(main_adb, 7, 4))
22+
result1 = await lsp.text_document_prepare_call_hierarchy_async(
23+
callHierarchyPrepareParams(main_adb_uri, 7, 4)
24+
)
25+
assert result1
2426

2527
# Expect these locations
26-
response.assertLocationsList([("root.ads", 5)])
28+
assertLocationsList(result1, [("root.ads", 5)])
2729

2830
# Now send the callHierarchy/incomingCalls request
29-
response = lsp.send(incomingCalls(root_ads, 5, 14))
31+
result2 = await lsp.call_hierarchy_incoming_calls_async(
32+
callHierarchyIncomingCallsParams(root_ads_uri, 5, 14)
33+
)
34+
assert result2
3035

3136
# Expect these locations
32-
response.assertLocationsList([("main.adb", 3)])
37+
assertLocationsList(result2, [("main.adb", 3)])
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
title: 'called_by_dispatching'
2-
driver: python
1+
# If the title is the same as the directory name, it can be ommited.
2+
# title: 'called_by_dispatching'
3+
driver: pylsp

testsuite/drivers/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@
1414
class ALSTestDriver(ClassicTestDriver):
1515
"""Abstract class to share some common facilities."""
1616

17+
@property
18+
def working_dir_cleanup_enabled(self):
19+
# By default cleanup of the working dir is performed for successful tests
20+
# because there is no need to investigate them. We inhibit that in verbose mode
21+
# to allow investigating successful tests.
22+
if self.env.main_options.verbose > 0 or self.env.main_options.debug:
23+
return False
24+
else:
25+
return super().working_dir_cleanup_enabled
26+
1727
@property
1828
def test_control_creator(self) -> TestControlCreator:
1929
eval_env = {

testsuite/drivers/lsp_python_driver.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,18 +128,18 @@ def __init__(
128128
self.license_to_kill = None
129129

130130
# The queue receiving the messages from the reading task
131-
self.queue = queue.Queue()
131+
self.queue: queue.Queue[LSPResponse] = queue.Queue()
132132

133133
# Launch a task that will receive messages from the LSP server
134134
# and store them in a queue
135135
self.task = threading.Thread(target=self.receive_task)
136136
self.k_task = threading.Thread(target=self.kill_task)
137137

138138
# Error messages encountered
139-
self.errors = []
139+
self.errors: list[str] = []
140140

141141
# A list of bytes containing everything we sent to the server
142-
self.replay = []
142+
self.replay: list[bytes] = []
143143

144144
# Start the tasks after all the attributes have been declared
145145
self.task.start()
@@ -207,6 +207,7 @@ def send(self, message: LSPMessage, expect_response=True) -> LSPResponse | None:
207207
encoded = message.encode()
208208
self.replay.append(encoded)
209209

210+
assert self.process.stdin
210211
self.process.stdin.write(encoded)
211212
self.process.stdin.flush()
212213

@@ -229,6 +230,8 @@ def send(self, message: LSPMessage, expect_response=True) -> LSPResponse | None:
229230
}
230231
)
231232

233+
return None
234+
232235
def error(self, message):
233236
"""Log an error message."""
234237
self.errors.append(message)
@@ -301,7 +304,8 @@ def run_simple_test(test_function, working_dir) -> list[str]:
301304
lsp.errors.append(traceback.format_exc())
302305
finally:
303306
lsp.shutdown()
304-
return lsp.errors
307+
308+
return lsp.errors
305309

306310

307311
# Make run_simple_test available as a decorator

testsuite/drivers/lsp_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Describes some types used in the LSP testing."""
22

3-
from typing import Any
43
import json
54
import os
65

@@ -11,6 +10,7 @@
1110

1211
class ResponseAssertionError(Exception):
1312
"""An exception that we manage - to avoid printing long traceback."""
13+
1414
pass
1515

1616

@@ -121,7 +121,7 @@ def _line_info(self) -> str:
121121
message = f"At {dir_and_file}:{line_number} in {fn_name}:\n"
122122
return message
123123

124-
def assertLocationsList(self, expected: list[(str, int)]):
124+
def assertLocationsList(self, expected: list[tuple[str, int]]):
125125
"""Compare the response to an expected list of locations.
126126
The expected list is a list of tuples (file base name, line number),
127127
with line_number being 1-based.

testsuite/drivers/pylsp-runner.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""This is a Python main entry point that calls drivers.pylsp.main().
2+
3+
We create this entry point here instead of in pylsp.py to avoid the pylsp.py module
4+
getting imported twice: once as "__main__" and once as "drivers.pylsp".
5+
"""
6+
7+
from drivers.pylsp import main
8+
9+
if __name__ == "__main__":
10+
main()

0 commit comments

Comments
 (0)