]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Avoid message about unknown 'salome_iapp' within unit tests.
authorArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Thu, 16 Jul 2020 19:24:10 +0000 (22:24 +0300)
committerArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Thu, 16 Jul 2020 19:24:10 +0000 (22:24 +0300)
CMakeCommon/UnitTest.cmake
src/InitializationPlugin/InitializationPlugin_Plugin.cpp
src/InitializationPlugin/InitializationPlugin_Plugin.h

index c683f26fbab177d65afa226ba0f1999bcd4cbf95..730f12136d2b66a889079458772d84114e3110ee 100644 (file)
@@ -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...
index 6ff636bc72726342f578d5aaa7b9265465711581..45cca36ddc07fa1aa780c6c47bb23a8a86e73c83 100644 (file)
@@ -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_ptr<Events_Mess
     if (aDoc != ModelAPI_Session::get()->moduleDocument())
       return;
 
-    myEvalListener->initDataModel();
+    if (myInitDataModel)
+      myEvalListener->initDataModel();
 
     std::list<FeaturePtr> aFeatures;
 
index 7c05c29daee5f205312dc0c637ae05025e42e854..7aa2c9885062c3b9b996817443bb1390e8c44b86 100644 (file)
@@ -72,6 +72,7 @@ class InitializationPlugin_Plugin : public Events_Listener
 
  private:
   std::shared_ptr<InitializationPlugin_EvalListener> myEvalListener;
+  bool myInitDataModel;
 };
 
 #endif