Commit 4b803e39 authored by Remi Perenon's avatar Remi Perenon
Browse files

Adding unit tests within CI

parent 9e9be420
Pipeline #8836 passed with stages
in 14 minutes and 51 seconds
......@@ -203,6 +203,7 @@ make_release:macos:
- export HDF5_INCLUDE_PATH="/Users/ci/Projects/fullprof/hdf5-ifort/include"
- export HDF5_LIBRARY_PATH="/Users/ci/Projects/fullprof/hdf5-ifort/lib"
- export PYTHON_LIBRARY_PATH="/Users/ci/Projects/fullprof/libpython3.7.dylib"
- export TEST_TRICK_COMMAND="install_name_tool -change /Library/Frameworks/Python.framework/Versions/3.7/Python /usr/local/Cellar/python\@3.8/3.8.3/Frameworks/Python.framework/Versions/3.8/Python Python_API/Tests/CFML_api/crysfml_api.so"
- BuildServer/Unix/build_release.sh
artifacts:
name: "CrysFML macOS"
......@@ -236,6 +237,7 @@ make_release:windows:
- set HDF5_INCLUDE_PATH=C:\\Projects\\fullprof\\hdf5-ifort\\include\\shared
- set HDF5_LIBRARY_PATH=C:\\Projects\\fullprof\\hdf5-ifort\\lib
- set PYTHON_LIBRARY_PATH=C:\\Projects\\fullprof\\python37\\libs\\python37.lib
- set PYTHON_INTERPRETER_PATH=C:\\Projects\fullprof\\python37\\python3.exe
- call "BuildServer\\Windows\\build_release.bat"
artifacts:
name: "CrysFML Windows"
......
......@@ -10,15 +10,20 @@ ENV LD_LIBRARY_PATH=/opt/intel/lib/intel64
# https://askubuntu.com/questions/355565/how-do-i-install-the-latest-version-of-cmake-from-the-command-line
# So need to install software-properties-common to add kitware repo https://askubuntu.com/questions/493460/how-to-install-add-apt-repository-using-the-terminal
# So need to install apt-transport-https https://unix.stackexchange.com/questions/263801/apt-get-fails-the-method-driver-usr-lib-apt-methods-https-could-not-be-found
RUN apt-get update && apt-get install -y python3 \
doxygen \
graphviz \
libaec-dev \
libz-dev \
libsz2 && \
apt-get install -y wget \
RUN apt-get update && apt-get install -y wget \
software-properties-common \
apt-transport-https && \
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add - && \
apt-add-repository 'deb https://apt.kitware.com/ubuntu/ xenial main' && \
apt-get update && apt-get install -y cmake
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update && apt-get install -y python3.7-dev
RUN apt-get update && apt-get install -y doxygen \
graphviz \
libaec-dev \
libz-dev \
libsz2
RUN wget https://bootstrap.pypa.io/get-pip.py
RUN python3.7 get-pip.py
RUN python3.7 -m pip install numpy
\ No newline at end of file
......@@ -9,7 +9,7 @@ ENV CI_COMMIT_SHORT_SHA=${CI_COMMIT_SHORT_SHA}
ENV CI_COMMIT_REF_NAME=${CI_COMMIT_REF_NAME}
ENV HDF5_INCLUDE_PATH=/hdf5/include
ENV HDF5_LIBRARY_PATH=/hdf5/lib
ENV PYTHON_LIBRARY_PATH=/fullprof/libpython3.7m.so
ENV LD_LIBRARY_PATH=/opt/intel/lib/intel64
COPY ./ /app/
WORKDIR /app
......
......@@ -6,4 +6,11 @@ mkdir build_${compiler##*/}
cd build_${compiler##*/}
cmake -D ARCH32=OFF -D CMAKE_BUILD_TYPE=Debug -D CMAKE_Fortran_COMPILER=${compiler} -D USE_HDF=ON -D HDF5_INCLUDE_PATH=${HDF5_INCLUDE_PATH} -D HDF5_LIBRARY_PATH=${HDF5_LIBRARY_PATH} ..
cmake --build . && ctest
\ No newline at end of file
cmake --build .
ctest
status=$?
if [ $status -ne 0 ]; then
echo "Failure/Error during ctest"
exit $status
fi
......@@ -5,7 +5,14 @@ rm -Rf build_release
mkdir build_release
cd build_release
cmake -D ARCH32=OFF -D CMAKE_BUILD_TYPE=Release -D CMAKE_Fortran_COMPILER=ifort -DPYTHON_API=ON -DPYTHON_LIBRARY_PATH=${PYTHON_LIBRARY_PATH} -D USE_HDF=ON -D HDF5_INCLUDE_PATH=${HDF5_INCLUDE_PATH} -D HDF5_LIBRARY_PATH=${HDF5_LIBRARY_PATH} ..
cmake -D ARCH32=OFF -D CMAKE_BUILD_TYPE=Release -D CMAKE_Fortran_COMPILER=ifort -DPYTHON_API=ON -DPYTHON_INTERPRETER_PATH=${PYTHON_INTERPRETER_PATH} -DPYTHON_LIBRARY_PATH=${PYTHON_LIBRARY_PATH} -D USE_HDF=ON -D HDF5_INCLUDE_PATH=${HDF5_INCLUDE_PATH} -D HDF5_LIBRARY_PATH=${HDF5_LIBRARY_PATH} ..
cmake --build .
cmake --build . --target doxygen
ctest && cmake --build . --target install
\ No newline at end of file
eval "${TEST_TRICK_COMMAND}"
ctest
status=$?
if [ $status -ne 0 ]; then
echo "Failure/Error during ctest"
exit $status
fi
cmake --build . --target install
......@@ -10,4 +10,11 @@ cmake -G "NMake Makefiles" -D ARCH32=OFF -D CMAKE_BUILD_TYPE=Debug -D CMAKE_Fort
) else (
cmake -G "MinGW Makefiles" -D ARCH32=OFF -D CMAKE_BUILD_TYPE=Debug -D CMAKE_Fortran_COMPILER=%compiler% -D USE_HDF=ON -D HDF5_INCLUDE_PATH=%HDF5_INCLUDE_PATH% -D HDF5_LIBRARY_PATH=%HDF5_LIBRARY_PATH% ..
)
cmake --build .&& ctest
\ No newline at end of file
cmake --build .
ctest
set STATUS=%ERRORLEVEL%
rem Exit now
if %STATUS% neq 0 (
echo "Failure/Error during ctest"
exit %STATUS%
)
......@@ -5,7 +5,14 @@ rmdir build_release /s /q
mkdir build_release
cd build_release
cmake -G "NMake Makefiles" -D ARCH32=OFF -D CMAKE_BUILD_TYPE=Release -D CMAKE_Fortran_COMPILER=ifort -D HEAP_ARRAYS=ON -D PYTHON_API=ON -D PYTHON_LIBRARY_PATH=%PYTHON_LIBRARY_PATH% -D USE_HDF=ON -D HDF5_INCLUDE_PATH=%HDF5_INCLUDE_PATH% -D HDF5_LIBRARY_PATH=%HDF5_LIBRARY_PATH% ..
cmake -G "NMake Makefiles" -D ARCH32=OFF -D CMAKE_BUILD_TYPE=Release -D CMAKE_Fortran_COMPILER=ifort -D HEAP_ARRAYS=ON -D PYTHON_API=ON -D PYTHON_INTERPRETER_PATH=%PYTHON_INTERPRETER_PATH% -D PYTHON_LIBRARY_PATH=%PYTHON_LIBRARY_PATH% -D USE_HDF=ON -D HDF5_INCLUDE_PATH=%HDF5_INCLUDE_PATH% -D HDF5_LIBRARY_PATH=%HDF5_LIBRARY_PATH% ..
cmake --build .
cmake --build . --target doxygen
ctest && cmake --build . --target install
\ No newline at end of file
ctest
set STATUS=%ERRORLEVEL%
rem Exit now
if %STATUS% neq 0 (
echo "Failure/Error during ctest"
exit %STATUS%
)
cmake --build . --target install
......@@ -56,6 +56,11 @@ if(DEFINED PYTHON_LIBRARY_PATH)
else()
set(PYTHON_LIBRARY_PATH "" CACHE PATH "Python library path")
endif()
if(DEFINED PYTHON_INTERPRETER_PATH)
set(PYTHON_INTERPRETER_PATH ${PYTHON_INTERPRETER_PATH} CACHE PATH "Python interpreter path")
else()
set(PYTHON_INTERPRETER_PATH "" CACHE PATH "Python interpreter path")
endif()
# Include and library paths for HDF5.
# They must be set by the user.
......
#################################
# Commad line arguments section
#################################
cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR)
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
#################################
# Project section
......@@ -30,13 +30,20 @@ set_source_files_properties(forpy_mod.f90 PROPERTIES COMPILE_FLAG "-cpp")
# Add a dependency to crysfml_common to keep sure that the crysfml_common library will be built first.
add_dependencies(${LIBRARY_NAME} crysfml_common)
#find_package(Python3 REQUIRED)
#include_directories(${Python3_INCLUDE_DIRS})
if(NOT PYTHON_LIBRARY_PATH)
#For a strange reason, find_package must be launched twice !
find_package(Python3 COMPONENTS Interpreter Development)
#For a strange reason, find_package must be launched twice !
if((NOT PYTHON_LIBRARY_PATH) OR (NOT PYTHON_INTERPRETER_PATH))
find_package(Python3 COMPONENTS Interpreter Development)
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
endif()
if(NOT PYTHON_LIBRARY_PATH)
set(PYTHON_LIBRARY_PATH ${Python3_LIBRARIES})
else()
message(STATUS "Linking Python extension with provided PYTHON_LIBRARY_PATH variable: " ${PYTHON_LIBRARY_PATH})
endif()
if(NOT PYTHON_INTERPRETER_PATH)
set(PYTHON_INTERPRETER_PATH ${Python3_EXECUTABLE})
else()
message(STATUS "using Python interpreter provided with PYTHON_INTERPRETER_PATH variable: " ${PYTHON_INTERPRETER_PATH})
endif()
if (UNIX)
......@@ -52,6 +59,17 @@ include_directories(${CRYSFML_COMMON_MODULE_DIRECTORY})
target_link_libraries(${LIBRARY_NAME} crysfml_common)
target_link_libraries(${LIBRARY_NAME} Python3_LIB)
# Set library extension
set_target_properties(${LIBRARY_NAME} PROPERTIES PREFIX "" OUTPUT_NAME ${LIBRARY_NAME})
set(LIBRARY_FILENAME "crysfml_api.so")
if(APPLE)
set_target_properties(${LIBRARY_NAME} PROPERTIES SUFFIX ".so")
set(LIBRARY_FILENAME "crysfml_api.so")
elseif(WIN32)
set_target_properties(${LIBRARY_NAME} PROPERTIES SUFFIX ".pyd")
set(LIBRARY_FILENAME "crysfml_api.pyd")
endif()
#################################
# Documentation
#################################
......@@ -84,16 +102,33 @@ else (DOXYGEN_FOUND)
message("Doxygen is not installed - no documentation will be generated")
endif (DOXYGEN_FOUND)
#################################
# Install section
# Tests
#################################
set_target_properties(${LIBRARY_NAME} PROPERTIES PREFIX "" OUTPUT_NAME ${LIBRARY_NAME})
if(APPLE)
set_target_properties(${LIBRARY_NAME} PROPERTIES SUFFIX ".so")
elseif(WIN32)
set_target_properties(${LIBRARY_NAME} PROPERTIES SUFFIX ".pyd")
endif()
# Add tests
add_test(NAME "Python_API_Tests" COMMAND ${PYTHON_INTERPRETER_PATH} -m unittest discover ${CMAKE_CURRENT_BINARY_DIR}/../Tests)
add_custom_target(Python_Files ALL
COMMAND
${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/../Tests
${CMAKE_CURRENT_BINARY_DIR}/../Tests
COMMAND
${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../Tests/CFML_api
COMMAND
${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_FILENAME}
${CMAKE_CURRENT_BINARY_DIR}/../Tests/CFML_api
)
#################################
# Install section
#################################
# The rules for installing the library.
install(DIRECTORY "" DESTINATION ${PYTHON_API_PREFIX}/CFML_api FILES_MATCHING PATTERN "*.py" PATTERN "Extensions" EXCLUDE)
if(WIN32)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment