diff options
author | saturneric <[email protected]> | 2023-12-13 10:01:06 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2023-12-13 10:01:06 +0000 |
commit | 42264ed0d7a3c91fbe9f307984964ffc9e5fe65c (patch) | |
tree | a3ddecbd6ad723e42d68cc2c5aed7a88c4e242a3 /src/test/GpgFrontendTest.cpp | |
parent | feat: move test to src and add submodule googletest (diff) | |
download | GpgFrontend-42264ed0d7a3c91fbe9f307984964ffc9e5fe65c.tar.gz GpgFrontend-42264ed0d7a3c91fbe9f307984964ffc9e5fe65c.zip |
refactor: improve the structure of main,core and test module
Diffstat (limited to 'src/test/GpgFrontendTest.cpp')
-rw-r--r-- | src/test/GpgFrontendTest.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/test/GpgFrontendTest.cpp b/src/test/GpgFrontendTest.cpp index 24e099a2..18157a00 100644 --- a/src/test/GpgFrontendTest.cpp +++ b/src/test/GpgFrontendTest.cpp @@ -28,14 +28,18 @@ #include "GpgFrontendTest.h" +#include <gtest/gtest.h> +#include <spdlog/sinks/rotating_file_sink.h> +#include <spdlog/sinks/stdout_color_sinks.h> + #include <boost/date_time.hpp> #include <boost/dll.hpp> #include <filesystem> +#include "core/GpgCoreInit.h" #include "core/function/GlobalSettingStation.h" #include "core/function/gpg/GpgContext.h" #include "spdlog/spdlog.h" -#include "type.h" namespace GpgFrontend::Test { @@ -66,6 +70,15 @@ void InitTestLoggingSystem(spdlog::level::level_enum level) { spdlog::set_default_logger(test_logger); } +void ShutdownTestLoggingSystem() { +#ifdef WINDOWS + // Under VisualStudio, this must be called before main finishes to workaround + // a known VS issue + spdlog::drop_all(); + spdlog::shutdown(); +#endif +} + auto GenerateRandomString(size_t length) -> std::string { const std::string characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; @@ -94,6 +107,8 @@ void ConfigureGpgContext() { std::filesystem::create_directory(db_path); } + SPDLOG_DEBUG("DEBUG--------<"); + GpgContext::CreateInstance( kGpgFrontendDefaultChannel, [&]() -> ChannelObjectPtr { GpgContextInitArgs args; @@ -104,11 +119,15 @@ void ConfigureGpgContext() { return ConvertToChannelObjectPtr<>(SecureCreateUniqueObject<GpgContext>( args, kGpgFrontendDefaultChannel)); }); + + SPDLOG_DEBUG("DEBUG-------->"); } -void ExecuteAllTestCase(InitArgs args) { - InitTestLoggingSystem(args.log_level); +auto ExecuteAllTestCase(GpgFrontendContext args) -> int { ConfigureGpgContext(); + + testing::InitGoogleTest(&args.argc, args.argv); + return RUN_ALL_TESTS(); } } // namespace GpgFrontend::Test
\ No newline at end of file |