]> SALOME platform Git repositories - plugins/gmshplugin.git/commitdiff
Salome HOME
add salome tests
authorPaul RASCLE <paul.rascle@edf.fr>
Mon, 9 Jul 2018 15:07:40 +0000 (17:07 +0200)
committerPaul RASCLE <paul.rascle@edf.fr>
Mon, 9 Jul 2018 15:19:24 +0000 (17:19 +0200)
CMakeLists.txt
doc/salome/examples/CMakeLists.txt
doc/salome/examples/examples.set [new file with mode: 0644]
doc/salome/examples/gmshdemo.py
tests/CMakeLists.txt [new file with mode: 0755]
tests/CTestTestfileInstall.cmake [new file with mode: 0644]
tests/basicGroup.py [new file with mode: 0644]
tests/tests.set [new file with mode: 0644]

index f72b09ee9214f67b7b4cec7c6e54a7b91595ba25..830f6ea9cb6297dc2aa487e5c67204d522c42617 100644 (file)
@@ -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)
index 732471c7d09e29e8d5d25c0a7d91406d636f56d2..cd5661459138bf37fff90771ec4d12065470ee8e 100644 (file)
 # 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 (file)
index 0000000..d43fad6
--- /dev/null
@@ -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
+)
index 11474f5f69ff9006681934335e4d0b5c028b6b7e..4b201b5dc5dbdd2d281918bcc00eeb3ef422e538 100644 (file)
@@ -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 (executable)
index 0000000..b4916b5
--- /dev/null
@@ -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 (file)
index 0000000..af34930
--- /dev/null
@@ -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 (file)
index 0000000..69072b6
--- /dev/null
@@ -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 (file)
index 0000000..eaf7b73
--- /dev/null
@@ -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
+)