#!/bin/sh
#
# This autopkgtest runs only specific test files instead of the full
# suite, as upstream test suite is very time consuming.

set -e -u

TEST_FILES="test_base.py test_cases.py test_scipy.py test_rosetta.py test_numpy_func3.py"
# * test_base: basic tests.
# * test_cases: suggested by upstream [1].
# * test_scipy: suggested during initial sponsorship, for scipy/numpy
#   coverage.
# * test_rosetta: suggested during initial sponsorship, for additional
#   user-oriented coverage.
# * test_numpy_func3: suggested during initial sponsorship, for
#   additional blas-specific coverage.
#
# [1] https://github.com/serge-sans-paille/pythran/issues/908#issuecomment-945378742

# Additionally, some tests are excluded manually, based on the output
# of "pytest --durations=0".
TEST_SELECTOR="not test__rbfinterp and not test_shallow_water and not test_compute_subpix_2d_gaussian2"

cd pythran/tests

# test_rosetta contains hard-coded references to a file relative to the
# package directory.
sed -i 's|pythran/tests/rosetta/read_conf.cfg|rosetta/read_conf.cfg|g' rosetta/*

for py in $(py3versions -s 2>/dev/null); do
    echo "Running testsuite with $py:"
    for test_file in $TEST_FILES; do
        $py -m pytest $test_file -k "${TEST_SELECTOR}"
    done
done
