diff --git a/test/libsolidity/lsp/include-paths/using-custom-includes.sol b/test/libsolidity/lsp/include-paths/using-custom-includes.sol new file mode 100644 index 000000000000..228fc2be534c --- /dev/null +++ b/test/libsolidity/lsp/include-paths/using-custom-includes.sol @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + + import "otherlib/otherlib.sol"; +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @SomeTag + +contract MyContract +{ +} +// ---- +// using-custom-includes: @SomeTag 6275 diff --git a/test/libsolidity/lsp/other-include-dir/otherlib/otherlib.sol b/test/libsolidity/lsp/other-include-dir/otherlib/otherlib.sol new file mode 100644 index 000000000000..cbcf206a0664 --- /dev/null +++ b/test/libsolidity/lsp/other-include-dir/otherlib/otherlib.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +library MyRootLib +{ +} diff --git a/test/lsp.py b/test/lsp.py index 48c2a5414756..68db044c8739 100755 --- a/test/lsp.py +++ b/test/lsp.py @@ -16,6 +16,7 @@ from itertools import islice from pathlib import PurePath from typing import Any, List, Optional, Tuple, Union, NewType +from pprint import pprint import colorama # Enables the use of SGR & CUP terminal VT sequences on Windows. from deepdiff import DeepDiff @@ -1381,6 +1382,37 @@ def get_test_tags(self, test_name: TestName, sub_dir=None, verbose=False): return markers + def test_custom_includes(self, solc: JsonRpcProcess) -> None: + self.setup_lsp(solc, expose_project_root=False) + solc.send_notification( + 'workspace/didChangeConfiguration', + { + 'settings': + { + 'include-paths': + [ + f"{self.project_root_dir}/other-include-dir" + ] + } + } + ) + published_diagnostics = self.open_file_and_wait_for_diagnostics(solc, 'include-paths/using-custom-includes') + + pprint(published_diagnostics) + self.expect_equal(len(published_diagnostics), 2, "Diagnostic reports for 2 files") + + # test file + report = published_diagnostics[0] + self.expect_equal(report['uri'], self.get_test_file_uri('using-custom-includes', 'include-paths')) + diagnostics = report['diagnostics'] + self.expect_equal(len(diagnostics), 0, "no diagnostics") + + # imported file + report = published_diagnostics[1] + self.expect_equal(report['uri'], f"{self.project_root_uri}/other-include-dir/otherlib/otherlib.sol") + diagnostics = report['diagnostics'] + self.expect_equal(len(diagnostics), 0, "no diagnostics") + def test_didChange_in_A_causing_error_in_B(self, solc: JsonRpcProcess) -> None: # Reusing another test but now change some file that generates an error in the other. self.test_textDocument_didOpen_with_relative_import(solc)