aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/pyunit/lsp
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2021-01-14 19:44:57 +0100
committerTristan Gingold <tgingold@free.fr>2021-01-16 11:20:10 +0100
commit115c91319dac7b71a8572dfbe3c64564962b14c9 (patch)
tree1e4319be5c0c21a79bc4963930bd91f029b94432 /testsuite/pyunit/lsp
parent2e769f38257102efca35f2715d3bf241dc628bc5 (diff)
downloadghdl-115c91319dac7b71a8572dfbe3c64564962b14c9.tar.gz
ghdl-115c91319dac7b71a8572dfbe3c64564962b14c9.tar.bz2
ghdl-115c91319dac7b71a8572dfbe3c64564962b14c9.zip
pyunit/lsp: fix and reenable some tests
Diffstat (limited to 'testsuite/pyunit/lsp')
-rw-r--r--testsuite/pyunit/lsp/003errors/cmds.json10
-rw-r--r--testsuite/pyunit/lsp/003errors/replies.json2
-rw-r--r--testsuite/pyunit/lsp/LanguageServer.py82
3 files changed, 35 insertions, 59 deletions
diff --git a/testsuite/pyunit/lsp/003errors/cmds.json b/testsuite/pyunit/lsp/003errors/cmds.json
index 03d6b1e37..20fabab7e 100644
--- a/testsuite/pyunit/lsp/003errors/cmds.json
+++ b/testsuite/pyunit/lsp/003errors/cmds.json
@@ -5,8 +5,8 @@
"method": "initialize",
"params": {
"processId": 5529,
- "rootPath": "/home/tgingold/work/vhdl-language-server/tests/003errors",
- "rootUri": "file:///home/tgingold/work/vhdl-language-server/tests/003errors",
+ "rootPath": "/003errors",
+ "rootUri": "file://003errors",
"capabilities": {
"workspace": {
"applyEdit": true,
@@ -203,7 +203,7 @@
"trace": "off",
"workspaceFolders": [
{
- "uri": "file:///home/tgingold/work/vhdl-language-server/tests/003errors",
+ "uri": "file://pyunit/lsp/003errors",
"name": "003errors"
}
]
@@ -219,7 +219,7 @@
"method": "textDocument/didOpen",
"params": {
"textDocument": {
- "uri": "file:///home/tgingold/work/vhdl-language-server/tests/003errors/tc.vhdl",
+ "uri": "file://pyunit/lsp/003errors/tc.vhdl",
"languageId": "vhdl",
"version": 1,
"text": "library ieee;\nuse ieee.std_logic_1164.all;\nuse ieee.std_logic_unsigned.all;\n\nentity tb is\nend tb;\n\narchitecture behav of tb is\n signal s : std_logic_vector(7 downto 0);\nbegin\n assert s /= x\"73\";\nend behav; \n"
@@ -232,7 +232,7 @@
"method": "textDocument/documentSymbol",
"params": {
"textDocument": {
- "uri": "file:///home/tgingold/work/vhdl-language-server/tests/003errors/tc.vhdl"
+ "uri": "file://pyunit/lsp/003errors/tc.vhdl"
}
}
},
diff --git a/testsuite/pyunit/lsp/003errors/replies.json b/testsuite/pyunit/lsp/003errors/replies.json
index 02e9cac85..88f962da5 100644
--- a/testsuite/pyunit/lsp/003errors/replies.json
+++ b/testsuite/pyunit/lsp/003errors/replies.json
@@ -27,7 +27,7 @@
"jsonrpc": "2.0",
"method": "textDocument/publishDiagnostics",
"params": {
- "uri": "file:///home/tgingold/work/vhdl-language-server/tests/003errors/tc.vhdl",
+ "uri": "file://pyunit/lsp/003errors/tc.vhdl",
"diagnostics": [
{
"source": "ghdl",
diff --git a/testsuite/pyunit/lsp/LanguageServer.py b/testsuite/pyunit/lsp/LanguageServer.py
index 5abfe2948..a89117991 100644
--- a/testsuite/pyunit/lsp/LanguageServer.py
+++ b/testsuite/pyunit/lsp/LanguageServer.py
@@ -36,10 +36,10 @@ def show_diffs(name, ref, res):
print('{}.{} unexpected in the result'.format(name, k))
elif isinstance(ref, str) and isinstance(res, str):
if res != ref:
- print('{}: mismatch (ref: {}, result: {})'.format(name, res, ref))
+ print('{}: mismatch (ref: {}, result: {})'.format(name, ref, res))
elif isinstance(ref, int) and isinstance(res, int):
if res != ref:
- print('{}: mismatch (ref: {}, result: {})'.format(name, res, ref))
+ print('{}: mismatch (ref: {}, result: {})'.format(name, ref, res))
elif isinstance(ref, list) and isinstance(res, list):
for i in range(min(len(ref), len(res))):
show_diffs('{}[{}]'.format(name, i), ref[i], res[i])
@@ -54,7 +54,10 @@ def show_diffs(name, ref, res):
class JSONTest(TestCase):
_LSPTestDirectory = Path(__file__).parent.resolve()
- def _RequestResponse(self, requestFile: Path, responseFile: Optional[Path] = None):
+ subdir = None
+
+ def _RequestResponse(self, requestName: str, responseName: Optional[str] = None):
+ requestFile = self._LSPTestDirectory / self.subdir / requestName
# Convert the JSON input file to an LSP string.
with requestFile.open('r') as file:
res = json_load(file)
@@ -68,12 +71,13 @@ class JSONTest(TestCase):
p = subprocess_run(
[executable, '-m', 'pyGHDL.cli.lsp'],
input=conn.res.encode('utf-8'),
- stdout=PIPE
- )
+ cwd=self._LSPTestDirectory / self.subdir,
+ stdout=PIPE)
self.assertEqual(p.returncode, 0, "Language server executable exit with a non-zero return code.")
- if responseFile is None:
+ if responseName is None:
return
+ responseFile = self._LSPTestDirectory / self.subdir / responseName
# Check output
in_io = BytesIO(p.stdout)
@@ -112,95 +116,67 @@ class JSONTest(TestCase):
class Test001_Simple(JSONTest):
- __subdir = Path("001simple")
+ subdir = Path("001simple")
def test_Request_Response(self):
- requestFile = self._LSPTestDirectory / self.__subdir / "cmds.json"
- responseFile = self._LSPTestDirectory / self.__subdir / "replies.json"
+ self._RequestResponse("cmds.json", "replies.json")
- self._RequestResponse(requestFile, responseFile)
class Test002_Coverage(JSONTest):
- __subdir = Path("002coverage")
+ subdir = Path("002coverage")
- @skip("deactivated")
def test_Request_Response(self):
- requestFile = self._LSPTestDirectory / self.__subdir / "cmds.json"
- responseFile = self._LSPTestDirectory / self.__subdir / "replies.json"
+ self._RequestResponse("cmds.json", "replies.json")
- self._RequestResponse(requestFile, responseFile)
class Test003_Errors(JSONTest):
- __subdir = Path("003errors")
+ subdir = Path("003errors")
def test_Crash1(self):
- requestFile = self._LSPTestDirectory / self.__subdir / "crash1.json"
-
- self._RequestResponse(requestFile)
+ self._RequestResponse("crash1.json")
def test_Crash2(self):
- requestFile = self._LSPTestDirectory / self.__subdir / "crash2.json"
-
- self._RequestResponse(requestFile)
+ self._RequestResponse("crash2.json")
- @skip("deactivated")
def test_Request_Response(self):
- requestFile = self._LSPTestDirectory / self.__subdir / "cmds.json"
- responseFile = self._LSPTestDirectory / self.__subdir / "replies.json"
-
- self._RequestResponse(requestFile, responseFile)
+ self._RequestResponse("cmds.json", "replies.json")
class Test004_Error_Project(JSONTest):
- __subdir = Path("004errprj")
+ subdir = Path("004errprj")
- @skip("deactivated")
def test_Request_Response(self):
- commandFile = self._LSPTestDirectory / self.__subdir / "cmds.json"
- responseFile = self._LSPTestDirectory / self.__subdir / "replies.json"
+ self._RequestResponse("cmds.json", "replies.json")
- self._RequestResponse(commandFile, responseFile)
class Test005_Create(JSONTest):
- __subdir = Path("005create")
+ subdir = Path("005create")
- @skip("deactivated")
def test_Request_Response(self):
- commandFile = self._LSPTestDirectory / self.__subdir / "cmds.json"
- responseFile = self._LSPTestDirectory / self.__subdir / "replies.json"
+ self._RequestResponse("cmds.json", "replies.json")
- self._RequestResponse(commandFile, responseFile)
# FIXME: is this case 6?
class Test005_Option_Error(JSONTest):
- __subdir = Path("005opterr")
+ subdir = Path("005opterr")
- @skip("deactivated")
def test_Request_Response(self):
- commandFile = self._LSPTestDirectory / self.__subdir / "cmds.json"
- responseFile = self._LSPTestDirectory / self.__subdir / "replies.json"
+ self._RequestResponse("cmds.json", "replies.json")
- self._RequestResponse(commandFile, responseFile)
#class Test006_?????(JSONTest):
# _CASE = Path("006?????")
+
class Test007_Error_Project(JSONTest):
- __subdir = Path("007errprj")
+ subdir = Path("007errprj")
- @skip("deactivated")
def test_Request_Response(self):
- commandFile = self._LSPTestDirectory / self.__subdir / "cmds.json"
- responseFile = self._LSPTestDirectory / self.__subdir / "replies.json"
+ self._RequestResponse("cmds.json", "replies.json")
- self._RequestResponse(commandFile, responseFile)
class Test008_Error_NoFile(JSONTest):
- __subdir = Path("008errnofile")
+ subdir = Path("008errnofile")
- @skip("deactivated")
def test_Request_Response(self):
- commandFile = self._LSPTestDirectory / self.__subdir / "cmds.json"
- responseFile = self._LSPTestDirectory / self.__subdir / "replies.json"
-
- self._RequestResponse(commandFile, responseFile)
+ self._RequestResponse("cmds.json", "replies.json")