Salome HOME
Issue #2971: Naming issue in a group when loading a dump file
[modules/shaper.git] / test.hdfs / 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 SET(RESTRICTED_ROOT_DIR $ENV{RESTRICTED_ROOT_DIR} CACHE PATH "Path to the restricted repository")
23
24 if (EXISTS ${RESTRICTED_ROOT_DIR})
25   file(GLOB hdfFilesRestr "${RESTRICTED_ROOT_DIR}/SHAPER/test.hdfs/*.hdf")
26
27   if (WIN32) # different separators and path to libraries variable name
28     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}")
29     STRING(REPLACE "\\" "/" _JUSTPATH "${_JUSTPATH}")
30     STRING(REPLACE ";" "\\;" _JUSTPATH "${_JUSTPATH}")
31     SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS};$ENV{PYTHONPATH}")
32     STRING(REPLACE "\\" "/" _PYTHONPATH "${_PYTHONPATH}")
33     STRING(REPLACE ";" "\\;" _PYTHONPATH "${_PYTHONPATH}")
34   else()
35     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}")
36     SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS}:$ENV{PYTHONPATH}")
37   endif()
38
39   foreach(eachFilePath ${hdfFilesRestr})
40     # Strip the ".hdf" suffix
41     GET_FILENAME_COMPONENT(aTestName ${eachFilePath} NAME_WE)
42     # Check corresponding ".py" file with reference data exists
43     IF(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${aTestName}.py")
44       MESSAGE(WARNING "File ${aTestName}.py containing reference data does not exist")
45       continue()
46     ENDIF()
47
48     # Add "SubprojectName_" prefix
49     GET_FILENAME_COMPONENT(aSubprojectName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
50     SET(aTestName "${aSubprojectName}_${aTestName}")
51
52     # Full path to the python test file being executed
53     SET(aTestFilePath "${eachFilePath}")
54     IF(EXISTS ${aTestFilePath})
55       ADD_TEST(NAME ${aTestName} COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/test.py" "$ENV{KERNEL_ROOT_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" "${aTestFilePath}")
56       if (WIN32) # different path to libraries variable name
57         SET_TESTS_PROPERTIES(${aTestName} PROPERTIES ENVIRONMENT "PATH=${_JUSTPATH};PYTHONPATH=${_PYTHONPATH}"
58           LABELS "models_hdf")
59       else()
60         SET_TESTS_PROPERTIES(${aTestName} PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${_LD_LIBRARY_PATH};PYTHONPATH=${_PYTHONPATH}"
61           LABELS "models_hdf")
62       endif()
63       # Debug output...
64       # MESSAGE(STATUS "Test added: ${aTestName} file: ${aTestFilePath}")
65     ELSE(EXISTS ${aTestFilePath})
66       MESSAGE(WARNING "Can not find the test file: ${aTestFilePath}")
67     ENDIF(EXISTS ${aTestFilePath})
68   endforeach(eachFilePath ${ARGN})
69
70   ADD_CUSTOM_TARGET(run_hdf_tests COMMAND ${CMAKE_CTEST_COMMAND} -C "${CMAKE_BUILD_TYPE}" -L "models_hdf")
71 endif()