Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/frontend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,20 @@ aux_source_directory(cxx SOURCES)

add_executable(cxx ${SOURCES})

target_link_libraries(cxx cxx-parser cxx-lsp)
target_link_libraries(cxx PRIVATE cxx-parser cxx-lsp)

target_compile_definitions(cxx PRIVATE
CXX_VERSION="${CMAKE_PROJECT_VERSION}"
)

# if cmake founds the Threads package, link with it
if(Threads_FOUND)
target_link_libraries(cxx Threads::Threads)
target_compile_options(cxx PRIVATE -pthread)
target_link_libraries(cxx PRIVATE Threads::Threads)
else()
target_compile_definitions(cxx PRIVATE CXX_NO_THREADS)
target_compile_definitions(cxx PRIVATE CXX_NO_THREADS)
endif()

if(EMSCRIPTEN)
target_link_options(cxx PRIVATE -pthread)
target_link_options(cxx PRIVATE
"SHELL:-s EXIT_RUNTIME=1"
"SHELL:-s WASM_BIGINT=1"
Expand Down
1 change: 1 addition & 0 deletions tests/unit_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ add_subdirectory(preprocessor)
add_subdirectory(parser)
add_subdirectory(ast)
add_subdirectory(sema)
add_subdirectory(lsp)
2 changes: 1 addition & 1 deletion tests/unit_tests/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

config.test_format = lit.formats.ShTest()

config.suffixes = [".cc"]
config.suffixes = [".cc", ".yml"]

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

Expand Down
21 changes: 21 additions & 0 deletions tests/unit_tests/lsp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) 2024 Roberto Raggi <roberto.raggi@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

add_test(NAME lsp
COMMAND lit::tool --config-prefix $<CONFIG>.lit -v ${CMAKE_CURRENT_BINARY_DIR})
18 changes: 18 additions & 0 deletions tests/unit_tests/lsp/document_01.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# RUN: %cxx -lsp-test < %s | %filecheck %s

{ "method": "initialize" }

{ "method": "textDocument/didOpen", "params": { "textDocument": { "uri": "test:///source.cc", "version": 0, "text": "auto main() -> int;" } } }

# CHECK: "method": "textDocument/publishDiagnostics"
# CHECK: "params":
# CHECK: "diagnostics": []
# CHECK: "uri": "test:///source.cc"
# CHECK: "version": 0

{ "method": "shutdown" }

{ "method": "exit" }



18 changes: 18 additions & 0 deletions tests/unit_tests/lsp/lifecycle_01.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# RUN: %cxx -lsp-test < %s | %filecheck %s

{ "method": "initialize" }

# CHECK: "result":
# CHECK: "capabilities":
# CHECK: "textDocumentSync":

# CHECK: "serverInfo":
# CHECK: "name":
# CHECK: "version":

{ "method": "shutdown" }

{ "method": "exit" }