]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Added unbit tests from CEA.
authorClarisse Genrault <clarisse.genrault@cea.fr>
Thu, 9 Mar 2017 07:41:31 +0000 (08:41 +0100)
committerClarisse Genrault <clarisse.genrault@cea.fr>
Thu, 9 Mar 2017 07:41:31 +0000 (08:41 +0100)
CMakeCommon/UnitTest.cmake
CMakeLists.txt
test.API/SHAPER/CMakeLists.txt [new file with mode: 0644]

index 626769505cb3d96b6f1617118a6d4dd3fb567b41..eb63e6bf712e3f07414dd2a55be1bbe01492466c 100644 (file)
@@ -65,3 +65,44 @@ MACRO(ADD_UNIT_TESTS)
     ENDIF(EXISTS ${aTestFileName})
   endforeach(eachFileName ${ARGN})
 ENDMACRO(ADD_UNIT_TESTS)
+
+MACRO(ADD_UNIT_TESTS_API)
+  if (WIN32) # different separators and path to libraries variable name
+    SET(_JUSTPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_BIN};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES};${SUIT_LIB_DIR};$ENV{PATH}")
+    STRING(REPLACE "\\" "/" _JUSTPATH "${_JUSTPATH}")
+    STRING(REPLACE ";" "\\;" _JUSTPATH "${_JUSTPATH}")
+    SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS};$ENV{PYTHONPATH}")
+    STRING(REPLACE "\\" "/" _PYTHONPATH "${_PYTHONPATH}")
+    STRING(REPLACE ";" "\\;" _PYTHONPATH "${_PYTHONPATH}")
+  else()
+    SET(_LD_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_BIN}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}:${SUIT_LIB_DIR}:$ENV{LD_LIBRARY_PATH}")
+    SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS}:$ENV{PYTHONPATH}")
+  endif()
+
+  foreach(eachFileName ${ARGN})
+    # Strip the ".py" suffix
+    GET_FILENAME_COMPONENT(aTestName ${eachFileName} NAME_WE)
+
+    # Add "SubprojectName_" prefix
+    GET_FILENAME_COMPONENT(aSubprojectName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+    SET(aTestName "${aSubprojectName}_${aTestName}")
+
+    # Full path to the python test file beeing executed
+    SET(aTestFileName "${CMAKE_CURRENT_SOURCE_DIR}/${eachFileName}")
+    IF(EXISTS ${aTestFileName})
+      ADD_TEST(NAME ${aTestName}
+               COMMAND ${PYTHON_EXECUTABLE} ${aTestFileName})
+      if (WIN32) # different path to libraries variable name
+        SET_TESTS_PROPERTIES(${aTestName} PROPERTIES
+               ENVIRONMENT "PATH=${_JUSTPATH};PYTHONPATH=${_PYTHONPATH}")
+      else()
+        SET_TESTS_PROPERTIES(${aTestName} PROPERTIES
+               ENVIRONMENT "LD_LIBRARY_PATH=${_LD_LIBRARY_PATH};PYTHONPATH=${_PYTHONPATH}")
+      endif()
+      # Debug output...
+      #MESSAGE(STATUS "Test added: ${aTestName} file: ${aTestFileName}")
+    ELSE(EXISTS ${aTestFileName})
+      MESSAGE(WARNING "Can not find the test file: ${aTestFileName}")
+    ENDIF(EXISTS ${aTestFileName})
+  endforeach(eachFileName ${ARGN})
+ENDMACRO(ADD_UNIT_TESTS_API)
index ef1b368691f7ba0bca336e8375af6c20df9735b5..01376442f89380ccedba5bed591af77dcb0ff778 100644 (file)
@@ -108,6 +108,8 @@ ADD_SUBDIRECTORY (src/PartSetAPI)
 ADD_SUBDIRECTORY (src/PrimitivesAPI)
 ADD_SUBDIRECTORY (src/SketchAPI)
 ADD_SUBDIRECTORY (src/GDMLAPI)
+# Tests
+ADD_SUBDIRECTORY (test.API/SHAPER)
 
 IF(${HAVE_SALOME})
     ADD_SUBDIRECTORY (src/SHAPERGUI)
diff --git a/test.API/SHAPER/CMakeLists.txt b/test.API/SHAPER/CMakeLists.txt
new file mode 100644 (file)
index 0000000..260ded0
--- /dev/null
@@ -0,0 +1,17 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+INCLUDE(UnitTest)
+
+ADD_UNIT_TESTS_API(
+  Primitives/TestBox.py
+  Primitives/TestCylinder.py
+  Primitives/TestAPI_Box.py
+  Primitives/TestAPI_Cylinder.py
+  GDML/TestConeSegment.py
+  GDML/TestAPI_ConeSegment.py
+  Transformations/TestScale.py
+  Transformations/TestSymmetry.py
+  Transformations/TestTranslation.py
+  Transformations/TestAPI_Scale.py
+  Transformations/TestAPI_Symmetry.py
+  Transformations/TestAPI_Translation.py
+)