Skip to content

Commit f00b8ea

Browse files
committed
test: add unit test that specifically checks the workspace_init exception handling mechanism
1 parent 800cc9c commit f00b8ea

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/test_server_init.py

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import os
2+
import tempfile
3+
4+
import pytest
5+
from setup_tests import Path, run_request, write_rpc_request
6+
7+
from fortls.constants import Severity
8+
9+
10+
@pytest.fixture()
11+
def setup_tmp_file():
12+
levels = 2000
13+
fd, filename = tempfile.mkstemp(suffix=".f90")
14+
try:
15+
with os.fdopen(fd, "w") as tmp:
16+
tmp.write(
17+
"program nested_if\n"
18+
+ str("if (.true.) then\n" * levels)
19+
+ str("end if\n" * levels)
20+
+ "end program nested_if"
21+
)
22+
yield filename
23+
finally:
24+
os.remove(filename)
25+
26+
27+
def test_recursion_error_handling(setup_tmp_file):
28+
root = Path(setup_tmp_file).parent
29+
request_string = write_rpc_request(1, "initialize", {"rootPath": str(root)})
30+
errcode, results = run_request(request_string)
31+
assert errcode == 0
32+
assert results[0]["type"] == Severity.error

0 commit comments

Comments
 (0)