From c71d90e12ce0713b4fc374da2a429398a85a3a94 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 30 Oct 2024 18:15:15 +0100 Subject: [PATCH 1/2] chore: Remove extra pthread parameters --- src/frontend/CMakeLists.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/frontend/CMakeLists.txt b/src/frontend/CMakeLists.txt index 6a27191d..8279a8cd 100644 --- a/src/frontend/CMakeLists.txt +++ b/src/frontend/CMakeLists.txt @@ -21,7 +21,7 @@ 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}" @@ -29,14 +29,12 @@ target_compile_definitions(cxx PRIVATE # 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" From f403130bfbe4f5ed25ed2d866f6b0cacf77cb4d5 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Wed, 30 Oct 2024 18:50:47 +0100 Subject: [PATCH 2/2] chore: Add LSP unit tests --- tests/unit_tests/CMakeLists.txt | 1 + tests/unit_tests/lit.cfg.py | 2 +- tests/unit_tests/lsp/CMakeLists.txt | 21 +++++++++++++++++++++ tests/unit_tests/lsp/document_01.yml | 18 ++++++++++++++++++ tests/unit_tests/lsp/lifecycle_01.yml | 18 ++++++++++++++++++ 5 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 tests/unit_tests/lsp/CMakeLists.txt create mode 100644 tests/unit_tests/lsp/document_01.yml create mode 100644 tests/unit_tests/lsp/lifecycle_01.yml diff --git a/tests/unit_tests/CMakeLists.txt b/tests/unit_tests/CMakeLists.txt index f9e81a96..98012636 100644 --- a/tests/unit_tests/CMakeLists.txt +++ b/tests/unit_tests/CMakeLists.txt @@ -56,3 +56,4 @@ add_subdirectory(preprocessor) add_subdirectory(parser) add_subdirectory(ast) add_subdirectory(sema) +add_subdirectory(lsp) diff --git a/tests/unit_tests/lit.cfg.py b/tests/unit_tests/lit.cfg.py index 5d81dc89..9da79ead 100644 --- a/tests/unit_tests/lit.cfg.py +++ b/tests/unit_tests/lit.cfg.py @@ -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__) diff --git a/tests/unit_tests/lsp/CMakeLists.txt b/tests/unit_tests/lsp/CMakeLists.txt new file mode 100644 index 00000000..42c7e605 --- /dev/null +++ b/tests/unit_tests/lsp/CMakeLists.txt @@ -0,0 +1,21 @@ +# Copyright (c) 2024 Roberto Raggi +# +# 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 $.lit -v ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/tests/unit_tests/lsp/document_01.yml b/tests/unit_tests/lsp/document_01.yml new file mode 100644 index 00000000..36b7b99a --- /dev/null +++ b/tests/unit_tests/lsp/document_01.yml @@ -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" } + + + diff --git a/tests/unit_tests/lsp/lifecycle_01.yml b/tests/unit_tests/lsp/lifecycle_01.yml new file mode 100644 index 00000000..f269afc8 --- /dev/null +++ b/tests/unit_tests/lsp/lifecycle_01.yml @@ -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" } + + +