aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/pyunit/lsp
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2021-01-18 19:13:17 +0100
committerTristan Gingold <tgingold@free.fr>2021-01-19 07:40:56 +0100
commit181943dc7378a8899353ed4b885ab5f290004677 (patch)
treed92f7642a4703bc63f9307e22b580716e83adeca /testsuite/pyunit/lsp
parent7dc3c1979f7451eb517863a5a8c501bc6c3d0a47 (diff)
downloadghdl-181943dc7378a8899353ed4b885ab5f290004677.tar.gz
ghdl-181943dc7378a8899353ed4b885ab5f290004677.tar.bz2
ghdl-181943dc7378a8899353ed4b885ab5f290004677.zip
testsuite/pyunit/lsp: use absolute path and metavalue @ROOT@
Diffstat (limited to 'testsuite/pyunit/lsp')
-rw-r--r--testsuite/pyunit/lsp/001simple/cmds.json8
-rw-r--r--testsuite/pyunit/lsp/001simple/replies.json2
-rw-r--r--testsuite/pyunit/lsp/002coverage/cmds.json36
-rw-r--r--testsuite/pyunit/lsp/002coverage/replies.json46
-rw-r--r--testsuite/pyunit/lsp/003errors/cmds.json10
-rw-r--r--testsuite/pyunit/lsp/003errors/crash1.json8
-rw-r--r--testsuite/pyunit/lsp/003errors/crash2.json10
-rw-r--r--testsuite/pyunit/lsp/003errors/replies.json6
-rw-r--r--testsuite/pyunit/lsp/004errprj/cmds.json8
-rw-r--r--testsuite/pyunit/lsp/004errprj/replies.json4
-rw-r--r--testsuite/pyunit/lsp/005create/cmds.json8
-rw-r--r--testsuite/pyunit/lsp/005create/replies.json4
-rw-r--r--testsuite/pyunit/lsp/006opterr/cmds.json12
-rw-r--r--testsuite/pyunit/lsp/006opterr/replies.json10
-rw-r--r--testsuite/pyunit/lsp/007errprj/cmds.json6
-rw-r--r--testsuite/pyunit/lsp/008errnofile/cmds.json6
-rw-r--r--testsuite/pyunit/lsp/LanguageServer.py43
17 files changed, 131 insertions, 96 deletions
diff --git a/testsuite/pyunit/lsp/001simple/cmds.json b/testsuite/pyunit/lsp/001simple/cmds.json
index e67503258..5681e6314 100644
--- a/testsuite/pyunit/lsp/001simple/cmds.json
+++ b/testsuite/pyunit/lsp/001simple/cmds.json
@@ -5,8 +5,8 @@
"method": "initialize",
"params": {
"processId": 2,
- "rootPath": ".",
- "rootUri": "file:///.",
+ "rootPath": "@ROOT@",
+ "rootUri": "file://@ROOT@/001simple",
"capabilities": {
"workspace": {
"applyEdit": true,
@@ -203,7 +203,7 @@
"trace": "off",
"workspaceFolders": [
{
- "uri": "file:///.",
+ "uri": "file://@ROOT@/001simple",
"name": "001simple"
}
]
@@ -219,7 +219,7 @@
"method": "textDocument/didOpen",
"params": {
"textDocument": {
- "uri": "file:///../files/hello.vhdl",
+ "uri": "file://@ROOT@/files/hello.vhdl",
"languageId": "vhdl",
"version": 1,
"text": "\n-- Hello world program\nuse std.textio.all; -- Imports the standard textio package.\n\n-- Defines a design entity, without any ports.\nentity hello_world is\nend hello_world;\n\narchitecture behaviour of hello_world is\nbegin\n process\n variable l : line;\n begin\n write (l, String'(\"Hello world!\"));\n writeline (output, l);\n wait;\n end process;\nend behaviour;\n\n"
diff --git a/testsuite/pyunit/lsp/001simple/replies.json b/testsuite/pyunit/lsp/001simple/replies.json
index 55a84917b..94d81a90c 100644
--- a/testsuite/pyunit/lsp/001simple/replies.json
+++ b/testsuite/pyunit/lsp/001simple/replies.json
@@ -27,7 +27,7 @@
"jsonrpc": "2.0",
"method": "textDocument/publishDiagnostics",
"params": {
- "uri": "file:///../files/hello.vhdl",
+ "uri": "file://@ROOT@/files/hello.vhdl",
"diagnostics": []
}
}
diff --git a/testsuite/pyunit/lsp/002coverage/cmds.json b/testsuite/pyunit/lsp/002coverage/cmds.json
index d003972a3..3e53f0e0c 100644
--- a/testsuite/pyunit/lsp/002coverage/cmds.json
+++ b/testsuite/pyunit/lsp/002coverage/cmds.json
@@ -5,8 +5,8 @@
"method": "initialize",
"params": {
"processId": 11082,
- "rootPath": "002coverage",
- "rootUri": "file://002coverage",
+ "rootPath": "@ROOT@/002coverage",
+ "rootUri": "file://@ROOT@/002coverage",
"capabilities": {
"workspace": {
"applyEdit": true,
@@ -203,7 +203,7 @@
"trace": "off",
"workspaceFolders": [
{
- "uri": "file://002coverage",
+ "uri": "file://@ROOT@/002coverage",
"name": "002coverage"
}
]
@@ -219,7 +219,7 @@
"method": "textDocument/didOpen",
"params": {
"textDocument": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"languageId": "vhdl",
"version": 1,
"text": "\nentity adder is\n -- `i0`, `i1`, and the carry-in `ci` are inputs of the adder.\n -- `s` is the sum output, `co` is the carry-out.\n port (i0, i1 : in bit; ci : in bit; s : out bit; co : out bit);\nend adder;\n\narchitecture rtl of adder is\nbegin\n -- This full-adder architecture contains two concurrent assignments.\n -- Compute the sum.\n s <= i0 xor i1 xor ci;\n -- Compute the carry.\n co <= (i0 and i1) or (i0 and ci) or (i1 and ci);\nend rtl;\n\n"
@@ -232,7 +232,7 @@
"method": "textDocument/documentSymbol",
"params": {
"textDocument": {
- "uri": "file://files/adder.vhdl"
+ "uri": "file://@ROOT@/files/adder.vhdl"
}
}
},
@@ -241,7 +241,7 @@
"method": "textDocument/didOpen",
"params": {
"textDocument": {
- "uri": "file://files/adder_tb.vhdl",
+ "uri": "file://@ROOT@/files/adder_tb.vhdl",
"languageId": "vhdl",
"version": 1,
"text": "\n-- A testbench has no ports.\nentity adder_tb is\nend adder_tb;\n\narchitecture behav of adder_tb is\n -- Declaration of the component that will be instantiated.\n component adder\n port (i0, i1 : in bit; ci : in bit; s : out bit; co : out bit);\n end component;\n\n -- Specifies which entity is bound with the component.\n for adder_0: adder use entity work.adder;\n signal i0, i1, ci, s, co : bit;\nbegin\n -- Component instantiation.\n adder_0: adder port map (i0 => i0, i1 => i1, ci => ci,\n s => s, co => co);\n\n -- This process does the real job.\n process\n type pattern_type is record\n -- The inputs of the adder.\n i0, i1, ci : bit;\n -- The expected outputs of the adder.\n s, co : bit;\n end record;\n -- The patterns to apply.\n type pattern_array is array (natural range <>) of pattern_type;\n constant patterns : pattern_array :=\n (('0', '0', '0', '0', '0'),\n ('0', '0', '1', '1', '0'),\n ('0', '1', '0', '1', '0'),\n ('0', '1', '1', '0', '1'),\n ('1', '0', '0', '1', '0'),\n ('1', '0', '1', '0', '1'),\n ('1', '1', '0', '0', '1'),\n ('1', '1', '1', '1', '1'));\n begin\n -- Check each pattern.\n for i in patterns'range loop\n -- Set the inputs.\n i0 <= patterns(i).i0;\n i1 <= patterns(i).i1;\n ci <= patterns(i).ci;\n -- Wait for the results.\n wait for 1 ns;\n -- Check the outputs.\n assert s = patterns(i).s\n report \"bad sum value\" severity error;\n assert co = patterns(i).co\n report \"bad carry out value\" severity error;\n end loop;\n assert false report \"end of test\" severity note;\n -- Wait forever; this will finish the simulation.\n wait;\n end process;\nend behav;\n\n\n"
@@ -254,7 +254,7 @@
"method": "textDocument/documentSymbol",
"params": {
"textDocument": {
- "uri": "file://files/adder_tb.vhdl"
+ "uri": "file://@ROOT@/files/adder_tb.vhdl"
}
}
},
@@ -264,7 +264,7 @@
"method": "textDocument/definition",
"params": {
"textDocument": {
- "uri": "file://files/adder_tb.vhdl"
+ "uri": "file://@ROOT@/files/adder_tb.vhdl"
},
"position": {
"line": 12,
@@ -277,7 +277,7 @@
"method": "textDocument/didChange",
"params": {
"textDocument": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"version": 2
},
"contentChanges": [
@@ -304,7 +304,7 @@
"method": "textDocument/documentSymbol",
"params": {
"textDocument": {
- "uri": "file://files/adder.vhdl"
+ "uri": "file://@ROOT@/files/adder.vhdl"
}
}
},
@@ -313,7 +313,7 @@
"method": "textDocument/didChange",
"params": {
"textDocument": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"version": 3
},
"contentChanges": [
@@ -340,7 +340,7 @@
"method": "textDocument/documentSymbol",
"params": {
"textDocument": {
- "uri": "file://files/adder.vhdl"
+ "uri": "file://@ROOT@/files/adder.vhdl"
}
}
},
@@ -349,7 +349,7 @@
"method": "textDocument/didChange",
"params": {
"textDocument": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"version": 4
},
"contentChanges": [
@@ -375,7 +375,7 @@
"method": "textDocument/didChange",
"params": {
"textDocument": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"version": 5
},
"contentChanges": [
@@ -402,7 +402,7 @@
"method": "textDocument/documentSymbol",
"params": {
"textDocument": {
- "uri": "file://files/adder.vhdl"
+ "uri": "file://@ROOT@/files/adder.vhdl"
}
}
},
@@ -411,7 +411,7 @@
"method": "textDocument/didChange",
"params": {
"textDocument": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"version": 6
},
"contentChanges": [
@@ -438,7 +438,7 @@
"method": "textDocument/documentSymbol",
"params": {
"textDocument": {
- "uri": "file://files/adder.vhdl"
+ "uri": "file://@ROOT@/files/adder.vhdl"
}
}
},
@@ -447,7 +447,7 @@
"method": "textDocument/didChange",
"params": {
"textDocument": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"version": 7
},
"contentChanges": [
diff --git a/testsuite/pyunit/lsp/002coverage/replies.json b/testsuite/pyunit/lsp/002coverage/replies.json
index b7bcf55d2..c73c17cb7 100644
--- a/testsuite/pyunit/lsp/002coverage/replies.json
+++ b/testsuite/pyunit/lsp/002coverage/replies.json
@@ -27,7 +27,7 @@
"jsonrpc": "2.0",
"method": "textDocument/publishDiagnostics",
"params": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"diagnostics": []
}
},
@@ -39,7 +39,7 @@
"kind": 2,
"name": "adder",
"location": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"range": {
"start": {
"line": 1,
@@ -56,7 +56,7 @@
"kind": 2,
"name": "rtl",
"location": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"range": {
"start": {
"line": 7,
@@ -75,7 +75,7 @@
"jsonrpc": "2.0",
"method": "textDocument/publishDiagnostics",
"params": {
- "uri": "file://files/adder_tb.vhdl",
+ "uri": "file://@ROOT@/files/adder_tb.vhdl",
"diagnostics": []
}
},
@@ -87,7 +87,7 @@
"kind": 2,
"name": "adder_tb",
"location": {
- "uri": "file://files/adder_tb.vhdl",
+ "uri": "file://@ROOT@/files/adder_tb.vhdl",
"range": {
"start": {
"line": 2,
@@ -104,7 +104,7 @@
"kind": 2,
"name": "behav",
"location": {
- "uri": "file://files/adder_tb.vhdl",
+ "uri": "file://@ROOT@/files/adder_tb.vhdl",
"range": {
"start": {
"line": 5,
@@ -121,7 +121,7 @@
"kind": 6,
"name": "adder_0",
"location": {
- "uri": "file://files/adder_tb.vhdl",
+ "uri": "file://@ROOT@/files/adder_tb.vhdl",
"range": {
"start": {
"line": 16,
@@ -137,7 +137,7 @@
"kind": 2,
"name": "behav",
"location": {
- "uri": "file://files/adder_tb.vhdl",
+ "uri": "file://@ROOT@/files/adder_tb.vhdl",
"range": {
"start": {
"line": 5,
@@ -158,7 +158,7 @@
"id": 3,
"result": [
{
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"range": {
"start": {
"line": 1,
@@ -176,7 +176,7 @@
"jsonrpc": "2.0",
"method": "textDocument/publishDiagnostics",
"params": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"diagnostics": []
}
},
@@ -188,7 +188,7 @@
"kind": 2,
"name": "adder",
"location": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"range": {
"start": {
"line": 1,
@@ -205,7 +205,7 @@
"kind": 2,
"name": "rtl",
"location": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"range": {
"start": {
"line": 7,
@@ -224,7 +224,7 @@
"jsonrpc": "2.0",
"method": "textDocument/publishDiagnostics",
"params": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"diagnostics": [
{
"source": "ghdl",
@@ -297,7 +297,7 @@
"kind": 2,
"name": "adder",
"location": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"range": {
"start": {
"line": 1,
@@ -314,7 +314,7 @@
"kind": 2,
"name": "rtl",
"location": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"range": {
"start": {
"line": 7,
@@ -333,7 +333,7 @@
"jsonrpc": "2.0",
"method": "textDocument/publishDiagnostics",
"params": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"diagnostics": [
{
"source": "ghdl",
@@ -402,7 +402,7 @@
"jsonrpc": "2.0",
"method": "textDocument/publishDiagnostics",
"params": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"diagnostics": [
{
"source": "ghdl",
@@ -475,7 +475,7 @@
"kind": 2,
"name": "adder",
"location": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"range": {
"start": {
"line": 1,
@@ -492,7 +492,7 @@
"kind": 2,
"name": "rtl",
"location": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"range": {
"start": {
"line": 7,
@@ -511,7 +511,7 @@
"jsonrpc": "2.0",
"method": "textDocument/publishDiagnostics",
"params": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"diagnostics": [
{
"source": "ghdl",
@@ -539,7 +539,7 @@
"kind": 2,
"name": "adder",
"location": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"range": {
"start": {
"line": 1,
@@ -556,7 +556,7 @@
"kind": 2,
"name": "rtl",
"location": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"range": {
"start": {
"line": 7,
@@ -575,7 +575,7 @@
"jsonrpc": "2.0",
"method": "textDocument/publishDiagnostics",
"params": {
- "uri": "file://files/adder.vhdl",
+ "uri": "file://@ROOT@/files/adder.vhdl",
"diagnostics": []
}
}
diff --git a/testsuite/pyunit/lsp/003errors/cmds.json b/testsuite/pyunit/lsp/003errors/cmds.json
index 9d0ec527f..2d687517e 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": "/003errors",
- "rootUri": "file://003errors",
+ "rootPath": "@ROOT@/003errors",
+ "rootUri": "file://@ROOT@/003errors",
"capabilities": {
"workspace": {
"applyEdit": true,
@@ -203,7 +203,7 @@
"trace": "off",
"workspaceFolders": [
{
- "uri": "file://pyunit/lsp/003errors",
+ "uri": "file://@ROOT@/003errors",
"name": "003errors"
}
]
@@ -219,7 +219,7 @@
"method": "textDocument/didOpen",
"params": {
"textDocument": {
- "uri": "file://pyunit/lsp/003errors/tc.vhdl",
+ "uri": "file://@ROOT@/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 s <= x\"73\";\nend behav; \n"
@@ -232,7 +232,7 @@
"method": "textDocument/documentSymbol",
"params": {
"textDocument": {
- "uri": "file://pyunit/lsp/003errors/tc.vhdl"
+ "uri": "file://@ROOT@/003errors/tc.vhdl"
}
}
},
diff --git a/testsuite/pyunit/lsp/003errors/crash1.json b/testsuite/pyunit/lsp/003errors/crash1.json
index 49c43326b..c323639ac 100644
--- a/testsuite/pyunit/lsp/003errors/crash1.json
+++ b/testsuite/pyunit/lsp/003errors/crash1.json
@@ -5,8 +5,8 @@
"method": "initialize",
"params": {
"processId": 27805,
- "rootPath": "003errors",
- "rootUri": "file://003errors",
+ "rootPath": "@ROOT@/003errors",
+ "rootUri": "file://@ROOT@/003errors",
"capabilities": {
"workspace": {
"applyEdit": true,
@@ -203,7 +203,7 @@
"trace": "off",
"workspaceFolders": [
{
- "uri": "file://003errors",
+ "uri": "file://@ROOT@/003errors",
"name": "003errors"
}
]
@@ -219,7 +219,7 @@
"method": "textDocument/didOpen",
"params": {
"textDocument": {
- "uri": "file://003errors/tc.vhdl",
+ "uri": "file://@ROOT@/003errors/tc.vhdl",
"languageId": "vhdl",
"version": 74,
"text": "library ieee;\nuse ieee.std_logic_1164.all;\nuse ieee.std_logic_unsigned.all;\n\nentity \n"
diff --git a/testsuite/pyunit/lsp/003errors/crash2.json b/testsuite/pyunit/lsp/003errors/crash2.json
index 4891a0207..a3d89bee1 100644
--- a/testsuite/pyunit/lsp/003errors/crash2.json
+++ b/testsuite/pyunit/lsp/003errors/crash2.json
@@ -5,8 +5,8 @@
"method": "initialize",
"params": {
"processId": 30387,
- "rootPath": "003errors",
- "rootUri": "file://003errors",
+ "rootPath": "@ROOT@/003errors",
+ "rootUri": "file://@ROOT@/003errors",
"capabilities": {
"workspace": {
"applyEdit": true,
@@ -203,7 +203,7 @@
"trace": "off",
"workspaceFolders": [
{
- "uri": "file://003errors",
+ "uri": "file://@ROOT@/003errors",
"name": "003errors"
}
]
@@ -219,7 +219,7 @@
"method": "textDocument/didOpen",
"params": {
"textDocument": {
- "uri": "file://003errors/tc.vhdl",
+ "uri": "file://@ROOT@/003errors/tc.vhdl",
"languageId": "vhdl",
"version": 172,
"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\";\n end process;\nend behav; \n"
@@ -232,7 +232,7 @@
"method": "textDocument/documentSymbol",
"params": {
"textDocument": {
- "uri": "file://003errors/tc.vhdl"
+ "uri": "file://@ROOT@/003errors/tc.vhdl"
}
}
}
diff --git a/testsuite/pyunit/lsp/003errors/replies.json b/testsuite/pyunit/lsp/003errors/replies.json
index 9272ee7c8..65aa5370e 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://pyunit/lsp/003errors/tc.vhdl",
+ "uri": "file://@ROOT@/003errors/tc.vhdl",
"diagnostics": [
{
"source": "ghdl",
@@ -55,7 +55,7 @@
"kind": 2,
"name": "tb",
"location": {
- "uri": "file://pyunit/lsp/003errors/tc.vhdl",
+ "uri": "file://@ROOT@/003errors/tc.vhdl",
"range": {
"start": {
"line": 4,
@@ -72,7 +72,7 @@
"kind": 2,
"name": "behav",
"location": {
- "uri": "file://pyunit/lsp/003errors/tc.vhdl",
+ "uri": "file://@ROOT@/003errors/tc.vhdl",
"range": {
"start": {
"line": 7,
diff --git a/testsuite/pyunit/lsp/004errprj/cmds.json b/testsuite/pyunit/lsp/004errprj/cmds.json
index 813a6cb50..63f9892fb 100644
--- a/testsuite/pyunit/lsp/004errprj/cmds.json
+++ b/testsuite/pyunit/lsp/004errprj/cmds.json
@@ -5,8 +5,8 @@
"method": "initialize",
"params": {
"processId": 2,
- "rootPath": ".",
- "rootUri": "file://.",
+ "rootPath": "@ROOT@",
+ "rootUri": "file://@ROOT@/004errprj",
"capabilities": {
"workspace": {
"applyEdit": true,
@@ -154,7 +154,7 @@
"trace": "off",
"workspaceFolders": [
{
- "uri": "file:///.",
+ "uri": "file://@ROOT@/004errprj",
"name": "workspacename"
}
]
@@ -170,7 +170,7 @@
"method": "textDocument/didOpen",
"params": {
"textDocument": {
- "uri": "file:///../files/hello.vhdl",
+ "uri": "file://@ROOT@/files/hello.vhdl",
"languageId": "vhdl",
"version": 1,
"text": "\n-- Hello world program\nuse std.textio.all; -- Imports the standard textio package.\n\n-- Defines a design entity, without any ports.\nentity hello_world is\nend hello_world;\n\narchitecture behaviour of hello_world is\nbegin\n process\n variable l : line;\n begin\n write (l, String'(\"Hello world!\"));\n writeline (output, l);\n wait;\n end process;\nend behaviour;\n\n"
diff --git a/testsuite/pyunit/lsp/004errprj/replies.json b/testsuite/pyunit/lsp/004errprj/replies.json
index 4c7f38082..7a16646b6 100644
--- a/testsuite/pyunit/lsp/004errprj/replies.json
+++ b/testsuite/pyunit/lsp/004errprj/replies.json
@@ -4,7 +4,7 @@
"method": "window/showMessage",
"params": {
"type": 1,
- "message": "json error in project file ./hdl-prj.json:1:3"
+ "message": "json error in project file @ROOT@/004errprj/hdl-prj.json:1:3"
}
},
{
@@ -35,7 +35,7 @@
"jsonrpc": "2.0",
"method": "textDocument/publishDiagnostics",
"params": {
- "uri": "file:///../files/hello.vhdl",
+ "uri": "file://@ROOT@/files/hello.vhdl",
"diagnostics": []
}
}
diff --git a/testsuite/pyunit/lsp/005create/cmds.json b/testsuite/pyunit/lsp/005create/cmds.json
index c4748062f..d17627af5 100644
--- a/testsuite/pyunit/lsp/005create/cmds.json
+++ b/testsuite/pyunit/lsp/005create/cmds.json
@@ -5,8 +5,8 @@
"method": "initialize",
"params": {
"processId": 6576,
- "rootPath": ".",
- "rootUri": "file://.",
+ "rootPath": "@ROOT@/005create",
+ "rootUri": "file://@ROOT@/005create",
"capabilities": {
"workspace": {
"applyEdit": true,
@@ -224,7 +224,7 @@
"trace": "off",
"workspaceFolders": [
{
- "uri": "file://.",
+ "uri": "file://@ROOT@/005create",
"name": "folder"
}
]
@@ -241,7 +241,7 @@
"method": "textDocument/documentSymbol",
"params": {
"textDocument": {
- "uri": "file://../files/hello.vhdl"
+ "uri": "file://@ROOT@/files/hello.vhdl"
}
}
}
diff --git a/testsuite/pyunit/lsp/005create/replies.json b/testsuite/pyunit/lsp/005create/replies.json
index 327618f6e..79ccd68bc 100644
--- a/testsuite/pyunit/lsp/005create/replies.json
+++ b/testsuite/pyunit/lsp/005create/replies.json
@@ -31,7 +31,7 @@
"kind": 2,
"name": "hello_world",
"location": {
- "uri": "file://../files/hello.vhdl",
+ "uri": "file://@ROOT@/files/hello.vhdl",
"range": {
"start": {
"line": 5,
@@ -48,7 +48,7 @@
"kind": 2,
"name": "behaviour",
"location": {
- "uri": "file://../files/hello.vhdl",
+ "uri": "file://@ROOT@/files/hello.vhdl",
"range": {
"start": {
"line": 8,
diff --git a/testsuite/pyunit/lsp/006opterr/cmds.json b/testsuite/pyunit/lsp/006opterr/cmds.json
index cc96c55f4..d41a24e08 100644
--- a/testsuite/pyunit/lsp/006opterr/cmds.json
+++ b/testsuite/pyunit/lsp/006opterr/cmds.json
@@ -5,8 +5,8 @@
"method": "initialize",
"params": {
"processId": 14698,
- "rootPath": ".",
- "rootUri": "file://.",
+ "rootPath": "@ROOT@",
+ "rootUri": "file://@ROOT@/006opterr",
"capabilities": {
"workspace": {
"applyEdit": true,
@@ -224,8 +224,8 @@
"trace": "off",
"workspaceFolders": [
{
- "uri": "file://005opterr",
- "name": "005opterr"
+ "uri": "file://@ROOT@/006opterr",
+ "name": "006opterr"
}
]
}
@@ -240,7 +240,7 @@
"method": "textDocument/didOpen",
"params": {
"textDocument": {
- "uri": "file://../files/heartbeat.vhdl",
+ "uri": "file://@ROOT@/files/heartbeat.vhdl",
"languageId": "vhdl",
"version": 1,
"text": "\nlibrary ieee;\nuse ieee.std_logic_1164.all;\n\nentity heartbeat is\n port ( clk: out std_logic);\nend heartbeat;\n\narchitecture behaviour of heartbeat\nis\n constant clk_period : time := 10 ns;\nbegin\n -- Clock process definition\n clk_process: process\n begin\n clk <= '0';\n wait for clk_period/2;\n clk <= '1';\n wait for clk_period/2;\n end process;\nend behaviour;\n\n"
@@ -253,7 +253,7 @@
"method": "textDocument/documentSymbol",
"params": {
"textDocument": {
- "uri": "file://../files/heartbeat.vhdl"
+ "uri": "file://@ROOT@/files/heartbeat.vhdl"
}
}
}
diff --git a/testsuite/pyunit/lsp/006opterr/replies.json b/testsuite/pyunit/lsp/006opterr/replies.json
index a5a142112..3c7eadd98 100644
--- a/testsuite/pyunit/lsp/006opterr/replies.json
+++ b/testsuite/pyunit/lsp/006opterr/replies.json
@@ -35,7 +35,7 @@
"jsonrpc": "2.0",
"method": "textDocument/publishDiagnostics",
"params": {
- "uri": "file://../files/heartbeat.vhdl",
+ "uri": "file://@ROOT@/files/heartbeat.vhdl",
"diagnostics": []
}
},
@@ -47,7 +47,7 @@
"kind": 2,
"name": "heartbeat",
"location": {
- "uri": "file://../files/heartbeat.vhdl",
+ "uri": "file://@ROOT@/files/heartbeat.vhdl",
"range": {
"start": {
"line": 4,
@@ -64,7 +64,7 @@
"kind": 2,
"name": "behaviour",
"location": {
- "uri": "file://../files/heartbeat.vhdl",
+ "uri": "file://@ROOT@/files/heartbeat.vhdl",
"range": {
"start": {
"line": 8,
@@ -81,7 +81,7 @@
"kind": 6,
"name": "clk_process",
"location": {
- "uri": "file://../files/heartbeat.vhdl",
+ "uri": "file://@ROOT@/files/heartbeat.vhdl",
"range": {
"start": {
"line": 13,
@@ -97,7 +97,7 @@
"kind": 2,
"name": "behaviour",
"location": {
- "uri": "file://../files/heartbeat.vhdl",
+ "uri": "file://@ROOT@/files/heartbeat.vhdl",
"range": {
"start": {
"line": 8,
diff --git a/testsuite/pyunit/lsp/007errprj/cmds.json b/testsuite/pyunit/lsp/007errprj/cmds.json
index d560fae75..7b6e29b5f 100644
--- a/testsuite/pyunit/lsp/007errprj/cmds.json
+++ b/testsuite/pyunit/lsp/007errprj/cmds.json
@@ -5,8 +5,8 @@
"method": "initialize",
"params": {
"processId": 2,
- "rootPath": ".",
- "rootUri": "file://.",
+ "rootPath": "@ROOT@/007errprj",
+ "rootUri": "file://@ROOT@/007errprj",
"capabilities": {
"workspace": {
"applyEdit": true,
@@ -154,7 +154,7 @@
"trace": "off",
"workspaceFolders": [
{
- "uri": "file:///.",
+ "uri": "file://@ROOT@/007errprj",
"name": "workspacename"
}
]
diff --git a/testsuite/pyunit/lsp/008errnofile/cmds.json b/testsuite/pyunit/lsp/008errnofile/cmds.json
index 4d6a26d57..44f0c80fb 100644
--- a/testsuite/pyunit/lsp/008errnofile/cmds.json
+++ b/testsuite/pyunit/lsp/008errnofile/cmds.json
@@ -5,8 +5,8 @@
"method": "initialize",
"params": {
"processId": 19954,
- "rootPath": ".",
- "rootUri": "file://.",
+ "rootPath": "@ROOT@/008errnofile",
+ "rootUri": "file://@ROOT@/008errnofile",
"capabilities": {
"workspace": {
"applyEdit": true,
@@ -224,7 +224,7 @@
"trace": "off",
"workspaceFolders": [
{
- "uri": "file://.",
+ "uri": "file://@ROOT@/008errnofile",
"name": "008errnofile"
}
]
diff --git a/testsuite/pyunit/lsp/LanguageServer.py b/testsuite/pyunit/lsp/LanguageServer.py
index 0ce296a11..46f330467 100644
--- a/testsuite/pyunit/lsp/LanguageServer.py
+++ b/testsuite/pyunit/lsp/LanguageServer.py
@@ -1,7 +1,8 @@
+import os
+import string
+from sys import executable
from io import BytesIO
from json import load as json_load, loads as json_loads, dumps as json_dumps
-from os import environ
-from sys import executable
from pathlib import Path
from subprocess import run as subprocess_run, PIPE
from typing import Optional
@@ -9,6 +10,8 @@ from unittest import TestCase, skip
from pyGHDL.lsp.lsp import LanguageProtocolServer, LSPConn
+is_windows = os.name == "nt"
+
class StrConn:
__res: str
@@ -53,16 +56,48 @@ def show_diffs(name, ref, res):
print('unhandle type {} in {}'.format(type(ref), name))
+def root_subst(obj, root):
+ """Substitute in all strings of :param obj: @ROOT@ with :param root:
+ URI in LSP are supposed to contain an absolute path. But putting an
+ hard absolute path would make the test suite not portable. So we use
+ the metaname @ROOT@ which should be replaced by the root path of the
+ test suite. Also we need to deal with the windows particularity
+ about URI."""
+ if isinstance(obj, dict):
+ for k, v in obj.items():
+ if isinstance(v, str):
+ if k in ('rootUri', 'uri'):
+ assert v.startswith("file://@ROOT@/")
+ p = "file://" + ("/" if is_windows else "")
+ obj[k] = p + root + v[13:]
+ elif k in ('rootPath', 'message'):
+ obj[k] = v.replace('@ROOT@', root)
+ else:
+ obj[k] = root_subst(v, root)
+ return obj
+ elif obj is None or isinstance(obj, (str, int)):
+ return obj
+ elif isinstance(obj, list):
+ res = []
+ for v in obj:
+ res.append(root_subst(v, root))
+ return res
+ else:
+ raise AssertionError("root_subst: unhandled type {}".format(type(obj)))
+
+
class JSONTest(TestCase):
_LSPTestDirectory = Path(__file__).parent.resolve()
subdir = None
def _RequestResponse(self, requestName: str, responseName: Optional[str] = None):
+ root = str(self._LSPTestDirectory)
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)
+ res = root_subst(res, root)
conn = StrConn()
ls = LanguageProtocolServer(None, conn)
@@ -71,9 +106,8 @@ class JSONTest(TestCase):
# Run
p = subprocess_run(
- [executable, '-m', 'pyGHDL.cli.lsp'],
+ [executable, '-m', 'pyGHDL.cli.lsp', '-v'],
input=conn.res.encode('utf-8'),
- cwd=self._LSPTestDirectory / self.subdir,
stdout=PIPE)
self.assertEqual(p.returncode, 0, "Language server executable exit with a non-zero return code.")
@@ -87,6 +121,7 @@ class JSONTest(TestCase):
ls = LanguageProtocolServer(None, conn)
with responseFile.open('r') as file:
ref = json_load(file)
+ ref = root_subst(ref, root)
errs = 0
json_res = []