1#!/bin/bash
2
3PYTHON_TESTS="grids repeatgen straingen"
4
5function abspath() {
6  cd $1
7  echo $PWD
8}
9
10testdir=$(dirname $0)
11testdir=$(abspath $testdir)
12
13packagedir="$testdir/../../../tools/dptools"
14packagedir=$(abspath $packagedir)
15
16workdir="./"
17workdir=$(abspath $workdir)
18
19if [ $# -gt 0 ]; then
20  pythons=$*
21else
22  pythons="python"
23fi
24
25pythonpath="$packagedir/src"
26if [ -z "$PYTHONPATH" ]; then
27  export PYTHONPATH="$pythonpath"
28else
29  export PYTHONPATH="$pythonpath:$PYTHONPATH"
30fi
31
32echo $PYTHONPATH
33cd $workdir
34failed="0"
35failing_tests=""
36for python in $pythons; do
37  echo -e "\n* Testing with interpreter $python"
38  for python_test in $PYTHON_TESTS; do
39    echo -e "\n** Executing $python_test tests"
40    $python $testdir/test_${python_test}.py
41    exitcode=$?
42    if [ $exitcode != 0 ]; then
43      failed="$(($failed + 1))"
44      if [ -z "$failing_tests" ]; then
45	failing_tests="$python_test ($python)"
46      else
47	failing_tests="$failing_tests, $python_test ($python)"
48      fi
49    fi
50  done
51done
52
53echo
54echo "********************************************************************************"
55if [ $failed -gt 0 ]; then
56  echo "Failing test runs: $failed" >&2
57  echo "Failing test(s): $failing_tests" >&2
58  exit 1
59else
60  echo "All test runs finished successfully"
61  exit 0
62fi
63