From 0110603c88a28a712fc860c9a255153abff2365d Mon Sep 17 00:00:00 2001 From: Artem Zhidkov Date: Thu, 16 Jul 2020 22:24:10 +0300 Subject: [PATCH] Avoid message about unknown 'salome_iapp' within unit tests. --- CMakeCommon/UnitTest.cmake | 8 ++++---- src/InitializationPlugin/InitializationPlugin_Plugin.cpp | 6 +++++- src/InitializationPlugin/InitializationPlugin_Plugin.h | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CMakeCommon/UnitTest.cmake b/CMakeCommon/UnitTest.cmake index c683f26fb..730f12136 100644 --- a/CMakeCommon/UnitTest.cmake +++ b/CMakeCommon/UnitTest.cmake @@ -70,11 +70,11 @@ MACRO(ADD_UNIT_TESTS) COMMAND ${PYTHON_EXECUTABLE} ${aTestFileName}) if (WIN32) # different path to libraries variable name SET_TESTS_PROPERTIES(${aTestName} PROPERTIES - ENVIRONMENT "PATH=${_JUSTPATH};PYTHONPATH=${_PYTHONPATH}" + ENVIRONMENT "PATH=${_JUSTPATH};PYTHONPATH=${_PYTHONPATH};SHAPER_UNIT_TEST_IN_PROGRESS=1" LABELS "${aSubprojectName}") else() SET_TESTS_PROPERTIES(${aTestName} PROPERTIES - ENVIRONMENT "LD_LIBRARY_PATH=${_LD_LIBRARY_PATH};PYTHONPATH=${_PYTHONPATH}" + ENVIRONMENT "LD_LIBRARY_PATH=${_LD_LIBRARY_PATH};PYTHONPATH=${_PYTHONPATH};SHAPER_UNIT_TEST_IN_PROGRESS=1" LABELS "${aSubprojectName}") endif() # Debug output... @@ -113,11 +113,11 @@ MACRO(ADD_UNIT_TESTS_API) COMMAND ${PYTHON_EXECUTABLE} ${aTestFileName}) if (WIN32) # different path to libraries variable name SET_TESTS_PROPERTIES(${aTestName} PROPERTIES - ENVIRONMENT "PATH=${_JUSTPATH};PYTHONPATH=${_PYTHONPATH}" + ENVIRONMENT "PATH=${_JUSTPATH};PYTHONPATH=${_PYTHONPATH};SHAPER_UNIT_TEST_IN_PROGRESS=1" LABELS "${aSubprojectName}") else() SET_TESTS_PROPERTIES(${aTestName} PROPERTIES - ENVIRONMENT "LD_LIBRARY_PATH=${_LD_LIBRARY_PATH};PYTHONPATH=${_PYTHONPATH}" + ENVIRONMENT "LD_LIBRARY_PATH=${_LD_LIBRARY_PATH};PYTHONPATH=${_PYTHONPATH};SHAPER_UNIT_TEST_IN_PROGRESS=1" LABELS "${aSubprojectName}") endif() # Debug output... diff --git a/src/InitializationPlugin/InitializationPlugin_Plugin.cpp b/src/InitializationPlugin/InitializationPlugin_Plugin.cpp index 6ff636bc7..45cca36dd 100644 --- a/src/InitializationPlugin/InitializationPlugin_Plugin.cpp +++ b/src/InitializationPlugin/InitializationPlugin_Plugin.cpp @@ -42,6 +42,9 @@ static InitializationPlugin_Plugin* MY_INITIALIZATIONPLUGIN_INSTANCE = InitializationPlugin_Plugin::InitializationPlugin_Plugin() { + char* isUnitTest = getenv("SHAPER_UNIT_TEST_IN_PROGRESS"); + myInitDataModel = (!isUnitTest || isUnitTest[0] != '1'); + Events_Loop* aLoop = Events_Loop::loop(); const Events_ID kDocCreatedEvent = ModelAPI_DocumentCreatedMessage::eventId(); aLoop->registerListener(this, kDocCreatedEvent, NULL, true); @@ -63,7 +66,8 @@ void InitializationPlugin_Plugin::processEvent(const std::shared_ptrmoduleDocument()) return; - myEvalListener->initDataModel(); + if (myInitDataModel) + myEvalListener->initDataModel(); std::list aFeatures; diff --git a/src/InitializationPlugin/InitializationPlugin_Plugin.h b/src/InitializationPlugin/InitializationPlugin_Plugin.h index 7c05c29da..7aa2c9885 100644 --- a/src/InitializationPlugin/InitializationPlugin_Plugin.h +++ b/src/InitializationPlugin/InitializationPlugin_Plugin.h @@ -72,6 +72,7 @@ class InitializationPlugin_Plugin : public Events_Listener private: std::shared_ptr myEvalListener; + bool myInitDataModel; }; #endif -- 2.39.2