From c2f245b40a20bc053c744ae6011df6bf7150d0d8 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Mon, 25 Apr 2022 15:35:24 +0200 Subject: [PATCH] Fixes to lsp.py with respect to Windows drive-letter paths in URI. --- test/lsp.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/lsp.py b/test/lsp.py index 79be59f8e..33059c43d 100755 --- a/test/lsp.py +++ b/test/lsp.py @@ -12,6 +12,7 @@ import tty import functools from collections import namedtuple from copy import deepcopy +from pathlib import PurePath from typing import Any, List, Optional, Tuple, Union from itertools import islice @@ -694,7 +695,7 @@ class SolidityLSPTestSuite: # {{{ args = create_cli_parser().parse_args() self.solc_path = args.solc_path 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.trace_io = args.trace_io self.test_pattern = args.test_pattern @@ -777,7 +778,7 @@ class SolidityLSPTestSuite: # {{{ return f"{self.project_root_dir}/{test_case_name}.sol" 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): """ @@ -1438,7 +1439,7 @@ class SolidityLSPTestSuite: # {{{ """ 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', { 'textDocument': { 'uri': FILE_A_URI, @@ -1466,7 +1467,7 @@ class SolidityLSPTestSuite: # {{{ ) reports = self.wait_for_diagnostics(solc) 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") def test_textDocument_didChange_at_eol(self, solc: JsonRpcProcess) -> None: