-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #446 from tomoto/fix/recursion-error-in-initializa…
…tion fix: catch RecursionError in initialization
- Loading branch information
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os | ||
import tempfile | ||
|
||
import pytest | ||
from setup_tests import Path, run_request, write_rpc_request | ||
|
||
from fortls.constants import Severity | ||
|
||
|
||
@pytest.fixture() | ||
def setup_tmp_file(): | ||
levels = 2000 | ||
fd, filename = tempfile.mkstemp(suffix=".f90") | ||
try: | ||
with os.fdopen(fd, "w") as tmp: | ||
tmp.write( | ||
"program nested_if\n" | ||
+ str("if (.true.) then\n" * levels) | ||
+ str("end if\n" * levels) | ||
+ "end program nested_if" | ||
) | ||
yield filename | ||
finally: | ||
os.remove(filename) | ||
|
||
|
||
def test_recursion_error_handling(setup_tmp_file): | ||
root = Path(setup_tmp_file).parent | ||
request_string = write_rpc_request(1, "initialize", {"rootPath": str(root)}) | ||
errcode, results = run_request(request_string) | ||
assert errcode == 0 | ||
assert results[0]["type"] == Severity.error |