From 305a95aef9dea790ebb7009fe04c98532768a82e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20D=C3=BCrr?= Date: Sat, 12 Aug 2017 15:47:05 +0200 Subject: [PATCH] Integrate Python-based tests and benchmark into Travis * Unfortunately, due to the SWIG dependency, we need sudo to install on Travis (conflicts when adding with debian-sid source prevent using addons) which means we cannot use the container-based infrastructure anymore. * Building the Python bindings requires g++5 (at least with -Werr set). * When building the Python bindings on Travis, the numpy includes are not found by cmake, so they have to be added separately by running a Python process with `numpy.get_include()` * The build script now (somewhat clumsily) depends on the RUN_PYTEST environment variable. If it is set to anything other than "", it will make the tests and run tests and benchmarks --- .travis.yml | 30 ++++++++++++++++++++---------- EKF/CMakeLists.txt | 4 ++++ build.sh | 23 +++++++++++++++++------ 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index f23dc37247..1000a335dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,23 +1,33 @@ +sudo: required language: cpp - +python: +- '3.5' matrix: fast_finish: true include: - os: linux dist: trusty compiler: gcc + env: + - MATRIX_EVAL="" - os: linux dist: trusty compiler: clang - env: CC=clang CXX=clang++ + env: + - CC=clang CXX=clang++ + - MATRIX_EVAL="" + - os: linux + dist: trusty + compiler: gcc + env: + - RUN_PYTEST=1 + - MATRIX_EVAL="CC=gcc-5 && CXX=g++-5" -addons: - apt: - packages: - - clang - - cmake - - g++ - - gcc - - libeigen3-dev +before_install: + - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y + - sudo apt-get -qq update + - sudo apt-get install -y clang cmake g++ gcc libeigen3-dev swig3.0 python-dev gcc-5 g++-5 + - eval "${MATRIX_EVAL}" + - if [ -n "${RUN_PYTEST}" ]; then pip3 install -r ./EKF/tests/pytest/requirements.txt; fi script: ./build.sh diff --git a/EKF/CMakeLists.txt b/EKF/CMakeLists.txt index eb595a265a..7dc791cd37 100644 --- a/EKF/CMakeLists.txt +++ b/EKF/CMakeLists.txt @@ -123,11 +123,15 @@ if(PythonTests) set_source_files_properties(../swig/ecl.i PROPERTIES CPLUSPLUS ON) set(swigged_sources ekf.h) + # Find numpy include + execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print(numpy.get_include())" OUTPUT_VARIABLE NUMPY_INCLUDE_DIRS ERROR_QUIET) + include_directories( .. ${MATRIX_DIR} ${EIGEN3_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS} + ${NUMPY_INCLUDE_DIRS} ) set(SWIG_MODULE_ecl_EXTRA_DEPS ${swigged_sources}) diff --git a/build.sh b/build.sh index 281e3e3e12..f8385bcca1 100755 --- a/build.sh +++ b/build.sh @@ -35,9 +35,20 @@ # Exit on any error. set -e -# Build EKF shared library. -mkdir Build -p -cd Build -cmake ../EKF -make -cd .. +if [ -z ${RUN_PYTEST} ]; +then + # Build EKF shared library. + mkdir Build -p + cd Build + cmake ../EKF + make + cd .. +else + # Build EKF shared library. + mkdir Build -p + cd Build + cmake -DPythonTests=1 ../EKF + make pytest + make pytest-benchmark + cd .. +fi