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 "$@"