From: abn Date: Mon, 18 Apr 2016 12:53:22 +0000 (+0200) Subject: Moving to "salome test" framework. QtTesting are now application tests. X-Git-Tag: V8_1_0b1~25^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2727d7760dc1465ae9fb872bcf94dc67c3d10ab7;p=modules%2Fmed.git Moving to "salome test" framework. QtTesting are now application tests. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index bfdcca99c..77fac8b3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -184,6 +184,7 @@ SET(SALOME_INSTALL_DOC share/doc/salome CACHE PATH "Install path: SALOME documen SET(SALOME_MED_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/med" CACHE PATH "Install path: SALOME MED specific data") SET(SALOME_MED_INSTALL_RES_SCRIPTS "${SALOME_INSTALL_RES}/med" CACHE PATH "Install path: SALOME MED specific scripts") +SET(SALOME_MED_INSTALL_TEST ${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) @@ -218,6 +219,10 @@ ENDIF(SALOME_BUILD_DOC) ADD_SUBDIRECTORY(idl) ADD_SUBDIRECTORY(resources) +# Application tests +# ================= +INSTALL(FILES CTestTestfileInstall.cmake DESTINATION ${SALOME_MED_INSTALL_TEST} RENAME CTestTestfile.cmake) + # Configuration export # ==================== INCLUDE(CMakePackageConfigHelpers) diff --git a/CTestTestfileInstall.cmake b/CTestTestfileInstall.cmake new file mode 100644 index 000000000..105165093 --- /dev/null +++ b/CTestTestfileInstall.cmake @@ -0,0 +1,22 @@ +# Copyright (C) 2015-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(SALOME_TEST_DRIVER "$ENV{ABSOLUTE_APPLI_PATH}/bin/salome/appliskel/salome_test_driver.py") +SET(SALOME_TEST_DRIVER_GUI "$ENV{ABSOLUTE_APPLI_PATH}/bin/salome/appliskel/salome_test_driver_gui.py") +SUBDIRS(MEDCalc) diff --git a/src/MEDCalc/test/CMakeLists.txt b/src/MEDCalc/test/CMakeLists.txt index 2a1326e09..620afc49a 100644 --- a/src/MEDCalc/test/CMakeLists.txt +++ b/src/MEDCalc/test/CMakeLists.txt @@ -20,7 +20,6 @@ SALOME_CONFIGURE_FILE(medcalc_testutils.py.in ${CMAKE_CURRENT_BINARY_DIR}/medcalc_testutils.py) SET(_test_scripts - test_qttesting.py # main entry point test_scalarmap.py ) @@ -36,13 +35,14 @@ SET(_test_files medfiles/test_scalarmap.med ) -# Test rules - the test MEDCalcQtTesting must be run after install (since it starts SALOME) -ADD_TEST(MEDCalcQtTesting ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_qttesting.py) - # Install rules +SALOME_INSTALL_SCRIPTS(test_qttesting.py ${SALOME_MED_INSTALL_TEST}/MEDCalc) +SALOME_INSTALL_SCRIPTS(${CMAKE_CURRENT_BINARY_DIR}/medcalc_testutils.py ${SALOME_MED_INSTALL_TEST}/MEDCalc) + SALOME_INSTALL_SCRIPTS("${_test_scripts}" ${SALOME_INSTALL_PYTHON}/tests) -SALOME_INSTALL_SCRIPTS(${CMAKE_CURRENT_BINARY_DIR}/medcalc_testutils.py ${SALOME_INSTALL_PYTHON}) INSTALL(FILES ${_test_scenarii} DESTINATION ${SALOME_MED_INSTALL_RES_DATA}/tests/scenarios) INSTALL(FILES ${_test_baselines} DESTINATION ${SALOME_MED_INSTALL_RES_DATA}/tests/baselines) INSTALL(FILES ${_test_files} DESTINATION ${SALOME_MED_INSTALL_RES_DATA}/tests/medfiles) + +INSTALL(FILES CTestTestfileInstall.cmake DESTINATION ${SALOME_MED_INSTALL_TEST}/MEDCalc RENAME CTestTestfile.cmake) diff --git a/src/MEDCalc/test/CTestTestfileInstall.cmake b/src/MEDCalc/test/CTestTestfileInstall.cmake new file mode 100644 index 000000000..f0491770c --- /dev/null +++ b/src/MEDCalc/test/CTestTestfileInstall.cmake @@ -0,0 +1,24 @@ +# Copyright (C) 2015-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(COMPONENT_NAME MEDCALC) +SET(TIMEOUT 180) # the GUI needs to start - so let some time here! + +ADD_TEST(MEDCalcQtTesting python test_qttesting.py) +SET_TESTS_PROPERTIES(MEDCalcQtTesting PROPERTIES LABELS "${COMPONENT_NAME}") diff --git a/src/MEDCalc/test/baselines/CMakeLists.txt b/src/MEDCalc/test/baselines/CMakeLists.txt new file mode 100644 index 000000000..803fe6d0d --- /dev/null +++ b/src/MEDCalc/test/baselines/CMakeLists.txt @@ -0,0 +1,109 @@ +# Copyright (C) 2010-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_NUMBERS 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20) + +SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test/MEDReader) +SET(BASELINES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Baselines") + +IF(KW_TESTING_PLATFORM) + +cmake_minimum_required(VERSION 2.7) + +find_package(ParaView REQUIRED) +include(${PARAVIEW_USE_FILE}) + +include(ParaViewTestingMacros) +include(FindPythonModules) + +include(${PROJECT_SOURCE_DIR}/testing/testFunctions.cmake) +set(PV_PLUGIN_PATH "${CMAKE_BINARY_DIR}/lib/") + +include(CTest) + +enable_testing() + +set(PARAVIEW_BIN_DIR "${ParaView_DIR}/bin" CACHE PATH "ParaView binary path") + +set(PVTEST_DRIVER "${PARAVIEW_BIN_DIR}/smTestDriver") +set(PARAVIEW_CLIENT "${PARAVIEW_BIN_DIR}/paraview") +set(PARAVIEW_SERVER "${PARAVIEW_BIN_DIR}/pvserver") +set(PVPYTHON "${PARAVIEW_BIN_DIR}/pvpython") + +set(PYTHON_SCRIPTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +set(TEMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/Testing/Temporary") + +if(NOT EXISTS ${TEMP_DIR}) + file(MAKE_DIRECTORY ${TEMP_DIR}) +endif() + +# Override vtk_add_test_* variables for use with ParaView. +macro (_myy_override_vtk_dirs) + set(VTK_TEST_DATA_DIR ${PYTHON_SCRIPTS_DIR}) + set(VTK_BASELINE_DIR ${BASELINES_DIR}) + set(VTK_TEST_OUTPUT_DIR ${TEMP_DIR}) + set(VTK_TEST_DATA_TARGET ParaViewData) +endmacro () + +function (myy_add_python_test) + message(STATUS "Add Python test for ${ARGV2}") + set(VTK_PYTHON_EXE "${PVPYTHON}") + list(APPEND VTK_PYTHON_ARGS -dr + ${PARAVIEW_PYTHON_ARGS}) + _myy_override_vtk_dirs() + myvtk_add_test_python(${ARGN}) +endfunction () + +# Test all python scripts +file(GLOB scripts "${PYTHON_SCRIPTS_DIR}/*py") +foreach(file ${scripts}) + get_filename_component(fname ${file} NAME) + myy_add_python_test( + NO_DATA NO_RT + ${fname}) + INSTALL(FILES ${file} + DESTINATION ${TEST_INSTALL_DIRECTORY}) +endforeach() + +ELSE(KW_TESTING_PLATFORM) + +SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) + +FOREACH(tfile ${TEST_NUMBERS}) + ADD_TEST(testMEDReader${tfile} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader${tfile}.py -B ${BASELINES_DIR} ) + SET_TESTS_PROPERTIES(testMEDReader${tfile} PROPERTIES ENVIRONMENT "${tests_env}") +ENDFOREACH() + +ENDIF(KW_TESTING_PLATFORM) + + +# Application tests +FOREACH(tfile ${TEST_NUMBERS}) + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader${tfile}.py + DESTINATION ${TEST_INSTALL_DIRECTORY}) +ENDFOREACH() + +FILE(GLOB BASELINE_FILES "${BASELINES_DIR}/*") +FOREACH(baseline_file ${BASELINE_FILES}) + INSTALL(FILES ${baseline_file} DESTINATION ${TEST_INSTALL_DIRECTORY}/Baselines) +ENDFOREACH() + +INSTALL(FILES CTestTestfileInstall.cmake + DESTINATION ${TEST_INSTALL_DIRECTORY} + RENAME CTestTestfile.cmake) diff --git a/src/MEDCalc/test/test_qttesting.py b/src/MEDCalc/test/test_qttesting.py index 165f93978..4a547e3d1 100644 --- a/src/MEDCalc/test/test_qttesting.py +++ b/src/MEDCalc/test/test_qttesting.py @@ -44,14 +44,15 @@ class MEDGUITest(unittest.TestCase): def launchSalomeWithScript(self, scriptname): """ TODO: review this - what is the nicest way to launch SALOME GUI from a Python script? """ - import shutil, subprocess + from salome_instance import SalomeInstance from medcalc_testutils import GetScriptDir - # TODO: review this! - salomeCommand = os.path.join(os.environ.get("KERNEL_ROOT_DIR", ""), "bin", "salome", "runSalome.py") args = "args:%s" % self._tmpDir pth = os.path.join(GetScriptDir(), scriptname) # Launch SALOME with the test script: - status = subprocess.call([salomeCommand, pth, args]) + inst = SalomeInstance.start(with_gui=True, args=[pth, args]) + # And make sure SALOME is stopped before running next one: + inst.stop() + status = 0 # TODO review this if status: raise Exception("SALOME exited abnormally for this test!") @@ -95,16 +96,24 @@ class MEDGUITest(unittest.TestCase): ## def testScalarMap(self): baseline = "test_scalarmap.png" - med_file = "test_scalarmap.med" # will change + med_file = "test_scalarmap.med" # will change with Cedric's files scenario = "test_scalarmap.xml" self.prepareScenario(scenario, baseline, med_file) self.launchSalomeWithScript("test_scalarmap.py") self.compareSnapshot(baseline) + def testScalarMap2(self): + baseline = "test_scalarmap.png" + med_file = "test_scalarmap.med" # will change + scenario = "test_scalarmap.xml" + self.prepareScenario(scenario, baseline, med_file) + self.launchSalomeWithScript("test_scalarmap.py") + self.compareSnapshot(baseline) if __name__ == "__main__": suite = unittest.TestSuite() suite.addTest(MEDGUITest('testScalarMap')) + suite.addTest(MEDGUITest('testScalarMap2')) # suite.addTest(MEDGUITest('testIsoContour')) unittest.TextTestRunner().run(suite)