From 80657e4615027595184835a4c2f3d5548dc1b18d Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Wed, 20 Apr 2016 16:56:46 +0200 Subject: [PATCH] [salome test] connect MEDCalc tests --- CTestTestfileInstall.cmake | 3 ++- src/MEDCalc/CMakeLists.txt | 4 ++-- src/MEDCalc/test/CMakeLists.txt | 12 ++++++++---- src/MEDCalc/test/CTestTestfileInstall.cmake | 17 ++++++++++++----- src/MEDCalc/test/test_qttesting.py | 12 +++++++----- src/MEDCalculator/Test/CMakeLists.txt | 2 +- 6 files changed, 32 insertions(+), 18 deletions(-) diff --git a/CTestTestfileInstall.cmake b/CTestTestfileInstall.cmake index 65850b7d6..0fb26934a 100644 --- a/CTestTestfileInstall.cmake +++ b/CTestTestfileInstall.cmake @@ -17,7 +17,8 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -SET(COMPONENT_NAME MEDCalc) +SET(COMPONENT_NAME MEDCALC) SET(TIMEOUT 300) SUBDIRS(MEDCalculator) +SUBDIRS(MEDCalc) diff --git a/src/MEDCalc/CMakeLists.txt b/src/MEDCalc/CMakeLists.txt index d6a1e4d3a..560ecadd9 100644 --- a/src/MEDCalc/CMakeLists.txt +++ b/src/MEDCalc/CMakeLists.txt @@ -23,10 +23,10 @@ ADD_SUBDIRECTORY(res) IF(SALOME_BUILD_GUI) ADD_SUBDIRECTORY(gui) - IF(SALOME_MED_WITH_QTTESTING) + IF(SALOME_MED_WITH_QTTESTING) ADD_SUBDIRECTORY(test) ENDIF() - + ENDIF() IF(SALOME_MED_ENABLE_PYTHON) diff --git a/src/MEDCalc/test/CMakeLists.txt b/src/MEDCalc/test/CMakeLists.txt index 620afc49a..329a4d3ae 100644 --- a/src/MEDCalc/test/CMakeLists.txt +++ b/src/MEDCalc/test/CMakeLists.txt @@ -36,13 +36,17 @@ SET(_test_files ) # 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) +SET(TEST_INSTALL_DIRECTORY ${SALOME_MED_INSTALL_TEST}/MEDCalc) + +SALOME_INSTALL_SCRIPTS(test_qttesting.py ${TEST_INSTALL_DIRECTORY}) +SALOME_INSTALL_SCRIPTS(${CMAKE_CURRENT_BINARY_DIR}/medcalc_testutils.py ${TEST_INSTALL_DIRECTORY}) SALOME_INSTALL_SCRIPTS("${_test_scripts}" ${SALOME_INSTALL_PYTHON}/tests) - + 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) +INSTALL(FILES CTestTestfileInstall.cmake + DESTINATION ${TEST_INSTALL_DIRECTORY} + RENAME CTestTestfile.cmake) diff --git a/src/MEDCalc/test/CTestTestfileInstall.cmake b/src/MEDCalc/test/CTestTestfileInstall.cmake index f0491770c..ef479a14e 100644 --- a/src/MEDCalc/test/CTestTestfileInstall.cmake +++ b/src/MEDCalc/test/CTestTestfileInstall.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2016 CEA/DEN, EDF R&D +# 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 @@ -17,8 +17,15 @@ # 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! +SET(TEST_NAMES + test_qttesting +) -ADD_TEST(MEDCalcQtTesting python test_qttesting.py) -SET_TESTS_PROPERTIES(MEDCalcQtTesting PROPERTIES LABELS "${COMPONENT_NAME}") +FOREACH(tfile ${TEST_NAMES}) + SET(TEST_NAME ${COMPONENT_NAME}_${tfile}) + ADD_TEST(${TEST_NAME} python ${tfile}.py) + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES + LABELS "${COMPONENT_NAME}" + TIMEOUT ${TIMEOUT} + ) +ENDFOREACH() diff --git a/src/MEDCalc/test/test_qttesting.py b/src/MEDCalc/test/test_qttesting.py index 4a547e3d1..e059b853b 100644 --- a/src/MEDCalc/test/test_qttesting.py +++ b/src/MEDCalc/test/test_qttesting.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011-2016 CEA/DEN, EDF R&D +# 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 @@ -26,7 +26,7 @@ class MEDGUITest(unittest.TestCase): unittest.TestCase.__init__(self, methodName=methodName) self._tmpDir = "" self._removeDir = True - + def setUp(self): import tempfile self._tmpDir = tempfile.mkdtemp(prefix="med_gui_tests_") @@ -37,7 +37,7 @@ class MEDGUITest(unittest.TestCase): unittest.TestCase.tearDown(self) if self._removeDir: shutil.rmtree(self._tmpDir, False) - + def getTestName(self): """ Return name of the test being currently executed. """ return self.id().split(".")[-1] @@ -61,13 +61,15 @@ class MEDGUITest(unittest.TestCase): Assert if not matching. """ import filecmp from medcalc_testutils import GetBaselineDir - + base_pth = os.path.join(GetBaselineDir(), basename) gen_path = os.path.join(self._tmpDir, basename) print base_pth, gen_path try: ret = filecmp.cmp(base_pth, gen_path, shallow=False) except OSError: + import traceback + traceback.print_exc() ret = False if not ret: # Keep file if comparison fails @@ -90,7 +92,7 @@ class MEDGUITest(unittest.TestCase): filedata = filedata.replace("/tmp/%s" % med_file, os.path.join(GetMEDFileDir(), med_file)) with open(scen_pth2,'w') as f: f.write(filedata) - + ## ## Now the tests themselves ## diff --git a/src/MEDCalculator/Test/CMakeLists.txt b/src/MEDCalculator/Test/CMakeLists.txt index e7e937c4e..8dbaa3774 100644 --- a/src/MEDCalculator/Test/CMakeLists.txt +++ b/src/MEDCalculator/Test/CMakeLists.txt @@ -45,7 +45,7 @@ INSTALL(TARGETS TestMEDCalculator DESTINATION ${SALOME_INSTALL_BINS}) # Application tests -SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test/MEDCalculator) +SET(TEST_INSTALL_DIRECTORY ${SALOME_MED_INSTALL_TEST}/MEDCalculator) INSTALL(TARGETS TestMEDCalculator DESTINATION ${TEST_INSTALL_DIRECTORY}) INSTALL(FILES CTestTestfileInstall.cmake -- 2.39.2