From a5d9bb08e041ee40e1a84b0b79b426606d011b2f Mon Sep 17 00:00:00 2001 From: elsid Date: Sat, 15 Jun 2024 13:53:13 +0200 Subject: [PATCH] Support custom log level in tests --- apps/components_tests/lua/test_scriptscontainer.cpp | 4 ++++ apps/components_tests/main.cpp | 11 +++++++---- apps/opencs_tests/main.cpp | 4 ++++ apps/openmw_tests/main.cpp | 4 ++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/apps/components_tests/lua/test_scriptscontainer.cpp b/apps/components_tests/lua/test_scriptscontainer.cpp index 6e562e7541..c048e29f5e 100644 --- a/apps/components_tests/lua/test_scriptscontainer.cpp +++ b/apps/components_tests/lua/test_scriptscontainer.cpp @@ -458,10 +458,14 @@ CUSTOM, PLAYER: useInterface.lua callback.call(1.5, 2.5); EXPECT_EQ(internal::GetCapturedStdout(), "1.5\t2.5\n"); + const Debug::Level level = std::exchange(Log::sMinDebugLevel, Debug::All); + testing::internal::CaptureStdout(); callback.mHiddenData[LuaUtil::ScriptsContainer::sScriptIdKey] = sol::nil; callback.call(1.5, 2.5); EXPECT_EQ(internal::GetCapturedStdout(), "Ignored callback to the removed script some_script.lua\n"); + + Log::sMinDebugLevel = level; } } diff --git a/apps/components_tests/main.cpp b/apps/components_tests/main.cpp index e3c01d6982..dcfb2e9ba9 100644 --- a/apps/components_tests/main.cpp +++ b/apps/components_tests/main.cpp @@ -1,13 +1,16 @@ -#include +#include +#include +#include +#include -#include "components/misc/strings/conversion.hpp" -#include "components/settings/parser.hpp" -#include "components/settings/values.hpp" +#include #include int main(int argc, char** argv) { + Log::sMinDebugLevel = Debug::getDebugLevel(); + const std::filesystem::path settingsDefaultPath = std::filesystem::path{ OPENMW_PROJECT_SOURCE_DIR } / "files" / Misc::StringUtils::stringToU8String("settings-default.cfg"); diff --git a/apps/opencs_tests/main.cpp b/apps/opencs_tests/main.cpp index e1a8e67397..fd7d4900c8 100644 --- a/apps/opencs_tests/main.cpp +++ b/apps/opencs_tests/main.cpp @@ -1,7 +1,11 @@ +#include + #include int main(int argc, char* argv[]) { + Log::sMinDebugLevel = Debug::getDebugLevel(); + testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/apps/openmw_tests/main.cpp b/apps/openmw_tests/main.cpp index e1a8e67397..fd7d4900c8 100644 --- a/apps/openmw_tests/main.cpp +++ b/apps/openmw_tests/main.cpp @@ -1,7 +1,11 @@ +#include + #include int main(int argc, char* argv[]) { + Log::sMinDebugLevel = Debug::getDebugLevel(); + testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }