From e541f819628b86d62218a6c47a4ca400094aed29 Mon Sep 17 00:00:00 2001 From: Edgar Date: Sun, 30 Aug 2026 13:36:05 +0200 Subject: [PATCH] :bug: Fixed failing tests --- .github/workflows/build-game.yml | 5 +- conanfile.py | 1 + src/engine/WindowManager.cxx | 6 -- tests/CMakeLists.txt | 1 - tests/Example.cxx | 96 -------------------------------- 5 files changed, 2 insertions(+), 107 deletions(-) delete mode 100644 tests/Example.cxx diff --git a/.github/workflows/build-game.yml b/.github/workflows/build-game.yml index 8127581bd4..b79ed24041 100644 --- a/.github/workflows/build-game.yml +++ b/.github/workflows/build-game.yml @@ -127,12 +127,9 @@ jobs: ninja - name: Test - env: - SDL_VIDEODRIVER: dummy - SDL_AUDIODRIVER: dummy run: | cd build - ctest -j2 --output-on-failure + xvfb-run -a ctest -j2 --output-on-failure - name: Upload build to itch.io env: diff --git a/conanfile.py b/conanfile.py index 71786c380d..f97f73f8ef 100644 --- a/conanfile.py +++ b/conanfile.py @@ -17,6 +17,7 @@ def requirements(self): self.requires("sdl_image/2.8.12") self.requires("sdl_ttf/2.24.0") self.requires("vorbis/1.3.7") + self.requires("zlib/1.3.1", force=True) def generate(self): tc = CMakeToolchain(self) diff --git a/src/engine/WindowManager.cxx b/src/engine/WindowManager.cxx index a037b9f384..8ca836a7b9 100644 --- a/src/engine/WindowManager.cxx +++ b/src/engine/WindowManager.cxx @@ -37,13 +37,7 @@ WindowManager::WindowManager() throw UIError(TRACE_INFO "Failed to create window: " + string{SDL_GetError()}); rendererFlags = SDL_RENDERER_ACCELERATED | (Settings::instance().vSync ? SDL_RENDERER_PRESENTVSYNC : 0); - -#if defined(TESTING_ENABLED) && defined(__linux) - // Set the index to 2 for running tests - m_renderer = SDL_CreateRenderer(m_window, 2, rendererFlags); -#else m_renderer = SDL_CreateRenderer(m_window, -1, rendererFlags); -#endif SDL_RendererInfo info; SDL_GetRendererInfo(m_renderer, &info); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d980c90cef..6ddf0c1ad5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -26,7 +26,6 @@ endforeach () LIST(APPEND TEST_SOURCES main.cxx - Example.cxx engine/basics/Point.cxx engine/basics/Settings.cxx engine/ResourcesManager.cxx diff --git a/tests/Example.cxx b/tests/Example.cxx deleted file mode 100644 index 082ce96fbe..0000000000 --- a/tests/Example.cxx +++ /dev/null @@ -1,96 +0,0 @@ -#include -#include - -using Catch::Contains; - -/* You can ignore these */ -template struct StaticEquals : std::false_type -{ -}; -template struct StaticEquals : std::true_type -{ -}; - -/* This is a test! */ -TEST_CASE("Example Test", "[!hide]") -{ - - SECTION("true/false") - { - // clang-format off - REQUIRE(1 != 0); - REQUIRE_FALSE(not true); - // clang-format on - } - - SECTION("floating points") - { - REQUIRE(1.1f == Approx(1.1)); - { - using namespace Catch::literals; - REQUIRE(1.1f == 1.1_a); - } - } - - SECTION("exceptions") - { - REQUIRE_NOTHROW(0); - REQUIRE_THROWS(throw 1); - REQUIRE_THROWS_AS(throw "hello", const char *); - REQUIRE_THROWS_MATCHES(throw "hello exception", const char *, Contains("hello")); - } - - SECTION("Matchers") { REQUIRE_THAT("hello tests", Contains("hello")); } - - /* Be careful with commas! - This code would not work because macros don't like commas in types - REQUIRE(StaticEquals<1,1>::value); - */ - using OneEqualsOne = StaticEquals<1, 1>; - /* Now this works! */ - REQUIRE(OneEqualsOne::value); -} - -/* You can also do it BDD-style! */ - -#include - -SCENARIO("C++ is cool", "[!hide]") -{ - GIVEN("a smart pointer") - { - std::unique_ptr myInt = std::make_unique(5); - WHEN("I try to set it") - { - *myInt = 2; - THEN("Its value changes") { REQUIRE(*myInt == 2); } - } - WHEN("I try to swap it with another pointer") - { - std::unique_ptr otherInt; - std::swap(otherInt, myInt); - THEN("They swap values") - { - REQUIRE(myInt == nullptr); - REQUIRE(*otherInt == 5); - } - } - WHEN("I release it") - { - int *intData = myInt.release(); - THEN("It becomes nullptr") - { - REQUIRE(myInt == nullptr); - REQUIRE(*intData == 5); - delete intData; - } - } - } -} - -/* Note that all inner scopes in a scope must be uniquely schedulable. - * That could mean memory leaks if you allocate pointers in a outer scope - * and don't deallocate in case, which is why we provide an example with smart pointers - */ - -/* To learn more about Catch2, see https://github.com/catchorg/Catch2 */