From aa9dd9c155c2f5aa3d4597f748ff509feff4215a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anna=20=E2=80=9CCyberTailor=E2=80=9D?= Date: Mon, 21 Feb 2022 12:22:29 +0500 Subject: [PATCH] CMakeLists.txt: make tests optional Run test-strbuf using ctest. --- .github/workflows/fastfetch-check.yml | 4 ++-- CMakeLists.txt | 30 ++++++++++++++++----------- tests/strbuf.sh | 6 ------ 3 files changed, 20 insertions(+), 20 deletions(-) delete mode 100755 tests/strbuf.sh diff --git a/.github/workflows/fastfetch-check.yml b/.github/workflows/fastfetch-check.yml index f8cc5f11b..305e7ce15 100644 --- a/.github/workflows/fastfetch-check.yml +++ b/.github/workflows/fastfetch-check.yml @@ -45,8 +45,8 @@ jobs: - name: Run flashfetch run: ./flashfetch - - name: Run fastfetch-test-strbuf - run: ./fastfetch-test-strbuf + - name: Run tests + run: ctest - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v1 diff --git a/CMakeLists.txt b/CMakeLists.txt index 843ebdd7a..e645ab98f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,7 @@ OPTION(ENABLE_DCONF "Enable dconf" ON) OPTION(ENABLE_DBUS "Enable dbus-1" ON) OPTION(ENABLE_XFCONF "Enable libxfconf-0" ON) OPTION(ENABLE_RPM "Enable rpm" ON) +OPTION(BUILD_TESTS "Build tests" ON) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) @@ -277,19 +278,24 @@ target_link_libraries(flashfetch # Testing. -add_executable(fastfetch-test-performance - tests/performance.c -) -target_link_libraries(fastfetch-test-performance - PRIVATE libfastfetch -) +if (BUILD_TESTS) + add_executable(fastfetch-test-performance + tests/performance.c + ) + target_link_libraries(fastfetch-test-performance + PRIVATE libfastfetch + ) -add_executable(fastfetch-test-strbuf - tests/strbuf.c -) -target_link_libraries(fastfetch-test-strbuf - PRIVATE libfastfetch -) + add_executable(fastfetch-test-strbuf + tests/strbuf.c + ) + target_link_libraries(fastfetch-test-strbuf + PRIVATE libfastfetch + ) + + enable_testing() + add_test(NAME test-strbuf COMMAND fastfetch-test-strbuf) +endif() # Installation. diff --git a/tests/strbuf.sh b/tests/strbuf.sh deleted file mode 100755 index 93ae379ff..000000000 --- a/tests/strbuf.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/env sh -mkdir -p build/ -cd build -cmake .. -cmake --build . --target fastfetch-test-strbuf -j$(nproc) -./fastfetch-test-strbuf "$@"