From: vsr Date: Fri, 22 May 2020 08:47:33 +0000 (+0300) Subject: Rearrange tests X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=017133335b762d0970c19007508b0ee72da27107;p=modules%2Fsmesh.git Rearrange tests --- diff --git a/CMakeLists.txt b/CMakeLists.txt index e2434f379..87740544d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -177,20 +177,6 @@ ELSE(EXISTS ${GEOM_ROOT_DIR}) MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM, please define GEOM_ROOT_DIR") ENDIF(EXISTS ${GEOM_ROOT_DIR}) -# Find SHAPERSTUDY -# ================ -SET(WITH_SHAPER_STUDY OFF) -SET(SHAPERSTUDY_ROOT_DIR $ENV{SHAPERSTUDY_ROOT_DIR} CACHE PATH "Path to the Salome SHAPERSTUDY") -IF(EXISTS ${SHAPERSTUDY_ROOT_DIR}) - FIND_PACKAGE(SalomeSHAPERSTUDY) - IF(SalomeSHAPERSTUDY_FOUND) - SET(WITH_SHAPER_STUDY ON) - ENDIF() -ENDIF(EXISTS ${SHAPERSTUDY_ROOT_DIR}) -IF(NOT WITH_SHAPER_STUDY AND SALOME_BUILD_TESTS) - MESSAGE(WARNING "SHAPERSTUDY is not found; the corresponding tests will be omitted") -ENDIF() - ## ## SMESH specifics ## @@ -290,9 +276,7 @@ ADD_SUBDIRECTORY(adm_local) ADD_SUBDIRECTORY(resources) ADD_SUBDIRECTORY(bin) ADD_SUBDIRECTORY(src) -IF(SALOME_BUILD_DOC) - ADD_SUBDIRECTORY(doc) -ENDIF() +ADD_SUBDIRECTORY(doc) IF(SALOME_BUILD_TESTS) ADD_SUBDIRECTORY(test) ENDIF() @@ -371,3 +355,10 @@ INSTALL(FILES # Install the export set for use with the install-tree INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}" FILE ${PROJECT_NAME}Targets.cmake) + +IF(SALOME_BUILD_TESTS) + # Application tests + INSTALL(FILES CTestTestfileInstall.cmake + DESTINATION ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test + RENAME CTestTestfile.cmake) +ENDIF() diff --git a/CTestTestfileInstall.cmake b/CTestTestfileInstall.cmake new file mode 100644 index 000000000..99929d8d2 --- /dev/null +++ b/CTestTestfileInstall.cmake @@ -0,0 +1,27 @@ +# Copyright (C) 2017-2020 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +SET(SALOME_TEST_DRIVER "$ENV{KERNEL_ROOT_DIR}/bin/salome/appliskel/salome_test_driver.py") + +SET(COMPONENT_NAME SMESH) +SET(TIMEOUT 300) + +SUBDIRS(examples) +SUBDIRS(tests) +SUBDIRS(tools) diff --git a/doc/salome/CMakeLists.txt b/doc/salome/CMakeLists.txt index ccc73ba43..08e99e1be 100644 --- a/doc/salome/CMakeLists.txt +++ b/doc/salome/CMakeLists.txt @@ -20,6 +20,10 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -ADD_SUBDIRECTORY(tui) -ADD_SUBDIRECTORY(gui) -ADD_SUBDIRECTORY(examples) \ No newline at end of file +ADD_SUBDIRECTORY(examples) +IF(SALOME_BUILD_DOC) + ADD_SUBDIRECTORY(tui) + ADD_SUBDIRECTORY(gui) +ENDIF() + +SALOME_INSTALL_SCRIPTS(collect_mesh_methods.py ${SALOME_INSTALL_BINS}) diff --git a/doc/salome/collect_mesh_methods.py b/doc/salome/collect_mesh_methods.py new file mode 100755 index 000000000..5d47130f7 --- /dev/null +++ b/doc/salome/collect_mesh_methods.py @@ -0,0 +1,199 @@ +#!/usr/bin/env python3 +# Copyright (C) 2012-2020 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +################################################################################# +# +# File: collect_mesh_methods.py +# Author: Vadim SANDLER, Open CASCADE S.A.S (vadim.sandler@opencascade.com) +# +################################################################################# +# +# Extraction of the meshing algorithm classes +# dynamically added by the plug-in to the Mesh +# class. +# +# This script is intended for internal usage - only +# for generation of the extra developer documentation for +# the meshing plug-in(s). +# +# Usage: +# collect_mesh_methods.py +# where +# is a name of the plug-in module +# +# Notes: +# - the script is supposed to be run in correct environment +# i.e. PYTHONPATH, SMESH_MeshersList and other important +# variables are set properly; otherwise the script will fail. +# +################################################################################ + +import inspect +import sys + +def main(plugin_name, dummymeshhelp = True, output_file = "smeshBuilder.py", format = "doxygen"): + plugin_module_name = plugin_name + "Builder" + plugin_module = "salome.%s.%s" % (plugin_name, plugin_module_name) + try: + exec("from salome.smesh.smeshBuilder import *", globals()) + exec("import %s" % plugin_module, globals()) + exec("mod = %s" % plugin_module , globals()) + methods = {} + for attr in dir( mod ): + if attr.startswith( '_' ): continue + algo = getattr( mod, attr ) + if inspect.isclass(algo) and hasattr(algo, "meshMethod"): + method = getattr( algo, "meshMethod" ) + if method not in methods: methods[ method ] = [] + methods[ method ].append( algo ) + pass + pass + if methods: + output = [] + if dummymeshhelp: + if format == "doxygen": + output.append( "## @package smeshBuilder" ) + output.append( "# Documentation of the methods dynamically added by the " + plugin_name + " meshing plug-in to the Mesh class." ) + output.append( "" ) + elif format == "sphinx": + output.append( '"""' ) + output.append( 'Documentation of the methods dynamically added by the ' + plugin_name + ' meshing plug-in to the Mesh class.' ) + output.append( '"""' ) + output.append( '' ) + pass + if format == "doxygen": + output.append( "## This class allows defining and managing a mesh." ) + output.append( "#" ) + elif format == "sphinx": + output.append( "class Mesh:" ) + output.append( ' """' ) + output.append( ' This class allows defining and managing a mesh.' ) + output.append( ' ' ) + if dummymeshhelp: + # Add dummy Mesh help + # This is supposed to be done when generating documentation for meshing plug-ins + if format == "doxygen": + output.append( "# @note The documentation below does not provide complete description of class @b %Mesh" ) + output.append( "# from @b smeshBuilder package. This documentation provides only information about" ) + output.append( "# the methods dynamically added to the %Mesh class by the " + plugin_name + " plugin" ) + output.append( "# For more details on the %Mesh class, please refer to the SALOME %Mesh module" ) + output.append( "# documentation." ) + elif format == "sphinx": + output.append( ' The documentation below does not provide complete description of class @b %Mesh' ) + output.append( ' from @b smeshBuilder package. This documentation provides only information about' ) + output.append( ' the methods dynamically added to the %Mesh class by the " + plugin_name + " plugin' ) + output.append( ' For more details on the %Mesh class, please refer to the SALOME %Mesh module' ) + output.append( ' documentation.' ) + output.append( ' """' ) + output.append( ' ' ) + pass + else: + # Extend documentation for Mesh class with information about dynamically added methods. + # This is supposed to be done only when building documentation for SMESH module + if format == "doxygen": + output.append( "# @note Some methods are dynamically added to the @b %Mesh class in runtime by meshing " ) + output.append( "# plug-in modules. If you fail to find help on some methods in the documentation of SMESH module, " ) + output.append( "# try to look into the documentation for the meshing plug-ins." ) + elif format == "sphinx": + output.append( " Note:") + output.append( " Some methods are dynamically added to the @b %Mesh class in runtime by meshing " ) + output.append( " plug-in modules. If you fail to find help on some methods in the documentation of SMESH module, " ) + output.append( " try to look into the documentation for the meshing plug-ins." ) + output.append( ' """' ) + output.append( ' ' ) + pass + if format == "doxygen": + output.append( "class Mesh:" ) + for method in methods: + docHelper = "" + for algo in methods[ method ]: + if hasattr( algo, "docHelper" ): docHelper = getattr( algo, "docHelper" ) + if docHelper: break + pass + if not docHelper: docHelper = "Create new algorithm." + if format == "doxygen": + output.append( " ## %s" % docHelper ) + output.append( " #" ) + output.append( " # This method is dynamically added to %Mesh class by the meshing plug-in(s). " ) + output.append( " #" ) + output.append( " # If the optional @a geom_shape parameter is not set, this algorithm is global (applied to whole mesh)." ) + output.append( " # Otherwise, this algorithm defines a submesh based on @a geom_shape subshape." ) + output.append( " # @param algo_type type of algorithm to be created; allowed values are specified by classes implemented by plug-in" ) + output.append( " # @param geom_shape if defined, the subshape to be meshed (GEOM_Object)" ) + output.append( " # @return An instance of Mesh_Algorithm sub-class according to the specified @a algo_type, see " ) + output.append( " # %s" % ", ".join( [ "%s.%s" % ( plugin_module_name, algo.__name__ ) for algo in methods[ method ] ] ) ) + output.append( " def %s(algo_type, geom_shape=0):" % method ) + output.append( " pass" ) + elif format == "sphinx": + output.append( ' def %s(algo_type, geom_shape=0):' % method ) + output.append( ' """' ) + output.append( ' %s' % docHelper ) + output.append( ' ' ) + output.append( ' This method is dynamically added to :class:`Mesh ` class by the meshing plug-in(s). ' ) + output.append( ' ' ) + output.append( ' If the optional *geom_shape* parameter is not set, this algorithm is global (applied to whole mesh).' ) + output.append( ' Otherwise, this algorithm defines a submesh based on *geom_shape* subshape.' ) + output.append( ' ' ) + output.append( ' Parameters:' ) + output.append( ' algo_type: type of algorithm to be created; allowed values are specified by classes implemented by plug-in' ) + output.append( ' geom_shape (GEOM_Object): if defined, the subshape to be meshed' ) + output.append( ' ' ) + output.append( ' Returns:') + output.append( ' An instance of Mesh_Algorithm sub-class according to the specified *algo_type*, see ' ) + output.append( ' %s' % ", ".join( [ ":class:`~%s.%s`" % ( plugin_module_name, algo.__name__ ) for algo in methods[ method ] ] ) ) + output.append( ' """' ) + output.append( ' pass' ) + pass + with open(output_file, "w", encoding='utf8') as f: + f.write('\n'.join(output)) + pass + pass + except Exception as e: + print(e) + pass + pass + +if __name__ == "__main__": + import argparse + parser = argparse.ArgumentParser() + h = "Output file (smesh.py by default)" + parser.add_argument("-o", "--output", dest="output", + action="store", default='smesh.py', metavar="file", + help=h) + h = "If this option is True, dummy help for Mesh class is added. " + h += "This option should be False (default) when building documentation for SMESH module " + h += "and True when building documentation for meshing plug-ins." + parser.add_argument("-d", "--dummy-mesh-help", dest="dummymeshhelp", + action="store_true", default=False, + help=h) + h = "Format of the documentation strings in the output file. Possible values are: " + h+= "'doxygen' - documentation strings are generated in the doxygen format, before a method definition." + h+= "'sphinx' - documentation strings are generated in the sphinx format, after a method definition." + parser.add_argument("-f", "--format", dest="format", + action="store", default="doxygen", help=h) + + parser.add_argument("plugin_name") + + + args = parser.parse_args() + + if args.plugin_name is None : sys.exit("Plugin name is not specified") + main( args.plugin_name, args.dummymeshhelp, args.output, args.format ) + pass diff --git a/doc/salome/examples/CMakeLists.txt b/doc/salome/examples/CMakeLists.txt index 8121124f7..ce20e4b70 100644 --- a/doc/salome/examples/CMakeLists.txt +++ b/doc/salome/examples/CMakeLists.txt @@ -19,31 +19,42 @@ INCLUDE(tests.set) -SET(TEST_REINIT_SALOME "False") SALOME_CONFIGURE_FILE(tests.py.in tests.py) -SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) +# Install examples -IF(SMESH_JOIN_TESTS) - ADD_TEST(NAME SMESH_examples COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_SOURCE_DIR}/doc/salome/examples/testme.py tests.py) -ELSE(SMESH_JOIN_TESTS) - FOREACH(test ${GOOD_TESTS}) - GET_FILENAME_COMPONENT(testname ${test} NAME_WE) - ADD_TEST(NAME ${testname} - COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_SOURCE_DIR}/doc/salome/examples/testme.py ${CMAKE_CURRENT_SOURCE_DIR}/${test}) - SET_TESTS_PROPERTIES(${testname} PROPERTIES ENVIRONMENT "${tests_env}") - ENDFOREACH() -ENDIF(SMESH_JOIN_TESTS) - -# install Python scripts +SET(EXAMPLES_TESTS ${BAD_TESTS} ${GOOD_TESTS}) SALOME_INSTALL_SCRIPTS("${EXAMPLES_TESTS}" ${SALOME_INSTALL_DOC}/examples/SMESH) -# Application tests +# Tests + +IF(SALOME_BUILD_TESTS) + + SET(TEST_REINIT_SALOME "False") + SET(TEST_HELPER ${KERNEL_ROOT_DIR}/bin/salome/test_helper.py) + + SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) + + IF(SMESH_JOIN_TESTS) + ADD_TEST(NAME all_examples COMMAND ${PYTHON_EXECUTABLE} -B ${TEST_HELPER} tests.py) + ELSE(SMESH_JOIN_TESTS) + FOREACH(test ${GOOD_TESTS}) + GET_FILENAME_COMPONENT(testname ${test} NAME_WE) + ADD_TEST(NAME ${testname} + COMMAND ${PYTHON_EXECUTABLE} -B ${TEST_HELPER} ${CMAKE_CURRENT_SOURCE_DIR}/${test}) + SET_TESTS_PROPERTIES(${testname} PROPERTIES ENVIRONMENT "${tests_env}") + ENDFOREACH() + ENDIF(SMESH_JOIN_TESTS) + + # Application tests + # Note: we don't install test scripts as they are already installed to the documentation folder + + SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test/examples) -SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test) -INSTALL(FILES ${GOOD_TESTS} ${BAD_TESTS} DESTINATION ${TEST_INSTALL_DIRECTORY}) + CONFIGURE_FILE(CTestTestfileInstall.cmake ${CMAKE_CURRENT_BINARY_DIR}/CTestTestfileInstall.cmake @ONLY) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/CTestTestfileInstall.cmake + DESTINATION ${TEST_INSTALL_DIRECTORY} + RENAME CTestTestfile.cmake) + INSTALL(FILES tests.set DESTINATION ${TEST_INSTALL_DIRECTORY}) -INSTALL(FILES CTestTestfileInstall.cmake - DESTINATION ${TEST_INSTALL_DIRECTORY} - RENAME CTestTestfile.cmake) -INSTALL(FILES tests.set DESTINATION ${TEST_INSTALL_DIRECTORY}) +ENDIF(SALOME_BUILD_TESTS) diff --git a/doc/salome/examples/CTestTestfileInstall.cmake b/doc/salome/examples/CTestTestfileInstall.cmake index 9a38643c1..e7cf79647 100644 --- a/doc/salome/examples/CTestTestfileInstall.cmake +++ b/doc/salome/examples/CTestTestfileInstall.cmake @@ -17,15 +17,13 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -INCLUDE(tests.set) +SET(TESTS_DIR "$ENV{SMESH_ROOT_DIR}/@SALOME_INSTALL_DOC@/examples/SMESH") -SET(SALOME_TEST_DRIVER "$ENV{KERNEL_ROOT_DIR}/bin/salome/appliskel/salome_test_driver.py") -SET(COMPONENT_NAME SMESH) -SET(TIMEOUT 300) +INCLUDE(tests.set) FOREACH(tfile ${GOOD_TESTS} ${BAD_TESTS}) GET_FILENAME_COMPONENT(BASE_NAME ${tfile} NAME_WE) - SET(TEST_NAME SMESH_${BASE_NAME}) - ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} ${tfile}) + SET(TEST_NAME ${COMPONENT_NAME}_${BASE_NAME}) + ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} ${TESTS_DIR}/${tfile}) SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") ENDFOREACH() diff --git a/doc/salome/examples/testme.py b/doc/salome/examples/testme.py deleted file mode 100755 index 7babeeacc..000000000 --- a/doc/salome/examples/testme.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env python3 -# Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - - -import unittest, sys, os - -class SalomeSession(object): - def __init__(self, script): - import runSalome - run_script = "runSalome.py" - if sys.platform == 'win32': - module_dir = os.getenv("KERNEL_ROOT_DIR") - if module_dir: run_script = os.path.join(module_dir, "bin", "salome", run_script) - pass - sys.argv = [run_script] - sys.argv += ["--terminal"] - sys.argv += ["--modules=GEOM,SHAPER,SHAPERSTUDY,SMESH"] - sys.argv += ["%s" % script] - if sys.platform == 'win32': - main_module_path = sys.modules['__main__'].__file__ - sys.modules['__main__'].__file__ = '' - clt, d = runSalome.main() - if sys.platform == 'win32': - sys.modules['__main__'].__file__ = main_module_path - return - - def __del__(self): - port = os.getenv('NSPORT') - import killSalomeWithPort - killSalomeWithPort.killMyPort(port) - return - pass - -class MyTest(unittest.TestCase): - def testFunction(self): - SalomeSession(sys.argv[1]) - pass - -unittest.main(argv=sys.argv[:1]) diff --git a/doc/salome/examples/tests.set b/doc/salome/examples/tests.set index 4f341f55e..767ac77c8 100644 --- a/doc/salome/examples/tests.set +++ b/doc/salome/examples/tests.set @@ -183,5 +183,3 @@ SET(GOOD_TESTS quad_medial_axis_algo.py defining_hypotheses_len_near_vertex.py ) - -SET(EXAMPLES_TESTS ${BAD_TESTS} ${GOOD_TESTS} testme.py) diff --git a/doc/salome/gui/SMESH/CMakeLists.txt b/doc/salome/gui/SMESH/CMakeLists.txt index 644a69b5e..8798c825c 100644 --- a/doc/salome/gui/SMESH/CMakeLists.txt +++ b/doc/salome/gui/SMESH/CMakeLists.txt @@ -19,10 +19,8 @@ INCLUDE(UseSphinx) -SALOME_INSTALL_SCRIPTS(collect_mesh_methods.py ${SALOME_INSTALL_BINS}) - #SET(DOC_SMESH_MeshersList StdMeshers) -SET(smesh_file "${CMAKE_CURRENT_SOURCE_DIR}/collect_mesh_methods.py") +SET(smesh_file "${CMAKE_SOURCE_DIR}/doc/salome/collect_mesh_methods.py") SET(smesh_merge_file "${CMAKE_CURRENT_SOURCE_DIR}/merge_mesh_class.py") # Define requared environment variables diff --git a/doc/salome/gui/SMESH/collect_mesh_methods.py b/doc/salome/gui/SMESH/collect_mesh_methods.py deleted file mode 100755 index 5d47130f7..000000000 --- a/doc/salome/gui/SMESH/collect_mesh_methods.py +++ /dev/null @@ -1,199 +0,0 @@ -#!/usr/bin/env python3 -# Copyright (C) 2012-2020 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -################################################################################# -# -# File: collect_mesh_methods.py -# Author: Vadim SANDLER, Open CASCADE S.A.S (vadim.sandler@opencascade.com) -# -################################################################################# -# -# Extraction of the meshing algorithm classes -# dynamically added by the plug-in to the Mesh -# class. -# -# This script is intended for internal usage - only -# for generation of the extra developer documentation for -# the meshing plug-in(s). -# -# Usage: -# collect_mesh_methods.py -# where -# is a name of the plug-in module -# -# Notes: -# - the script is supposed to be run in correct environment -# i.e. PYTHONPATH, SMESH_MeshersList and other important -# variables are set properly; otherwise the script will fail. -# -################################################################################ - -import inspect -import sys - -def main(plugin_name, dummymeshhelp = True, output_file = "smeshBuilder.py", format = "doxygen"): - plugin_module_name = plugin_name + "Builder" - plugin_module = "salome.%s.%s" % (plugin_name, plugin_module_name) - try: - exec("from salome.smesh.smeshBuilder import *", globals()) - exec("import %s" % plugin_module, globals()) - exec("mod = %s" % plugin_module , globals()) - methods = {} - for attr in dir( mod ): - if attr.startswith( '_' ): continue - algo = getattr( mod, attr ) - if inspect.isclass(algo) and hasattr(algo, "meshMethod"): - method = getattr( algo, "meshMethod" ) - if method not in methods: methods[ method ] = [] - methods[ method ].append( algo ) - pass - pass - if methods: - output = [] - if dummymeshhelp: - if format == "doxygen": - output.append( "## @package smeshBuilder" ) - output.append( "# Documentation of the methods dynamically added by the " + plugin_name + " meshing plug-in to the Mesh class." ) - output.append( "" ) - elif format == "sphinx": - output.append( '"""' ) - output.append( 'Documentation of the methods dynamically added by the ' + plugin_name + ' meshing plug-in to the Mesh class.' ) - output.append( '"""' ) - output.append( '' ) - pass - if format == "doxygen": - output.append( "## This class allows defining and managing a mesh." ) - output.append( "#" ) - elif format == "sphinx": - output.append( "class Mesh:" ) - output.append( ' """' ) - output.append( ' This class allows defining and managing a mesh.' ) - output.append( ' ' ) - if dummymeshhelp: - # Add dummy Mesh help - # This is supposed to be done when generating documentation for meshing plug-ins - if format == "doxygen": - output.append( "# @note The documentation below does not provide complete description of class @b %Mesh" ) - output.append( "# from @b smeshBuilder package. This documentation provides only information about" ) - output.append( "# the methods dynamically added to the %Mesh class by the " + plugin_name + " plugin" ) - output.append( "# For more details on the %Mesh class, please refer to the SALOME %Mesh module" ) - output.append( "# documentation." ) - elif format == "sphinx": - output.append( ' The documentation below does not provide complete description of class @b %Mesh' ) - output.append( ' from @b smeshBuilder package. This documentation provides only information about' ) - output.append( ' the methods dynamically added to the %Mesh class by the " + plugin_name + " plugin' ) - output.append( ' For more details on the %Mesh class, please refer to the SALOME %Mesh module' ) - output.append( ' documentation.' ) - output.append( ' """' ) - output.append( ' ' ) - pass - else: - # Extend documentation for Mesh class with information about dynamically added methods. - # This is supposed to be done only when building documentation for SMESH module - if format == "doxygen": - output.append( "# @note Some methods are dynamically added to the @b %Mesh class in runtime by meshing " ) - output.append( "# plug-in modules. If you fail to find help on some methods in the documentation of SMESH module, " ) - output.append( "# try to look into the documentation for the meshing plug-ins." ) - elif format == "sphinx": - output.append( " Note:") - output.append( " Some methods are dynamically added to the @b %Mesh class in runtime by meshing " ) - output.append( " plug-in modules. If you fail to find help on some methods in the documentation of SMESH module, " ) - output.append( " try to look into the documentation for the meshing plug-ins." ) - output.append( ' """' ) - output.append( ' ' ) - pass - if format == "doxygen": - output.append( "class Mesh:" ) - for method in methods: - docHelper = "" - for algo in methods[ method ]: - if hasattr( algo, "docHelper" ): docHelper = getattr( algo, "docHelper" ) - if docHelper: break - pass - if not docHelper: docHelper = "Create new algorithm." - if format == "doxygen": - output.append( " ## %s" % docHelper ) - output.append( " #" ) - output.append( " # This method is dynamically added to %Mesh class by the meshing plug-in(s). " ) - output.append( " #" ) - output.append( " # If the optional @a geom_shape parameter is not set, this algorithm is global (applied to whole mesh)." ) - output.append( " # Otherwise, this algorithm defines a submesh based on @a geom_shape subshape." ) - output.append( " # @param algo_type type of algorithm to be created; allowed values are specified by classes implemented by plug-in" ) - output.append( " # @param geom_shape if defined, the subshape to be meshed (GEOM_Object)" ) - output.append( " # @return An instance of Mesh_Algorithm sub-class according to the specified @a algo_type, see " ) - output.append( " # %s" % ", ".join( [ "%s.%s" % ( plugin_module_name, algo.__name__ ) for algo in methods[ method ] ] ) ) - output.append( " def %s(algo_type, geom_shape=0):" % method ) - output.append( " pass" ) - elif format == "sphinx": - output.append( ' def %s(algo_type, geom_shape=0):' % method ) - output.append( ' """' ) - output.append( ' %s' % docHelper ) - output.append( ' ' ) - output.append( ' This method is dynamically added to :class:`Mesh ` class by the meshing plug-in(s). ' ) - output.append( ' ' ) - output.append( ' If the optional *geom_shape* parameter is not set, this algorithm is global (applied to whole mesh).' ) - output.append( ' Otherwise, this algorithm defines a submesh based on *geom_shape* subshape.' ) - output.append( ' ' ) - output.append( ' Parameters:' ) - output.append( ' algo_type: type of algorithm to be created; allowed values are specified by classes implemented by plug-in' ) - output.append( ' geom_shape (GEOM_Object): if defined, the subshape to be meshed' ) - output.append( ' ' ) - output.append( ' Returns:') - output.append( ' An instance of Mesh_Algorithm sub-class according to the specified *algo_type*, see ' ) - output.append( ' %s' % ", ".join( [ ":class:`~%s.%s`" % ( plugin_module_name, algo.__name__ ) for algo in methods[ method ] ] ) ) - output.append( ' """' ) - output.append( ' pass' ) - pass - with open(output_file, "w", encoding='utf8') as f: - f.write('\n'.join(output)) - pass - pass - except Exception as e: - print(e) - pass - pass - -if __name__ == "__main__": - import argparse - parser = argparse.ArgumentParser() - h = "Output file (smesh.py by default)" - parser.add_argument("-o", "--output", dest="output", - action="store", default='smesh.py', metavar="file", - help=h) - h = "If this option is True, dummy help for Mesh class is added. " - h += "This option should be False (default) when building documentation for SMESH module " - h += "and True when building documentation for meshing plug-ins." - parser.add_argument("-d", "--dummy-mesh-help", dest="dummymeshhelp", - action="store_true", default=False, - help=h) - h = "Format of the documentation strings in the output file. Possible values are: " - h+= "'doxygen' - documentation strings are generated in the doxygen format, before a method definition." - h+= "'sphinx' - documentation strings are generated in the sphinx format, after a method definition." - parser.add_argument("-f", "--format", dest="format", - action="store", default="doxygen", help=h) - - parser.add_argument("plugin_name") - - - args = parser.parse_args() - - if args.plugin_name is None : sys.exit("Plugin name is not specified") - main( args.plugin_name, args.dummymeshhelp, args.output, args.format ) - pass diff --git a/src/Tools/CMakeLists.txt b/src/Tools/CMakeLists.txt index de8baf90a..6275ca1a7 100644 --- a/src/Tools/CMakeLists.txt +++ b/src/Tools/CMakeLists.txt @@ -37,3 +37,10 @@ SET(plugin_SCRIPTS # --- rules --- SALOME_INSTALL_SCRIPTS("${plugin_SCRIPTS}" ${SALOME_SMESH_INSTALL_PLUGINS}) + +IF(SALOME_BUILD_TESTS) + SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test/tools) + INSTALL(FILES CTestTestfileInstall.cmake + DESTINATION ${TEST_INSTALL_DIRECTORY} + RENAME CTestTestfile.cmake) +ENDIF() diff --git a/src/Tools/CTestTestfileInstall.cmake b/src/Tools/CTestTestfileInstall.cmake new file mode 100644 index 000000000..7145456e6 --- /dev/null +++ b/src/Tools/CTestTestfileInstall.cmake @@ -0,0 +1,20 @@ +# Copyright (C) 2017-2020 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +SUBDIRS(MacMesh) diff --git a/src/Tools/MacMesh/CMakeLists.txt b/src/Tools/MacMesh/CMakeLists.txt index eb6b82fcb..cb1f07743 100644 --- a/src/Tools/MacMesh/CMakeLists.txt +++ b/src/Tools/MacMesh/CMakeLists.txt @@ -49,18 +49,32 @@ SET(plugin_SCRIPTS MacMesh/PublishGroups.py MacMesh/SharpAngle.py ) -SET(sample_SCRIPT +SET(sample_SCRIPTS ${CMAKE_CURRENT_BINARY_DIR}/PressureValve.py ) # --- rules --- SALOME_INSTALL_SCRIPTS("${plugin_SCRIPTS}" ${MACMESH_INSTALL_PY}) -SALOME_INSTALL_SCRIPTS("${sample_SCRIPT}" ${SALOME_INSTALL_SCRIPT_PYTHON} DEF_PERMS) +SALOME_INSTALL_SCRIPTS("${sample_SCRIPTS}" ${SALOME_INSTALL_DOC}/examples/SMESH DEF_PERMS) -SET(testname MacMesh_Example_PressureValve) -SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) -ADD_TEST( - NAME ${testname} - COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_SOURCE_DIR}/doc/salome/examples/testme.py ${sample_SCRIPT}) -SET_TESTS_PROPERTIES(${testname} PROPERTIES ENVIRONMENT "${tests_env}") +IF(SALOME_BUILD_TESTS) + SET(TEST_HELPER ${KERNEL_ROOT_DIR}/bin/salome/test_helper.py) + SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) + FOREACH(test ${sample_SCRIPTS}) + GET_FILENAME_COMPONENT(testname ${test} NAME_WE) + ADD_TEST(NAME MacMesh_${testname} + COMMAND ${PYTHON_EXECUTABLE} -B ${TEST_HELPER} ${test}) + SET_TESTS_PROPERTIES(MacMesh_${testname} PROPERTIES ENVIRONMENT "${tests_env}") + ENDFOREACH() + + # Application tests + # Note: we don't install test scripts as they are already installed to the documentation folder + + SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test/tools/MacMesh) + + CONFIGURE_FILE(CTestTestfileInstall.cmake ${CMAKE_CURRENT_BINARY_DIR}/CTestTestfileInstall.cmake @ONLY) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/CTestTestfileInstall.cmake + DESTINATION ${TEST_INSTALL_DIRECTORY} + RENAME CTestTestfile.cmake) +ENDIF() diff --git a/src/Tools/MacMesh/CTestTestfileInstall.cmake b/src/Tools/MacMesh/CTestTestfileInstall.cmake new file mode 100644 index 000000000..4d9a06476 --- /dev/null +++ b/src/Tools/MacMesh/CTestTestfileInstall.cmake @@ -0,0 +1,29 @@ +# Copyright (C) 2015-2020 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +SET(TESTS_DIR "$ENV{SMESH_ROOT_DIR}/@SALOME_INSTALL_DOC@/examples/SMESH") + +SET(TESTS PressureValve.py) + +FOREACH(tfile ${TESTS}) + GET_FILENAME_COMPONENT(BASE_NAME ${tfile} NAME_WE) + SET(TEST_NAME ${COMPONENT_NAME}_${BASE_NAME}) + ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} ${TESTS_DIR}/${tfile}) + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") +ENDFOREACH() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4e58f7d62..f0bd76a14 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -20,23 +20,30 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # +INCLUDE(tests.set) + +# For 'make test' + SALOME_GENERATE_TESTS_ENVIRONMENT(_test_env) -SET(_test_helper ${CMAKE_SOURCE_DIR}/doc/salome/examples/testme.py) +SET(TEST_HELPER ${KERNEL_ROOT_DIR}/bin/salome/test_helper.py) + +FOREACH(test ${GOOD_TESTS}) + GET_FILENAME_COMPONENT(testname ${test} NAME_WE) + ADD_TEST(NAME ${testname} + COMMAND ${PYTHON_EXECUTABLE} -B ${TEST_HELPER} ${CMAKE_CURRENT_SOURCE_DIR}/${test}) + SET_TESTS_PROPERTIES(${testname} PROPERTIES ENVIRONMENT "${tests_env}") +ENDFOREACH() + +# Application tests -# Tests from RESTRICTED repository ----------------------------------- +SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test/tests) -SET(RESTRICTED_ROOT_DIR $ENV{RESTRICTED_ROOT_DIR} CACHE PATH "Path to the restricted repository") +INSTALL(FILES CTestTestfileInstall.cmake + DESTINATION ${TEST_INSTALL_DIRECTORY} + RENAME CTestTestfile.cmake) -IF(WITH_SHAPER_STUDY AND EXISTS ${RESTRICTED_ROOT_DIR}) - FILE(GLOB _restricted_tests "${RESTRICTED_ROOT_DIR}/SMESH/*.py") - FOREACH(_test ${_restricted_tests}) - GET_FILENAME_COMPONENT(_test_name ${_test} NAME_WE) - ADD_TEST(NAME ${_test_name} - COMMAND ${PYTHON_EXECUTABLE} -B ${_test_helper} ${_test}) - SET_TESTS_PROPERTIES(${_test_name} PROPERTIES ENVIRONMENT "${_test_env}") - ENDFOREACH() -ELSE() - MESSAGE(WARNING "Tests from RESTRICTED repository aren't available") -ENDIF() +INSTALL(FILES tests.set DESTINATION ${TEST_INSTALL_DIRECTORY}) -# -------------------------------------------------------------------- +# WARNING! DO NOT INSTALL RESTRICTED_TESTS HERE!!!! +SET(ALL_TESTS ${BAD_TESTS} ${GOOD_TESTS}) +SALOME_INSTALL_SCRIPTS("${ALL_TESTS}" ${TEST_INSTALL_DIRECTORY}) diff --git a/test/CTestTestfileInstall.cmake b/test/CTestTestfileInstall.cmake new file mode 100644 index 000000000..2d44e9a51 --- /dev/null +++ b/test/CTestTestfileInstall.cmake @@ -0,0 +1,27 @@ +# Copyright (C) 2015-2020 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +INCLUDE(tests.set) + +FOREACH(tfile ${GOOD_TESTS} ${BAD_TESTS} ${RESTRICTED_TESTS}) + GET_FILENAME_COMPONENT(BASE_NAME ${tfile} NAME_WE) + SET(TEST_NAME ${COMPONENT_NAME}_${BASE_NAME}) + ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} ${tfile}) + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") +ENDFOREACH() diff --git a/test/tests.set b/test/tests.set new file mode 100644 index 000000000..98d9c229d --- /dev/null +++ b/test/tests.set @@ -0,0 +1,35 @@ +# Copyright (C) 2015-2020 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +# test cases that can't be used for testing because they use external mesher plug-ins +SET(BAD_TESTS) + +# test cases that can be used for testing because they don't use external mesher plug-ins +SET(GOOD_TESTS) + +# test cases from RESTRICTED repositpory +SET(RESTRICTED_ROOT_DIR $ENV{RESTRICTED_ROOT_DIR}) + +SET(RESTRICTED_TESTS) +IF(EXISTS ${RESTRICTED_ROOT_DIR}) + FILE(GLOB _restricted_tests "${RESTRICTED_ROOT_DIR}/SMESH/*.py") + FOREACH(_test ${_restricted_tests}) + LIST(APPEND RESTRICTED_TESTS ${_test}) + ENDFOREACH() +ENDIF()