From 629bed186cf2e20dcaffdd3b73e9155d088abb0d Mon Sep 17 00:00:00 2001 From: Finn Hackett Date: Tue, 20 Aug 2024 16:43:13 +0100 Subject: [PATCH] Fix intrusive_ptr test breakage in dependencies (#131) * Fix intrusive_ptr test breakage in dependencies * make tests optional, defaulted to OFF * ensure testing is enabled across entire CI matrix * fix ninja CI variant * do spaces in Github expressions avoid flaky behavior? * add build-type Release back * resolve matrix confusion * give global cmake flags a name --- .github/workflows/buildtest.yml | 9 +++++++-- CMakeLists.txt | 8 ++++++-- test/CMakeLists.txt | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/buildtest.yml b/.github/workflows/buildtest.yml index 7bf45026..6f0a0f1b 100644 --- a/.github/workflows/buildtest.yml +++ b/.github/workflows/buildtest.yml @@ -6,17 +6,22 @@ on: pull_request: branches: [ "main" ] +env: + global-cmake-flags: -DTRIESTE_ENABLE_TESTING=1 + jobs: build-test: strategy: matrix: platform: [ "ubuntu-latest", "macos-latest", "windows-latest" ] build-type: [ "Release", "Debug" ] + # Note: cmake-options is missing here on purpose to let it be overridden by includes standard: [ "", "-DTRIESTE_USE_CXX17=ON" ] compiler: [ "", "clang" ] variant: [""] include: + # ensures ubuntu-latest clang uses Ninja (modifies the matrix entry) - platform: "ubuntu-latest" compiler: "clang" cmake-options: "-DCMAKE_CXX_COMPILER=clang++-15 -DCMAKE_C_COMPILER=clang-15 -DTRIESTE_BUILD_PARSER_TESTS=1" @@ -62,10 +67,10 @@ jobs: - uses: actions/checkout@v3 - name: Install build dependencies - run: ${{ matrix.dependencies }} + run: ${{matrix.dependencies}} - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build-type}} ${{matrix.generator}} ${{matrix.standard}} ${{matrix.cmake-options}} + run: cmake -B ${{github.workspace}}/build ${{env.global-cmake-flags}} -DCMAKE_BUILD_TYPE=${{matrix.build-type}} ${{matrix.generator}} ${{matrix.standard}} ${{matrix.cmake-options}} - name: Build run: cmake --build ${{github.workspace}}/build --config ${{matrix.build-type}} diff --git a/CMakeLists.txt b/CMakeLists.txt index 03a810e8..8d0981f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ project(trieste VERSION 1.0.0 LANGUAGES CXX) # ############################################# # Options +option(TRIESTE_ENABLE_TESTING "Specifies whether to enable Trieste's tests" OFF) option(TRIESTE_BUILD_SAMPLES "Specifies whether to build the samples" ON) option(TRIESTE_BUILD_PARSERS "Specifies whether to build the parsers" ON) option(TRIESTE_BUILD_PARSER_TESTS "Specifies whether to build the parser tests" OFF) @@ -175,12 +176,15 @@ export(PACKAGE trieste) # ############################################# # # Add core Trieste tests -enable_testing() -add_subdirectory(test) +if(TRIESTE_ENABLE_TESTING) + enable_testing() + add_subdirectory(test) +endif() # ############################################# # # Add samples if(TRIESTE_BUILD_SAMPLES) + enable_testing() add_subdirectory(samples/infix) endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1dfae8d3..d9fe172b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -11,4 +11,4 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT TRIESTE_SANITIZE) target_link_libraries(trieste_intrusive_ptr_test -fsanitize=thread) endif() -add_test(NAME trieste_intrusive_ptr_test COMMAND trieste_intrusive_ptr_test) +add_test(NAME trieste_intrusive_ptr_test COMMAND trieste_intrusive_ptr_test WORKING_DIRECTORY $)