From 0d08d094faa0e828471d8a663a3a31155724cbfd Mon Sep 17 00:00:00 2001 From: Clarisse Genrault Date: Thu, 9 Mar 2017 08:41:31 +0100 Subject: [PATCH] Added unbit tests from CEA. --- CMakeCommon/UnitTest.cmake | 41 ++++++++++++++++++++++++++++++++++ CMakeLists.txt | 2 ++ test.API/SHAPER/CMakeLists.txt | 17 ++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 test.API/SHAPER/CMakeLists.txt diff --git a/CMakeCommon/UnitTest.cmake b/CMakeCommon/UnitTest.cmake index 626769505..eb63e6bf7 100644 --- a/CMakeCommon/UnitTest.cmake +++ b/CMakeCommon/UnitTest.cmake @@ -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) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef1b36869..01376442f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 index 000000000..260ded0b4 --- /dev/null +++ b/test.API/SHAPER/CMakeLists.txt @@ -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 +) -- 2.39.2