]> SALOME platform Git repositories - modules/shaper.git/blob - test.compatibility/CMakeLists.txt
Salome HOME
Fix the code coverage level
[modules/shaper.git] / test.compatibility / CMakeLists.txt
1 # Copyright (C) 2014-2019  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 ENABLE_TESTING()
21
22 file(GLOB pyFiles "*.py")
23
24 SET(RESTRICTED_ROOT_DIR $ENV{RESTRICTED_ROOT_DIR} CACHE PATH "Path to the restricted repository")
25
26 if (EXISTS ${RESTRICTED_ROOT_DIR})
27   file(GLOB pyFilesRestr "${RESTRICTED_ROOT_DIR}/SHAPER/test.compatibility/*.py")
28 endif()
29
30 if (WIN32) # different separators and path to libraries variable name
31   SET(_JUSTPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_BIN};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES};${SUIT_LIB_DIR};${SALOME_KERNEL_LIBDIR};$ENV{PATH}")
32   STRING(REPLACE "\\" "/" _JUSTPATH "${_JUSTPATH}")
33   STRING(REPLACE ";" "\\;" _JUSTPATH "${_JUSTPATH}")
34   SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS};$ENV{PYTHONPATH}")
35   STRING(REPLACE "\\" "/" _PYTHONPATH "${_PYTHONPATH}")
36   STRING(REPLACE ";" "\\;" _PYTHONPATH "${_PYTHONPATH}")
37 else()
38   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}:${SALOME_KERNEL_LIBDIR}:$ENV{LD_LIBRARY_PATH}")
39   SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS}:$ENV{PYTHONPATH}")
40 endif()
41
42 foreach(eachFilePath ${pyFiles};${pyFilesRestr})
43   # Strip the ".py" suffix
44   GET_FILENAME_COMPONENT(aTestName ${eachFilePath} NAME_WE)
45
46   # Add "SubprojectName_" prefix
47   GET_FILENAME_COMPONENT(aSubprojectName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
48   SET(aTestName "${aSubprojectName}_${aTestName}")
49
50   # Full path to the python test file beeing executed
51   SET(aTestFilePath "${eachFilePath}")
52   IF(EXISTS ${aTestFilePath})
53     ADD_TEST(NAME ${aTestName} COMMAND ${PYTHON_EXECUTABLE} ${aTestFilePath})
54     if (WIN32) # different path to libraries variable name
55       SET_TESTS_PROPERTIES(${aTestName} PROPERTIES ENVIRONMENT "PATH=${_JUSTPATH};PYTHONPATH=${_PYTHONPATH}"
56         LABELS "tests_compatibility")
57     else()
58       SET_TESTS_PROPERTIES(${aTestName} PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${_LD_LIBRARY_PATH};PYTHONPATH=${_PYTHONPATH}"
59         LABELS "tests_compatibility")
60     endif()
61     # Debug output...
62     # MESSAGE(STATUS "Test added: ${aTestName} file: ${aTestFilePath}")
63   ELSE(EXISTS ${aTestFilePath})
64     MESSAGE(WARNING "Can not find the test file: ${aTestFilePath}")
65   ENDIF(EXISTS ${aTestFilePath})
66 endforeach(eachFilePath ${ARGN})
67
68 ADD_CUSTOM_TARGET(run_tests_compatibility COMMAND ${CMAKE_CTEST_COMMAND} -C "${CMAKE_BUILD_TYPE}" -L "tests_compatibility")