From 0000c6232f9f29085017b44a3484bbd7eb492a01 Mon Sep 17 00:00:00 2001 From: faumaray Date: Sun, 2 Aug 2026 02:36:52 +0300 Subject: [PATCH] Read module test versions from component lock --- CMakeLists.txt | 17 ++++++++++++++++- tests/ModuleDescriptors.cpp | 19 +++++++++++-------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8db857e..67de36c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -538,6 +538,16 @@ if(BUILD_TESTS AND UNIX) TARGET EchoionHost AND TARGET EchoionCore AND TARGET EchoionWeb AND TARGET EchoionUrlShortenerInternalPlugin AND TARGET EchoionUrlShortenerExternalPlugin) + foreach(_echoionTestComponent IN ITEMS + EchoionHost EchoionCore EchoionWeb + EchoionPluginUrlShortenerInternal + EchoionPluginUrlShortenerExternal) + string(JSON _echoionTestComponentVersion GET + "${_echoionComponentLockJson}" + components "${_echoionTestComponent}" componentVersion) + set("_echoionTestVersion${_echoionTestComponent}" + "${_echoionTestComponentVersion}") + endforeach() add_executable(EchoionModuleTests tests/ModuleDescriptors.cpp) target_compile_features(EchoionModuleTests PRIVATE cxx_std_26) target_link_libraries(EchoionModuleTests PRIVATE @@ -549,7 +559,12 @@ if(BUILD_TESTS AND UNIX) "ECHOION_TEST_CORE=\"$\"" "ECHOION_TEST_WEB=\"$\"" "ECHOION_TEST_PLUGIN_INTERNAL=\"$\"" - "ECHOION_TEST_PLUGIN_EXTERNAL=\"$\"") + "ECHOION_TEST_PLUGIN_EXTERNAL=\"$\"" + "ECHOION_TEST_HOST_VERSION=\"${_echoionTestVersionEchoionHost}\"" + "ECHOION_TEST_CORE_VERSION=\"${_echoionTestVersionEchoionCore}\"" + "ECHOION_TEST_WEB_VERSION=\"${_echoionTestVersionEchoionWeb}\"" + "ECHOION_TEST_PLUGIN_INTERNAL_VERSION=\"${_echoionTestVersionEchoionPluginUrlShortenerInternal}\"" + "ECHOION_TEST_PLUGIN_EXTERNAL_VERSION=\"${_echoionTestVersionEchoionPluginUrlShortenerExternal}\"") void_add_tests(EchoionModuleTests) add_test(NAME echoion_module_descriptor_tests COMMAND EchoionModuleTests) diff --git a/tests/ModuleDescriptors.cpp b/tests/ModuleDescriptors.cpp index 718d70e..1f894d7 100644 --- a/tests/ModuleDescriptors.cpp +++ b/tests/ModuleDescriptors.cpp @@ -6,6 +6,7 @@ #include #include +#include #include namespace @@ -25,31 +26,31 @@ Void::Testing::Test component_module_descriptors_are_loadable() .path = ECHOION_TEST_HOST, .moduleId = "EchoionHost", .stableComponentId = "EchoionHost", - .version = "2.0.0", + .version = ECHOION_TEST_HOST_VERSION, }, ModuleExpectation{ .path = ECHOION_TEST_CORE, .moduleId = "EchoionCore", .stableComponentId = "EchoionCore", - .version = "2.0.0", + .version = ECHOION_TEST_CORE_VERSION, }, ModuleExpectation{ .path = ECHOION_TEST_WEB, .moduleId = "EchoionWeb", .stableComponentId = "EchoionWeb", - .version = "2.0.0", + .version = ECHOION_TEST_WEB_VERSION, }, ModuleExpectation{ .path = ECHOION_TEST_PLUGIN_INTERNAL, .moduleId = "url-shortener-internal", .stableComponentId = "EchoionPluginUrlShortenerInternal", - .version = "2.0.0", + .version = ECHOION_TEST_PLUGIN_INTERNAL_VERSION, }, ModuleExpectation{ .path = ECHOION_TEST_PLUGIN_EXTERNAL, .moduleId = "url-shortener-external", .stableComponentId = "EchoionPluginUrlShortenerExternal", - .version = "2.0.0", + .version = ECHOION_TEST_PLUGIN_EXTERNAL_VERSION, }, }; @@ -103,9 +104,11 @@ Void::Testing::Test component_module_descriptors_are_loadable() std::string_view{stable->component_id.data, stable->component_id.size}, expected.stableComponentId); - Void::Testing::expect_eq(stable->version_major, 2U); - Void::Testing::expect_eq(stable->version_minor, 0U); - Void::Testing::expect_eq(stable->version_patch, 0U); + const auto stableVersion = + std::to_string(stable->version_major) + "." + + std::to_string(stable->version_minor) + "." + + std::to_string(stable->version_patch); + Void::Testing::expect_eq(stableVersion, expected.version); Void::Testing::expect(stable->api != nullptr); if (stable->api != nullptr) { Void::Testing::expect_eq(stable->api->struct_size,