1 # Copyright (C) 2014-2020 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # SHAPER unit test system
25 # ADD_UNIT_TESTS(TestUndoRedo.py
28 # SET(PROJECT_UNIT_TESTS
32 # ADD_UNIT_TESTS(${PROJECT_UNIT_TESTS})
34 # Where "TestUndoRedo.py" and "TestResultBody.py" are names
35 # of python test scripts in the "./Test" directory.
36 # This macro will add "Subproject_" as prefix and
37 # remove ".py" for the test name automaticaly.
39 # Start building of the "RUN_TESTS" project in the Visual studio
40 # or run "make test" on linux stations to start the testing procedure.
45 function(GENERATE_TESTS PATH testdir TESTS)
46 SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
48 foreach(eachFileName ${ARGN})
49 # Strip the ".py" suffix
50 GET_FILENAME_COMPONENT(aTestName ${eachFileName} NAME_WE)
52 # Add "SubprojectName_" prefix
53 GET_FILENAME_COMPONENT(aSubprojectName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
54 SET(aTestName "${aSubprojectName}_${aTestName}")
56 # Full path to the python test file beeing executed
57 SET(aTestFileName "${testdir}/${eachFileName}")
58 IF(EXISTS ${aTestFileName})
59 ADD_TEST(NAME ${aTestName}
60 COMMAND ${PYTHON_EXECUTABLE} ${aTestFileName})
61 SET_TESTS_PROPERTIES(${aTestName} PROPERTIES
62 ENVIRONMENT "${tests_env};SHAPER_UNIT_TEST_IN_PROGRESS=1"
63 LABELS "${aSubprojectName}")
65 #MESSAGE(STATUS "Test added: ${aTestName} file: ${aTestFileName}")
66 ELSE(EXISTS ${aTestFileName})
67 MESSAGE(WARNING "Can not find the test file: ${aTestFileName}")
68 ENDIF(EXISTS ${aTestFileName})
69 endforeach(eachFileName ${ARGN})
70 endfunction(GENERATE_TESTS)
72 function(ADD_UNIT_TESTS)
73 GENERATE_TESTS(PATH "${CMAKE_CURRENT_SOURCE_DIR}/Test" TESTS ${ARGN})
74 endfunction(ADD_UNIT_TESTS)
76 function(ADD_UNIT_TESTS_API)
77 GENERATE_TESTS(PATH "${CMAKE_CURRENT_SOURCE_DIR}" TESTS ${ARGN})
78 endfunction(ADD_UNIT_TESTS_API)
81 function(ADD_RESTRICTED_TESTS)
82 SET(RESTRICTED_ROOT_DIR $ENV{RESTRICTED_ROOT_DIR} CACHE PATH "Path to the restricted repository")
84 if (EXISTS ${RESTRICTED_ROOT_DIR})
85 GENERATE_TESTS(PATH "${RESTRICTED_ROOT_DIR}/SHAPER/bugs" TESTS ${ARGN})
87 message(WARNING "RESTRICTED_ROOT_DIR is not specified to run restricted tests")
89 endfunction(ADD_RESTRICTED_TESTS)