From 84f56d0936d1b9043c0640be2e69cb0c3e1b145e Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Mon, 26 Dec 2022 22:30:18 -0600 Subject: [PATCH] Add option for skipping tests that require an attached display --- .github/workflows/ci.yml | 4 ++-- test/CMakeLists.txt | 11 +++++++++++ test/Graphics/Texture.test.cpp | 2 +- test/TestUtilities/GraphicsUtil.hpp | 6 ++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2bd9e8aa..879d608a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,9 +48,9 @@ jobs: - platform: { name: Android, os: ubuntu-latest } config: { name: x86_64, flags: -DCMAKE_ANDROID_ARCH_ABI=x86_64 -DCMAKE_SYSTEM_NAME=Android -DSFML_BUILD_TEST_SUITE=FALSE -DCMAKE_TOOLCHAIN_FILE=$GITHUB_WORKSPACE/android-ndk-r23b/build/cmake/android.toolchain.cmake -DCMAKE_ANDROID_NDK=$GITHUB_WORKSPACE/android-ndk-r23b -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang -DCMAKE_ANDROID_STL_TYPE=c++_shared -DCMAKE_ANDROID_API=26 -DANDROID_PLATFORM=26 } - platform: { name: Linux GCC, os: ubuntu-latest } - config: { name: Static DRM, flags: -DBUILD_SHARED_LIBS=FALSE -DSFML_USE_DRM=TRUE } + config: { name: Static DRM, flags: -DBUILD_SHARED_LIBS=FALSE -DSFML_USE_DRM=TRUE -DSFML_RUN_DISPLAY_TESTS=FALSE } - platform: { name: Linux GCC, os: ubuntu-latest } - config: { name: Shared DRM, flags: -DBUILD_SHARED_LIBS=TRUE -DSFML_USE_DRM=TRUE } + config: { name: Shared DRM, flags: -DBUILD_SHARED_LIBS=TRUE -DSFML_USE_DRM=TRUE -DSFML_RUN_DISPLAY_TESTS=FALSE } steps: - name: Checkout Code uses: actions/checkout@v3 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e0148fcf..286f7110 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -49,6 +49,14 @@ target_compile_definitions(test-sfml-system PRIVATE EXPECTED_SFML_VERSION_IS_RELEASE=$,true,false> ) +# FIXME Remove this once the Buildbot supports handling display tests on Linux platforms +if(SFML_OS_WINDOWS OR SFML_OS_MACOSX) + set(SFML_RUN_DISPLAY_TESTS_DEFAULT ON) +else() + set(SFML_RUN_DISPLAY_TESTS_DEFAULT OFF) +endif() +sfml_set_option(SFML_RUN_DISPLAY_TESTS ${SFML_RUN_DISPLAY_TESTS_DEFAULT} BOOL "TRUE to run tests that require a display, FALSE to ignore it") + set(WINDOW_SRC Window/Context.test.cpp Window/ContextSettings.test.cpp @@ -88,6 +96,9 @@ set(GRAPHICS_SRC Graphics/View.test.cpp ) sfml_add_test(test-sfml-graphics "${GRAPHICS_SRC}" SFML::Graphics) +if(SFML_RUN_DISPLAY_TESTS) + target_compile_definitions(test-sfml-graphics PRIVATE SFML_RUN_DISPLAY_TESTS) +endif() set(NETWORK_SRC Network/Ftp.test.cpp diff --git a/test/Graphics/Texture.test.cpp b/test/Graphics/Texture.test.cpp index a4b1da83..20ac4aef 100644 --- a/test/Graphics/Texture.test.cpp +++ b/test/Graphics/Texture.test.cpp @@ -12,7 +12,7 @@ static_assert(!std::is_nothrow_move_constructible_v); static_assert(std::is_move_assignable_v); static_assert(!std::is_nothrow_move_assignable_v); -TEST_CASE("[Graphics] sf::Texture") +TEST_CASE("[Graphics] sf::Texture" * doctest::skip(skipDisplayTests)) { SUBCASE("Construction") { diff --git a/test/TestUtilities/GraphicsUtil.hpp b/test/TestUtilities/GraphicsUtil.hpp index 4b134356..18da9742 100644 --- a/test/TestUtilities/GraphicsUtil.hpp +++ b/test/TestUtilities/GraphicsUtil.hpp @@ -11,6 +11,12 @@ #include #include +#ifdef SFML_RUN_DISPLAY_TESTS +static constexpr bool skipDisplayTests = false; +#else +static constexpr bool skipDisplayTests = true; +#endif + namespace sf { struct BlendMode;