diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 29e439b0a97505591a74e2407ba17bcc584f45e4..efd33f3b30beaa153b749ac6cfb669f494cff66e 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -5,9 +5,8 @@ COPY .docker/wait-for-it.sh /wait-for-it.sh # build and install caosdb-cpplib WORKDIR /libcaosdb/ -RUN mkdir build -WORKDIR /libcaosdb/build -RUN conan create -s "compiler.libcxx=libstdc++11" -o caosdb:build_acm=True .. "caosdb/$(conan inspect --raw version ..)@_/_" +RUN conan profile detect -f +RUN make conan COPY . /caosdb-cppinttest WORKDIR /caosdb-cppinttest @@ -17,10 +16,7 @@ COPY .docker/caosdb-client.json /caosdb-client.json # Build and run tests. # If no other command is given to the Docker image -CMD mkdir build && \ - cd build && \ - conan install .. -s "compiler.libcxx=libstdc++11" && \ - cmake .. && \ - cmake --build . && \ +CMD make build-release &&\ + cd build/Release &&\ /wait-for-it.sh caosdb-server:10443 -t 500 -- \ ctest -V diff --git a/.gitignore b/.gitignore index 2df735637f2c21743cd290bccc49bee78a57da95..425118edef63bd4aaf7962d39f6db9db776187a3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ build/ include/libcaosdbConfig.h cert/ -.* # CMake CMakeLists.txt.user diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 93e5484652c11d1694a21f0aee6703e56d9d879f..7db556ade9e65934034e1a02d376f34e663274da 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -100,12 +100,8 @@ build-test: tags: [ docker ] stage: build script: - - echo $PWD - - mkdir build - - cd build - - conan install .. -s "compiler.libcxx=libstdc++11" - - cmake .. - - cmake --build . + - echo $PWD + - make build-release test: diff --git a/CMakeLists.txt b/CMakeLists.txt index e4c84cfc7a4482175b39037dc6b29cdd60e8f695..7f9f58f309e395676313e9e2b683895e4e87f920 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,20 +28,16 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - -# dependency management with conan -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - -# fix grpc - remove unsecure (no-op ssl implementations) -string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_LIBS_GRPC - "${CONAN_LIBS_GRPC}") -string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_PKG_LIBS_GRPC - "${CONAN_PKG_LIBS_GRPC}") -string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_LIBS - "${CONAN_LIBS}") -string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_PKG_LIBS - "${CONAN_PKG_LIBS}") +# # fix grpc - remove unsecure (no-op ssl implementations) +# TODO: Find out if this is still necessary +# string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_LIBS_GRPC +# "${CONAN_LIBS_GRPC}") +# string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_PKG_LIBS_GRPC +# "${CONAN_PKG_LIBS_GRPC}") +# string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_LIBS +# "${CONAN_LIBS}") +# string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_PKG_LIBS +# "${CONAN_PKG_LIBS}") set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) diff --git a/Makefile b/Makefile index 214c6f224054ad9f8d6dd267f2adb82aac94a3a1..b9f64190d098669d2f2f1f20a645ac682510c442 100644 --- a/Makefile +++ b/Makefile @@ -35,14 +35,46 @@ CLANG_TIDY_CMD = $(CLANG_TIDY) \ .PHONY: help help: @echo "Targets:" - @echo " conan-install - Install locally with Conan." + @echo " conan-install-debug - Install locally with Conan." + @echo " conan-install-release - Install locally with Conan." @echo " format - auto-format the source files." + @echo " build-debug - Build the project in Debug mode." + @echo " build-release - Build the project in Release mode." + @echo " test-debug - Run the tests in Debug mode." + @echo " test-release - Run the tests in Release mode." + @echo " clean - Remove build directories." -conan-install: - conan install . -s "compiler.libcxx=libstdc++11" -.PHONY: conan-install +conan-install-debug: + conan install . -s "compiler.libcxx=libstdc++11" -s build_type=Debug --build=missing + +conan-install-release: + conan install . -s "compiler.libcxx=libstdc++11" -s build_type=Release --build=missing format: $(CLANG_FORMAT) -i --verbose \ $$(find test/ -type f -iname "*.cpp" -o -iname "*.h" -o -iname "*.h.in") .PHONY: format + +build-debug: conan-install-debug + # cmake --preset conan-debug && cmake --build build/Debug # for CMake >= 3.23 + cd build/Debug &&\ + cmake -S ../.. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=generators/conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Debug &&\ + cmake --build . + +build-release: conan-install-release + # cmake --preset conan-release # for CMake >= 3.23 + cd build/Release &&\ + cmake -S ../.. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=generators/conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release &&\ + cmake --build . + + +test-debug: build-debug + cd build/Debug && ctest + +test-release: build-release + cd build/Release && ctest + +clean: + rm -rf build + +.PHONY: conan-install-debug conan-install-release build-debug build-release test-debug test-release \ No newline at end of file diff --git a/README.md b/README.md index 46060729d020e592e1087eaa28effe4a1df96216..62f212d73fe34679b36c26c2a6e5f0404113e223 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,21 @@ Integration tests for caosdb-cpplib and the caosdb-server # Run tests -## Prerequisite +## Prerequisites + Create a local conan package from the caosdb-cpplib repository ## Build & Execution -1. `mkdir build && cd build/` -2. `conan install .. -s "compiler.libcxx=libstdc++11"` -3. `cmake -B . ..` + +``` +make test-release +``` + +or manually via + +1. `conan install . -s build_type=<Debug/Release> --build=missing` +2. `cmake --preset conan-<debug/release>` +3. `cd build <Debug/Release>` 4. `cmake --build .` 5. Provide client configuration at `~/.caosdb-client.json` or via any other method described in the docs. 6. There are tests which need access to the server's certificate file. Define diff --git a/conanfile.txt b/conanfile.txt index cd80b1474b1d209d6678d95b12a958e3110163ba..05e1980285d6357168d97392f1d828bcc2074fe5 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -1,11 +1,17 @@ [requires] caosdb/[>=0.3.0-dev, include_prerelease=True] +protobuf/3.21.12 +grpc/1.48.4 -[build_requires] +[test_requires] gtest/1.11.0 [generators] -cmake +CMakeDeps +CMakeToolchain [options] -caosdb:build_acm=True +caosdb*:build_acm=True + +[layout] +cmake_layout \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4c740017f3628d32fce456b9ec7dfd54670704ee..1b89cfdb7a130d6741a51f152f056400bd2c0b60 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -86,10 +86,9 @@ if(LINTING) else() message(STATUS "clang-tidy: ${clang_tidy}") set(_CMAKE_CXX_CLANG_TIDY "${clang_tidy}" - "--header-filter=caosdb/.*[^\(\.pb\.h\)]$" - "--fix") + "--header-filter=caosdb/.*[^\(\.pb\.h\)]$") set(_CMAKE_CXX_CLANG_TIDY_CHECKS - "--checks=*,-fuchsia-*,-llvmlibc-*,-cert-err58-cpp,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-modernize-use-trailing-return-type,-google-readability-avoid-underscore-in-googletest-name,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-cppcoreguidelines-avoid-goto,-hicpp-avoid-goto,-readability-function-cognitive-complexity,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-hicpp-no-array-decay,-altera-*") + "--checks=*,-fuchsia-*,-llvmlibc-*,-cert-err58-cpp,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-modernize-use-trailing-return-type,-google-readability-avoid-underscore-in-googletest-name,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-cppcoreguidelines-avoid-goto,-hicpp-avoid-goto,-readability-function-cognitive-complexity,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-hicpp-no-array-decay,-altera-*,-misc-include-cleaner,-readability-identifier-length") endif() else() message(STATUS "LINTING is OFF") @@ -103,22 +102,25 @@ endif() # add special cmake functions for gtest include(GoogleTest REQUIRED) +find_package(caosdb) +find_package(GTest) +find_package(gRPC) +find_package(protobuf) + # loop over all test cases and add them to the test runner list(LENGTH test_cases len_test_cases) math(EXPR len_test_cases "${len_test_cases} - 1") foreach (i RANGE "${len_test_cases}") list(GET test_cases ${i} test_case_name) add_executable(${test_case_name} ${test_case_name}.cpp) - target_link_libraries(${test_case_name} PRIVATE ${CONAN_LIBS_CAOSDB} - ${CONAN_LIBS_GTEST} ${CONAN_LIBS_GRPC} ${CONAN_LIBS_ABSEIL} - ${CONAN_LIBS_OPENSSL} ${CONAN_LIBS_C-ARES} ${CONAN_LIBS_BZIP2} - ${CONAN_LIBS_PROTOBUF} ${CONAN_LIBS_ZLIB} ${CONAN_LIBS_RE2} - ${CONAN_LIBS_BOOST}) + target_link_libraries(${test_case_name} PRIVATE + caosdb::caosdb gtest::gtest grpc::grpc protobuf::protobuf + ) if("${CMAKE_BUILD_TYPE}" MATCHES "Debug") target_link_libraries(${test_case_name} PRIVATE caosdb_grpc) endif() target_include_directories(${test_case_name} - PUBLIC ${CONAN_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) if(LINTING) set_target_properties(${test_case_name} PROPERTIES