From: Paul RASCLE Date: Mon, 9 Jul 2018 15:07:40 +0000 (+0200) Subject: add salome tests X-Git-Tag: SHAPER_V9_1_0RC1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=56a3a1a6502eb07428d39fde146723f8a4a81f25;p=plugins%2Fgmshplugin.git add salome tests --- diff --git a/CMakeLists.txt b/CMakeLists.txt index f72b09e..830f6ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -206,13 +206,14 @@ SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME # Specific to GMSHPLUGIN: SET(SALOME_GMSHPLUGIN_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/gmshplugin" CACHE PATH "Install path: SALOME GMSHPLUGIN specific data") +SET(SALOME_GMSHPLUGIN_INSTALL_TESTS "${SALOME_INSTALL_BINS}/test") MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS) MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON) MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES) MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED) MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG_LOCAL SALOME_INSTALL_DOC) -MARK_AS_ADVANCED(SALOME_GMSHPLUGIN_INSTALL_RES_DATA) +MARK_AS_ADVANCED(SALOME_GMSHPLUGIN_INSTALL_RES_DATA SALOME_GMSHPLUGIN_INSTALL_TESTS) # Accumulate environment variables for GMSHPLUGIN module SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS} @@ -226,6 +227,9 @@ ADD_SUBDIRECTORY(idl) ADD_SUBDIRECTORY(resources) ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(bin) +IF(SALOME_BUILD_TESTS) + ADD_SUBDIRECTORY(tests) +ENDIF(SALOME_BUILD_TESTS) IF(SALOME_BUILD_DOC) ADD_SUBDIRECTORY(doc) ENDIF(SALOME_BUILD_DOC) diff --git a/doc/salome/examples/CMakeLists.txt b/doc/salome/examples/CMakeLists.txt index 732471c..cd56614 100644 --- a/doc/salome/examples/CMakeLists.txt +++ b/doc/salome/examples/CMakeLists.txt @@ -18,5 +18,31 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -FILE(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/*.py") -INSTALL(FILES ${files} DESTINATION ${SALOME_INSTALL_DOC}/examples/GMSHPLUGIN) +#FILE(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/*.py") +#INSTALL(FILES ${files} DESTINATION ${SALOME_INSTALL_DOC}/examples/GMSHPLUGIN) + +INCLUDE(examples.set) + +SET(COMPONENT_NAME GMSHPLUGIN) + +SET(TEST_INSTALL_DIRECTORY ${SALOME_GMSHPLUGIN_INSTALL_TESTS}) + +# make test +SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) + +FOREACH(tfile ${EXAMPLE_NAMES}) + SET(TEST_NAME ${COMPONENT_NAME}_${tfile}) + ADD_TEST(NAME ${TEST_NAME} + COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_SOURCE_DIR}/doc/salome/examples/gmshdemo.py ${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.py) + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES ENVIRONMENT "${tests_env}") + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") + INSTALL(FILES ${tfile}.py DESTINATION ${SALOME_INSTALL_DOC}/examples/GMSHPLUGIN) +ENDFOREACH() + +# salome test +FOREACH(tfile ${EXAMPLE_NAMES}) + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.py + DESTINATION ${TEST_INSTALL_DIRECTORY}) +ENDFOREACH() + +INSTALL(FILES examples.set DESTINATION ${TEST_INSTALL_DIRECTORY}) \ No newline at end of file diff --git a/doc/salome/examples/examples.set b/doc/salome/examples/examples.set new file mode 100644 index 0000000..d43fad6 --- /dev/null +++ b/doc/salome/examples/examples.set @@ -0,0 +1,22 @@ +# Copyright (C) 2016 CEA/DEN, EDF R&D +# +# 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(EXAMPLE_NAMES + gmshdemo +) diff --git a/doc/salome/examples/gmshdemo.py b/doc/salome/examples/gmshdemo.py index 11474f5..4b201b5 100644 --- a/doc/salome/examples/gmshdemo.py +++ b/doc/salome/examples/gmshdemo.py @@ -3,14 +3,12 @@ import salome salome.salome_init() -theStudy = salome.myStudy - from salome.geom import geomBuilder -geompy = geomBuilder.New(theStudy) +geompy = geomBuilder.New() from salome.smesh import smeshBuilder -smesh = smeshBuilder.New(theStudy) +smesh = smeshBuilder.New() from salome.GMSHPlugin import GMSHPluginBuilder @@ -51,4 +49,4 @@ Mesh_2D.Compute() Mesh_3D.Compute() if salome.sg.hasDesktop(): - salome.sg.updateObjBrowser(1) + salome.sg.updateObjBrowser() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100755 index 0000000..b4916b5 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,47 @@ +# Copyright (C) 2013-2016 CEA/DEN, EDF R&D +# +# 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) + +SET(COMPONENT_NAME GMSHPLUGIN) + +SET(TEST_INSTALL_DIRECTORY ${SALOME_GMSHPLUGIN_INSTALL_TESTS}) + +# make test +SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) + +FOREACH(tfile ${TEST_NAMES}) + SET(TEST_NAME ${COMPONENT_NAME}_${tfile}) + ADD_TEST(NAME ${TEST_NAME} + COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_SOURCE_DIR}/doc/salome/examples/gmshdemo.py ${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.py) + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES ENVIRONMENT "${tests_env}") + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") +ENDFOREACH() + +# salome test +FOREACH(tfile ${TEST_NAMES}) + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.py + DESTINATION ${TEST_INSTALL_DIRECTORY}) +ENDFOREACH() + +INSTALL(FILES CTestTestfileInstall.cmake + DESTINATION ${TEST_INSTALL_DIRECTORY} + RENAME CTestTestfile.cmake) + +INSTALL(FILES tests.set DESTINATION ${TEST_INSTALL_DIRECTORY}) \ No newline at end of file diff --git a/tests/CTestTestfileInstall.cmake b/tests/CTestTestfileInstall.cmake new file mode 100644 index 0000000..af34930 --- /dev/null +++ b/tests/CTestTestfileInstall.cmake @@ -0,0 +1,32 @@ +# Copyright (C) 2016 CEA/DEN, EDF R&D +# +# 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) +INCLUDE(examples.set) + +SET(COMPONENT_NAME GMSHPLUGIN) +SET(SALOME_TEST_DRIVER "$ENV{KERNEL_ROOT_DIR}/bin/salome/appliskel/salome_test_driver.py") +SET(TIMEOUT 300) + + +FOREACH(tfile ${TEST_NAMES} ${EXAMPLE_NAMES}) + SET(TEST_NAME ${COMPONENT_NAME}_${tfile}) + ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} ${tfile}.py) + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") +ENDFOREACH() diff --git a/tests/basicGroup.py b/tests/basicGroup.py new file mode 100644 index 0000000..69072b6 --- /dev/null +++ b/tests/basicGroup.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- + +### +### This file is generated automatically by SALOME v8.5.0 with dump python functionality +### + +import sys +import salome + +salome.salome_init() + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + + +geompy = geomBuilder.New() + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) +Cylinder_1 = geompy.MakeCylinderRH(100, 300) +Sphere_1 = geompy.MakeSphereR(100) +Fuse_1 = geompy.MakeFuseList([Box_1, Cylinder_1, Sphere_1], True, True) +Group_1 = geompy.CreateGroup(Fuse_1, geompy.ShapeType["FACE"]) +geompy.UnionIDs(Group_1, [46, 37]) +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( Box_1, 'Box_1' ) +geompy.addToStudy( Cylinder_1, 'Cylinder_1' ) +geompy.addToStudy( Sphere_1, 'Sphere_1' ) +geompy.addToStudy( Fuse_1, 'Fuse_1' ) +geompy.addToStudyInFather( Fuse_1, Group_1, 'Group_1' ) + +### +### SMESH component +### + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder + +smesh = smeshBuilder.New() +Mesh_1 = smesh.Mesh(Fuse_1) +GMSH = Mesh_1.Tetrahedron(algo=smeshBuilder.GMSH) +Gmsh_Parameters = GMSH.Parameters() +Gmsh_Parameters.Set2DAlgo( 0 ) +Gmsh_Parameters.SetMinSize( 1 ) +Gmsh_Parameters.SetMaxSize( 20 ) +Gmsh_Parameters.SetIs2d( 0 ) +Gmsh_Parameters.SetCompoundOnShape(Group_1) +isDone = Mesh_1.Compute() + + +## Set names of Mesh objects +smesh.SetName(GMSH.GetAlgorithm(), 'GMSH') +smesh.SetName(Gmsh_Parameters, 'Gmsh Parameters') +smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1') + + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser() diff --git a/tests/tests.set b/tests/tests.set new file mode 100644 index 0000000..eaf7b73 --- /dev/null +++ b/tests/tests.set @@ -0,0 +1,22 @@ +# Copyright (C) 2016 CEA/DEN, EDF R&D +# +# 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(TEST_NAMES + basicGroup +)