From: Ovidiu Mircescu Date: Fri, 8 Mar 2019 15:47:14 +0000 (+0100) Subject: Salome test and some fixes. X-Git-Tag: V9_3_0rc1~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ad63deb35718647959db4bf20b3e267e6539f40a;p=tools%2Fydefx.git Salome test and some fixes. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index eed83b1..d9ae075 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,10 @@ FIND_PACKAGE(SalomeKERNEL NO_MODULE) IF(NOT SalomeKERNEL_FOUND) MESSAGE("SalomeKERNEL not found. Salome installation paths will not be used") +ELSE() + SET(SALOME_BUILD_TESTS ON) + SET(SALOME_YDEFX_INSTALL_TEST ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test CACHE PATH + "Install path: SALOME Test files") ENDIF() IF(NOT DEFINED SALOME_INSTALL_PYTHON) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5da96bc..767b2b5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,6 +16,14 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # + +# For salome test +IF(SALOME_BUILD_TESTS) + INSTALL(FILES CTestTestfileInstall.cmake + DESTINATION ${SALOME_YDEFX_INSTALL_TEST} + RENAME CTestTestfile.cmake) +ENDIF(SALOME_BUILD_TESTS) + ADD_SUBDIRECTORY(cpp) ADD_SUBDIRECTORY(pydefx) IF(YDEFX_BUILD_GUI) diff --git a/src/CTestTestfileInstall.cmake b/src/CTestTestfileInstall.cmake new file mode 100644 index 0000000..4809113 --- /dev/null +++ b/src/CTestTestfileInstall.cmake @@ -0,0 +1,27 @@ +# Copyright (C) 2019 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{KERNEL_ROOT_DIR}/bin/salome/appliskel/salome_test_driver.py") + +SET(COMPONENT_NAME YDEFX) +SET(TIMEOUT 500) + +SUBDIRS( + cpp + ) diff --git a/src/cpp/SamplePyConversions.hxx b/src/cpp/SamplePyConversions.hxx index a3de77b..19db48f 100644 --- a/src/cpp/SamplePyConversions.hxx +++ b/src/cpp/SamplePyConversions.hxx @@ -346,7 +346,7 @@ py2cpp::ConversionCheck errorsFromPy(PyObject* obj, Sample& sample) if(Py_None != pyValue) check.addError(py2cpp::fromPy(pyValue, cppValue)); if(check) - sample.errors().push_back(cppValue); + sample.errors()[i] = cppValue; } } else diff --git a/src/cpp/Test/CMakeLists.txt b/src/cpp/Test/CMakeLists.txt index b91193d..0e98033 100644 --- a/src/cpp/Test/CMakeLists.txt +++ b/src/cpp/Test/CMakeLists.txt @@ -52,3 +52,13 @@ TARGET_LINK_LIBRARIES(StudyRestartTest ${_link_LIBRARIES}) ADD_TEST(YdefxStudyRestartTest StudyRestartTest) SET_TESTS_PROPERTIES(YdefxStudyRestartTest PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_SOURCE_DIR}/src:$ENV{PYTHONPATH}") +IF(SALOME_BUILD_TESTS) + # For salome test + SET(LOCAL_TEST_DIR ${SALOME_YDEFX_INSTALL_TEST}/cpp) + INSTALL(TARGETS SampleTest DESTINATION ${LOCAL_TEST_DIR}) + INSTALL(TARGETS StudyGeneralTest DESTINATION ${LOCAL_TEST_DIR}) + INSTALL(TARGETS StudyRestartTest DESTINATION ${LOCAL_TEST_DIR}) + INSTALL(FILES CTestTestfileInstall.cmake + DESTINATION ${LOCAL_TEST_DIR} + RENAME CTestTestfile.cmake) +ENDIF() diff --git a/src/cpp/Test/CTestTestfileInstall.cmake b/src/cpp/Test/CTestTestfileInstall.cmake new file mode 100644 index 0000000..c28a019 --- /dev/null +++ b/src/cpp/Test/CTestTestfileInstall.cmake @@ -0,0 +1,37 @@ +# Copyright (C) 2019 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_NAME ${COMPONENT_NAME}_SampleTest) +ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} ./SampleTest) +SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES + LABELS "${COMPONENT_NAME}" + ) + +SET(TEST_NAME ${COMPONENT_NAME}_StudyGeneralTest) +ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} ./StudyGeneralTest) +SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES + LABELS "${COMPONENT_NAME}" + ) + +SET(TEST_NAME ${COMPONENT_NAME}_StudyRestartTest) +ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} ./StudyRestartTest) +SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES + LABELS "${COMPONENT_NAME}" + ) + diff --git a/src/pydefx/pystudy.py b/src/pydefx/pystudy.py index deb9a0d..48d272c 100644 --- a/src/pydefx/pystudy.py +++ b/src/pydefx/pystudy.py @@ -43,6 +43,8 @@ def prepareDirectoryForLaunch(sample, result_directory, nb_branches, script, """ if sampleManager is None: sampleManager = defaultSampleManager() + if not os.path.exists(result_directory): + os.makedirs(result_directory) # export sample to result_directory inputFiles = sampleManager.prepareRun(script, sample, result_directory) diff --git a/src/pydefx/samplecsviterator.py b/src/pydefx/samplecsviterator.py index df8359d..8e79dc0 100644 --- a/src/pydefx/samplecsviterator.py +++ b/src/pydefx/samplecsviterator.py @@ -52,7 +52,7 @@ class SampleIterator: datapath = SampleIterator.DATAFILE outputnamespath = SampleIterator.OUTPUTNAMESFILE resultpath = SampleIterator.RESULTFILE - + self.iterNb = -1 self.datafile = open(datapath, newline='') self.data = csv.DictReader(self.datafile, quoting=csv.QUOTE_NONNUMERIC)