diff --git a/ci/scripts/test.sh b/ci/scripts/test.sh index eceb2693f3c27710cf7b81130078dbcba1091bd0..b8826256136fd014d3eb37695860148dda35cd99 100755 --- a/ci/scripts/test.sh +++ b/ci/scripts/test.sh @@ -1,8 +1,13 @@ #!/bin/bash set -e -if [ $# -ne 3 ]; then - echo "Usage ./test install_folder hysop_folder cache_dir" +if [ $# -lt 2 ]; then + echo "Usage ./test install_folder hysop_folder [cache_dir]" + exit 1 +fi + +if [ $# -gt 3 ]; then + echo "Usage ./test install_folder hysop_folder [cache_dir]" exit 1 fi @@ -18,18 +23,25 @@ fi INSTALL_DIR=$1 HYSOP_DIR=$2 -CACHE_DIR=$3 - -if [ -d "$CACHE_DIR" ]; then - echo "Cache directory '$CACHE_DIR' was found." - mkdir -p /root/.cache - cp -r $CACHE_DIR/* /root/.cache +if [ $# -eq 3 ]; then + CACHE_DIR=$3 + HAS_CACHE_DIR=true else - echo "Cache directory '$CACHE_DIR' was not found." - mkdir -p $CACHE_DIR + HAS_CACHE_DIR=false fi -export PYTHONPATH="$INSTALL_DIR/lib/python2.7/site-packages" +if [ "$HAS_CACHE_DIR" = true ]; then + if [ -d "$CACHE_DIR" ]; then + echo "Cache directory '$CACHE_DIR' was found." + mkdir -p /root/.cache + cp -r $CACHE_DIR/* /root/.cache + else + echo "Cache directory '$CACHE_DIR' was not found." + mkdir -p $CACHE_DIR + fi +fi + +export PYTHONPATH="$INSTALL_DIR/lib/python2.7/site-packages:$PYTHONPATH" python -c 'import hysop; print hysop' # long backend dependent tests @@ -49,7 +61,9 @@ python "$HYSOP_DIR/operator/tests/test_directional_advection.py" python "$HYSOP_DIR/operator/tests/test_directional_diffusion.py" python "$HYSOP_DIR/operator/tests/test_directional_stretching.py" -cp -r /root/.cache/* $CACHE_DIR/ -find $CACHE_DIR -name '*.lock' -delete +if [ "$HAS_CACHE_DIR" = true ]; then + cp -r /root/.cache/* $CACHE_DIR/ + find $CACHE_DIR -name '*.lock' -delete +fi exit 0 diff --git a/cmake/hysop_tests.cmake b/cmake/hysop_tests.cmake index 8161e359074bdd030081cbc10bbe5f53a0032697..8288fa8f9ffadb19afdfd797808e88f0c5de8f6e 100755 --- a/cmake/hysop_tests.cmake +++ b/cmake/hysop_tests.cmake @@ -96,3 +96,6 @@ foreach(testfile ${py_doctest_files}) add_test("doctest_${testName}" py.test -v --doctest-modules ${exename}) endforeach() +# Add custom target to launch continuous integration tests +add_custom_target(ci COMMAND ${CMAKE_SOURCE_DIR}/ci/scripts/test.sh ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/hysop) +