Skip to content

Commit

Permalink
lsp: Adding test for custom include paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
christianparpart committed Jul 12, 2022
1 parent 39ea365 commit c3cbd81
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/libsolidity/lsp/include-paths/using-custom-includes.sol
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions test/libsolidity/lsp/other-include-dir/otherlib/otherlib.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.0;

library MyRootLib
{
}
32 changes: 32 additions & 0 deletions test/lsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c3cbd81

Please sign in to comment.