Fixes to lsp.py with respect to Windows drive-letter paths in URI.

This commit is contained in:
Christian Parpart 2022-04-25 15:35:24 +02:00
parent f308f1a1f8
commit c2f245b40a

View File

@ -12,6 +12,7 @@ import tty
import functools import functools
from collections import namedtuple from collections import namedtuple
from copy import deepcopy from copy import deepcopy
from pathlib import PurePath
from typing import Any, List, Optional, Tuple, Union from typing import Any, List, Optional, Tuple, Union
from itertools import islice from itertools import islice
@ -694,7 +695,7 @@ class SolidityLSPTestSuite: # {{{
args = create_cli_parser().parse_args() args = create_cli_parser().parse_args()
self.solc_path = args.solc_path self.solc_path = args.solc_path
self.project_root_dir = os.path.realpath(args.project_root_dir) + "/test/libsolidity/lsp" self.project_root_dir = os.path.realpath(args.project_root_dir) + "/test/libsolidity/lsp"
self.project_root_uri = "file://" + self.project_root_dir self.project_root_uri = PurePath(self.project_root_dir).as_uri()
self.print_assertions = args.print_assertions self.print_assertions = args.print_assertions
self.trace_io = args.trace_io self.trace_io = args.trace_io
self.test_pattern = args.test_pattern self.test_pattern = args.test_pattern
@ -777,7 +778,7 @@ class SolidityLSPTestSuite: # {{{
return f"{self.project_root_dir}/{test_case_name}.sol" return f"{self.project_root_dir}/{test_case_name}.sol"
def get_test_file_uri(self, test_case_name): def get_test_file_uri(self, test_case_name):
return "file://" + self.get_test_file_path(test_case_name) return PurePath(self.get_test_file_path(test_case_name)).as_uri()
def get_test_file_contents(self, test_case_name): def get_test_file_contents(self, test_case_name):
""" """
@ -1438,7 +1439,7 @@ class SolidityLSPTestSuite: # {{{
""" """
self.setup_lsp(solc) self.setup_lsp(solc)
FILE_A_URI = f'file://{self.project_root_dir}/a.sol' FILE_A_URI = f'{self.project_root_uri}/a.sol'
solc.send_message('textDocument/didOpen', { solc.send_message('textDocument/didOpen', {
'textDocument': { 'textDocument': {
'uri': FILE_A_URI, 'uri': FILE_A_URI,
@ -1466,7 +1467,7 @@ class SolidityLSPTestSuite: # {{{
) )
reports = self.wait_for_diagnostics(solc) reports = self.wait_for_diagnostics(solc)
self.expect_equal(len(reports), 1, '') self.expect_equal(len(reports), 1, '')
self.expect_equal(reports[0]['uri'], f'file://{self.project_root_dir}/lib.sol', "") self.expect_equal(reports[0]['uri'], f'{self.project_root_uri}/lib.sol', "")
self.expect_equal(len(reports[0]['diagnostics']), 0, "should not contain diagnostics") self.expect_equal(len(reports[0]['diagnostics']), 0, "should not contain diagnostics")
def test_textDocument_didChange_at_eol(self, solc: JsonRpcProcess) -> None: def test_textDocument_didChange_at_eol(self, solc: JsonRpcProcess) -> None: