Skip to content

Commit c84dc04

Browse files
committed
chore: Add LSP unit tests
1 parent 5c97a83 commit c84dc04

File tree

5 files changed

+59
-1
lines changed

5 files changed

+59
-1
lines changed

tests/unit_tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,4 @@ add_subdirectory(preprocessor)
5656
add_subdirectory(parser)
5757
add_subdirectory(ast)
5858
add_subdirectory(sema)
59+
add_subdirectory(lsp)

tests/unit_tests/lit.cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
config.test_format = lit.formats.ShTest()
2828

29-
config.suffixes = [".cc"]
29+
config.suffixes = [".cc", ".yml"]
3030

3131
config.test_source_root = os.path.dirname(__file__)
3232

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright (c) 2024 Roberto Raggi <[email protected]>
2+
#
3+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
# this software and associated documentation files (the "Software"), to deal in
5+
# the Software without restriction, including without limitation the rights to
6+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7+
# the Software, and to permit persons to whom the Software is furnished to do so,
8+
# subject to the following conditions:
9+
#
10+
# The above copyright notice and this permission notice shall be included in all
11+
# copies or substantial portions of the Software.
12+
#
13+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19+
20+
add_test(NAME lsp
21+
COMMAND lit::tool --config-prefix $<CONFIG>.lit -v ${CMAKE_CURRENT_BINARY_DIR})
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# RUN: %cxx -lsp-test < %s | %filecheck %s
2+
3+
{ "method": "initialize" }
4+
5+
{ "method": "textDocument/didOpen", "params": { "textDocument": { "uri": "test:///source.cc", "version": 0, "text": "auto main() -> int;" } } }
6+
7+
# CHECK: "method": "textDocument/publishDiagnostics"
8+
# CHECK: "params":
9+
# CHECK: "diagnostics": []
10+
# CHECK: "uri": "test:///source.cc"
11+
# CHECK: "version": 0
12+
13+
{ "method": "shutdown" }
14+
15+
{ "method": "exit" }
16+
17+
18+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# RUN: %cxx -lsp-test < %s | %filecheck %s
2+
3+
{ "method": "initialize" }
4+
5+
# CHECK: "result":
6+
# CHECK: "capabilities":
7+
# CHECK: "textDocumentSync":
8+
9+
# CHECK: "serverInfo":
10+
# CHECK: "name":
11+
# CHECK: "version":
12+
13+
{ "method": "shutdown" }
14+
15+
{ "method": "exit" }
16+
17+
18+

0 commit comments

Comments
 (0)