From 7763128c9e85b5d5890a2ad129c97f74aeb7a53d Mon Sep 17 00:00:00 2001 From: Nuri Jung Date: Tue, 3 Dec 2024 09:36:08 +0900 Subject: [PATCH 1/4] build: allow run testing at post-install step --- CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 812a1d38..a8958432 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,9 @@ option(NURI_TEST_COVERAGE "Enable coverage build" OFF) option(NURI_BUILD_DOCS "Build documentation" OFF) option(NURI_BUILD_PYTHON_DOCS "Build python documentation" OFF) +option(NURI_POSTINSTALL_TEST "Run tests after installation" OFF) +mark_as_advanced(NURI_POSTINSTALL_TEST) + if(CMAKE_SYSTEM_NAME MATCHES Linux) set(NURI_RPATH_PREFIX "$ORIGIN") elseif(CMAKE_SYSTEM_NAME MATCHES Darwin) @@ -142,3 +145,14 @@ endif() include(CTest) add_subdirectory(test EXCLUDE_FROM_ALL) + +if(BUILD_TESTING AND NURI_POSTINSTALL_TEST) + message(NOTICE "Running tests after post-installation step") + install(CODE + "execute_process( + COMMAND \"\${CMAKE_CTEST_COMMAND}\" -T test -j --output-on-failure + WORKING_DIRECTORY + \"$\" + )" + ) +endif() From 31ea7864b823d00b3ab24ce7c1d0f21d729188c0 Mon Sep 17 00:00:00 2001 From: Nuri Jung Date: Tue, 3 Dec 2024 09:44:32 +0900 Subject: [PATCH 2/4] ci(gha): enable test on macos --- .github/workflows/_wheel-build.yaml | 8 ++++++++ .github/workflows/pr-wheels.yaml | 2 ++ .github/workflows/wheels-matrix.yaml | 1 + 3 files changed, 11 insertions(+) diff --git a/.github/workflows/_wheel-build.yaml b/.github/workflows/_wheel-build.yaml index 86c1d767..a36e592b 100644 --- a/.github/workflows/_wheel-build.yaml +++ b/.github/workflows/_wheel-build.yaml @@ -12,6 +12,11 @@ on: type: string description: "Python version" required: true + cpp_test: + type: boolean + description: "Run C++ tests" + required: false + default: false defaults: run: @@ -48,6 +53,9 @@ jobs: run: | cmake -DCMAKE_BUILD_TYPE=Release -S . -B build -G Ninja + - if: ${{ inputs.cpp_test }} + run: echo "SKBUILD_CMAKE_DEFINE=NURI_POSTINSTALL_TEST=ON" >>$GITHUB_ENV + - if: ${{ contains(inputs.python, 'linux') }} uses: pypa/cibuildwheel@v2.22.0 env: diff --git a/.github/workflows/pr-wheels.yaml b/.github/workflows/pr-wheels.yaml index 621353fc..7eea95e8 100644 --- a/.github/workflows/pr-wheels.yaml +++ b/.github/workflows/pr-wheels.yaml @@ -38,6 +38,7 @@ jobs: uses: ./.github/workflows/_wheel-build.yaml with: python: cp38-macosx_x86_64 + cpp_test: true test-build-mac-arm: needs: [check-want-test] @@ -45,6 +46,7 @@ jobs: uses: ./.github/workflows/_wheel-build.yaml with: python: cp38-macosx_arm64 + cpp_test: true concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/wheels-matrix.yaml b/.github/workflows/wheels-matrix.yaml index b7039af0..c2af6ed3 100644 --- a/.github/workflows/wheels-matrix.yaml +++ b/.github/workflows/wheels-matrix.yaml @@ -41,6 +41,7 @@ jobs: uses: ./.github/workflows/_wheel-build.yaml with: python: ${{ matrix.pyver }}-${{ matrix.os }} + cpp_test: ${{ matrix.pyver == 'cp38' }} concurrency: group: ${{ github.workflow }}-${{ github.ref }} From d19b70b6862045d2e9a949a32f7588128fa5ea55 Mon Sep 17 00:00:00 2001 From: Nuri Jung Date: Tue, 3 Dec 2024 09:56:07 +0900 Subject: [PATCH 3/4] build: specify processor count explicitly --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a8958432..293b2690 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,9 +148,12 @@ add_subdirectory(test EXCLUDE_FROM_ALL) if(BUILD_TESTING AND NURI_POSTINSTALL_TEST) message(NOTICE "Running tests after post-installation step") + include(ProcessorCount) + + ProcessorCount(NPROC) install(CODE "execute_process( - COMMAND \"\${CMAKE_CTEST_COMMAND}\" -T test -j --output-on-failure + COMMAND \"\${CMAKE_CTEST_COMMAND}\" -T test -j ${NPROC} --output-on-failure WORKING_DIRECTORY \"$\" )" From 787ed302140e52636e59e0c3b703de0322b81fca Mon Sep 17 00:00:00 2001 From: Nuri Jung Date: Tue, 3 Dec 2024 10:07:45 +0900 Subject: [PATCH 4/4] build: fix on older cmake versions PATH introduced on 3.24. --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 293b2690..4eaedfc7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -154,8 +154,7 @@ if(BUILD_TESTING AND NURI_POSTINSTALL_TEST) install(CODE "execute_process( COMMAND \"\${CMAKE_CTEST_COMMAND}\" -T test -j ${NPROC} --output-on-failure - WORKING_DIRECTORY - \"$\" + WORKING_DIRECTORY \"$<1:${CMAKE_CURRENT_BINARY_DIR}>\" )" ) endif()