Salome HOME
Copyright update 2022
[modules/paravis.git] / src / Plugins / MEDReader / plugin / Test / CMakeLists.txt
1 # Copyright (C) 2010-2022  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 if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
21   
22   ###########################
23   # Tests for standalone mode
24   ###########################
25
26   if (PARAVIEW_ENABLE_PYTHON)
27     file(GLOB pythonTests *.py)
28     list(FILTER pythonTests EXCLUDE REGEX ".*MEDReaderHelper.py$")
29     list(FILTER pythonTests EXCLUDE REGEX ".*medreadertestlauncher.py$")
30     foreach(testFullPath ${pythonTests})
31       get_filename_component(testFile ${testFullPath} NAME)
32       paraview_add_test_python(NO_RT DIRECT_DATA ${testFile})
33       get_filename_component(testName ${testFile} NAME_WE)
34       set_tests_properties(Python-${testName} PROPERTIES ENVIRONMENT "PARAVIEW_DATA_ROOT=${CMAKE_CURRENT_SOURCE_DIR}/Data;LD_LIBRARY_PATH=${QT5_ROOT_DIR}/lib/:${MEDCOUPLING_ROOT_DIR}/lib/:${MEDFILE_ROOT_DIR}/lib/:${HDF5_ROOT_DIR}/lib:${PYTHON_ROOT_DIR}/lib;PYTHONPATH=${MEDCOUPLING_ROOT_DIR}/lib/python3.6/site-packages/;PV_PLUGIN_PATH=${CMAKE_BINARY_DIR}/lib/paraview-5.7/plugins/MEDReader;PARAVIEW_BIN_DIR=${ParaView_DIR}/bin/")
35     endforeach()
36   endif()
37
38   if(PARAVIEW_USE_QT)
39     file(GLOB xmlTests *.xml)
40     foreach(testFullPath ${xmlTests})
41       get_filename_component(testFile ${testFullPath} NAME)
42       get_filename_component(testName ${testFile} NAME_WE)
43       set (${testName}_USES_DIRECT_DATA ON)
44       paraview_add_client_tests(
45         LOAD_PLUGIN MEDReader
46         PLUGIN_PATH $<TARGET_FILE_DIR:MEDReader>
47         BASELINE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Data/Baseline
48         TEST_SCRIPTS ${testFile})
49         set_tests_properties(pv.${testName} PROPERTIES ENVIRONMENT "PARAVIEW_DATA_ROOT=${CMAKE_CURRENT_SOURCE_DIR}/Data;LD_LIBRARY_PATH=${QT5_ROOT_DIR}/lib/:${MEDCOUPLING_ROOT_DIR}/lib/:${MEDFILE_ROOT_DIR}/lib/:${HDF5_ROOT_DIR}/lib:${PYTHON_ROOT_DIR}/lib")
50     endforeach()
51   endif()
52
53 else()
54
55   ########################
56   # Tests for PARAVIS mode
57   ########################
58
59   include(tests.set)
60
61   salome_generate_tests_environment(tests_env)
62   list(APPEND tests_env "PARAVIEW_DATA_ROOT=${CMAKE_CURRENT_SOURCE_DIR}/Data")
63
64   set(_helper_script ${CMAKE_CURRENT_SOURCE_DIR}/medreadertestlauncher.py)
65   set(_baseline_dir ${CMAKE_CURRENT_SOURCE_DIR}/Data/Baseline)
66   IF(SALOME_PARAVIS_NO_VISU_TESTS)
67     SET(_other_options "-D")
68   ENDIF()
69
70   foreach(tfile ${TEST_NUMBERS})
71     add_test(Python-testMEDReader${tfile}
72              ${PYTHON_EXECUTABLE}
73              ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader${tfile}.py
74              -B ${_baseline_dir} ${_other_options})
75     set_tests_properties(Python-testMEDReader${tfile} PROPERTIES ENVIRONMENT "${tests_env}")
76   endforeach()
77
78   # Application tests
79   set(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test/MEDReader)
80   foreach(tfile ${TEST_NUMBERS})
81     install(FILES testMEDReader${tfile}.py
82             DESTINATION ${TEST_INSTALL_DIRECTORY})
83   endforeach()
84   
85   install(FILES MEDReaderHelper.py tests.set
86           DESTINATION ${TEST_INSTALL_DIRECTORY})
87   install(FILES CTestTestfileInstall.cmake
88           DESTINATION ${TEST_INSTALL_DIRECTORY}
89           RENAME CTestTestfile.cmake)
90   install(DIRECTORY Data/Baseline DESTINATION ${TEST_INSTALL_DIRECTORY})
91
92 endif()