Salome HOME
Copyright update: 2016
[modules/paravis.git] / src / Plugins / MEDReader / Test / CMakeLists.txt
1 # Copyright (C) 2010-2016  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 SET(TEST_NUMBERS 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19)
21
22 SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test/MEDReader)
23
24 IF(KW_TESTING_PLATFORM)
25
26 FOREACH(tfile ${TEST_NUMBERS})
27   INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader${tfile}.py
28           DESTINATION ${TEST_INSTALL_DIRECTORY})
29 ENDFOREACH()
30
31   INSTALL(FILES CTestTestfileInstall.cmake
32         DESTINATION ${TEST_INSTALL_DIRECTORY}
33         RENAME CTestTestfile.cmake)
34
35 cmake_minimum_required(VERSION 2.7)
36
37 find_package(ParaView REQUIRED)
38 include(${PARAVIEW_USE_FILE})
39
40 include(ParaViewTestingMacros)
41 include(FindPythonModules)
42
43 include(${PROJECT_SOURCE_DIR}/testing/testFunctions.cmake)
44 set(PV_PLUGIN_PATH "${CMAKE_BINARY_DIR}/lib/")
45
46 include(CTest)
47
48 enable_testing()
49
50 set(PARAVIEW_BIN_DIR "${ParaView_DIR}/bin" CACHE PATH "ParaView binary path")
51
52 set(PVTEST_DRIVER "${PARAVIEW_BIN_DIR}/smTestDriver")
53 set(PARAVIEW_CLIENT "${PARAVIEW_BIN_DIR}/paraview")
54 set(PARAVIEW_SERVER "${PARAVIEW_BIN_DIR}/pvserver")
55 set(PVPYTHON "${PARAVIEW_BIN_DIR}/pvpython")
56
57 set(BASELINES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Baselines")
58 set(PYTHON_SCRIPTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
59 set(TEMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/Testing/Temporary")
60
61 # Application tests
62 SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test/MEDReader)
63
64 if(NOT EXISTS ${TEMP_DIR})
65   file(MAKE_DIRECTORY ${TEMP_DIR})
66 endif()
67
68 # Override vtk_add_test_* variables for use with ParaView.
69 macro (_myy_override_vtk_dirs)
70   set(VTK_TEST_DATA_DIR    ${PYTHON_SCRIPTS_DIR})
71   set(VTK_BASELINE_DIR     ${BASELINES_DIR})
72   set(VTK_TEST_OUTPUT_DIR  ${TEMP_DIR})
73   set(VTK_TEST_DATA_TARGET ParaViewData)
74 endmacro ()
75
76 function (myy_add_python_test)
77   message(STATUS "Add Python test for ${ARGV2}")
78   set(VTK_PYTHON_EXE "${PVPYTHON}")
79   list(APPEND VTK_PYTHON_ARGS -dr
80     ${PARAVIEW_PYTHON_ARGS})
81   _myy_override_vtk_dirs()
82   myvtk_add_test_python(${ARGN})
83 endfunction ()
84
85 # Test all python scripts
86 file(GLOB scripts "${PYTHON_SCRIPTS_DIR}/*py")
87 foreach(file ${scripts})
88   get_filename_component(fname ${file} NAME)
89   myy_add_python_test(
90     NO_DATA NO_RT
91     ${fname})
92   INSTALL(FILES ${file}
93           DESTINATION ${TEST_INSTALL_DIRECTORY})
94 endforeach()
95
96 ELSE(KW_TESTING_PLATFORM)
97
98 SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
99
100 FOREACH(tfile ${TEST_NUMBERS})
101   ADD_TEST(testMEDReader${tfile} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader${tfile}.py -B ${CMAKE_CURRENT_SOURCE_DIR}/Baselines )
102   SET_TESTS_PROPERTIES(testMEDReader${tfile} PROPERTIES ENVIRONMENT "${tests_env}")
103 ENDFOREACH()
104
105 ENDIF(KW_TESTING_PLATFORM)
106
107 INSTALL(FILES CTestTestfileInstall.cmake
108         DESTINATION ${TEST_INSTALL_DIRECTORY}
109         RENAME CTestTestfile.cmake)