Salome HOME
Issue #19241: install test_hdf.py
[modules/shaper.git] / test.hdfs / CMakeLists.txt
1 # Copyright (C) 2014-2020  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 # get all restricted HDF tests
23 SET(hdfFilesRestr "")
24 IF (EXISTS $ENV{RESTRICTED_ROOT_DIR})
25   FILE(GLOB hdfFilesRestr "$ENV{RESTRICTED_ROOT_DIR}/SHAPER/test.hdfs/*.hdf")
26 ENDIF()
27
28 # get all HDF tests from the current drectory
29 file(GLOB hdfFilesCur "${CMAKE_CURRENT_SOURCE_DIR}/*.hdf")
30
31 # collect test names
32 set(TEST_NAMES "")
33 foreach(eachFilePath IN LISTS hdfFilesCur hdfFilesRestr)
34   # Strip the ".hdf" suffix
35   get_filename_component(aTestName ${eachFilePath} NAME_WE)
36   # Check corresponding ".py" file with reference data exists
37   if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${aTestName}.py")
38     set(TEST_NAMES ${TEST_NAMES} ${aTestName})
39   else()
40     message(WARNING "File ${aTestName}.py containing reference data for ${aTestName}.hdf does not exist")
41   endif()
42 endforeach()
43
44 SET(COMPONENT_NAME SHAPER)
45 SET(TIMEOUT 600)
46
47 SET(TEST_INSTALL_DIRECTORY "${SALOME_SHAPER_INSTALL_TESTS}/HDFs")
48
49 SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
50
51 SET(PUBLIC_TESTS "")
52 SET(RESTRICTED_TESTS "")
53 FOREACH(tfile ${TEST_NAMES})
54   SET(TEST_NAME ${COMPONENT_NAME}_HDF_${tfile})
55
56   IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.hdf")
57     SET(HDF_TEST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.hdf")
58     SET(PUBLIC_TESTS ${PUBLIC_TESTS} ${tfile})
59   ELSEIF(EXISTS "$ENV{RESTRICTED_ROOT_DIR}/SHAPER/test.hdfs/${tfile}.hdf")
60     SET(HDF_TEST_FILE "$ENV{RESTRICTED_ROOT_DIR}/SHAPER/test.hdfs/${tfile}.hdf")
61     SET(RESTRICTED_TESTS ${RESTRICTED_TESTS} ${tfile})
62   ENDIF()
63
64   ADD_TEST(NAME ${TEST_NAME}
65            COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/testme.py" "${HDF_TEST_FILE}" "${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.py")
66   SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES ENVIRONMENT "${tests_env};SHAPER_UNIT_TEST_IN_PROGRESS=1")
67   SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME};models_hdf")
68   SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES TIMEOUT ${TIMEOUT})
69 ENDFOREACH()
70
71 ADD_CUSTOM_TARGET(run_hdf_tests COMMAND ${CMAKE_CTEST_COMMAND} -C "${CMAKE_BUILD_TYPE}" -L "models_hdf")
72
73 # salome test
74 FOREACH(tfile ${TEST_NAMES})
75   INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.py
76           DESTINATION ${TEST_INSTALL_DIRECTORY})
77   IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.hdf")
78     INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.hdf
79             DESTINATION ${TEST_INSTALL_DIRECTORY})
80   ENDIF()
81 ENDFOREACH()
82
83 INSTALL(FILES CTestTestfileInstall.cmake
84   DESTINATION ${TEST_INSTALL_DIRECTORY}
85   RENAME CTestTestfile.cmake)
86
87 INSTALL(FILES testme.py DESTINATION ${TEST_INSTALL_DIRECTORY}
88                         PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
89                                     GROUP_READ GROUP_EXECUTE
90                                     WORLD_READ WORLD_EXECUTE)
91 FILE(COPY test_hdf.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
92 INSTALL(FILES test_hdf.py DESTINATION ${TEST_INSTALL_DIRECTORY}
93                           PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
94                                       GROUP_READ GROUP_EXECUTE
95                                       WORLD_READ WORLD_EXECUTE)
96 CONFIGURE_FILE(tests.set.in ${CMAKE_CURRENT_BINARY_DIR}/tests.set @ONLY)
97 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tests.set DESTINATION ${TEST_INSTALL_DIRECTORY})