#!/bin/sh
set -efux

pys="$(py3versions -rv 2>/dev/null)"
pkgbuild=${pkgbuild:-no}

srcdir=$PWD

# These exclusions should be kept in sync with debian/rules
exclude_tests="not test_old_pickle and not test_ard_accuracyh_on_easy_problem"
if dpkg-architecture -e arm64; then
	exclude_tests="$exclude_tests and not test_dump"
fi
if dpkg-architecture -e ppc64el; then
	exclude_tests="$exclude_tests and not test_precomputed_nearest_neighbors_filtering"
	exclude_tests="$exclude_tests and not test_stacking_cv_influence"
	exclude_tests="$exclude_tests and not test_common"
	exclude_tests="$exclude_tests and not test_stacking_with_sample_weight"
fi
if dpkg-architecture -e armhf; then
	exclude_tests="$exclude_tests and not test_check_estimators_stacking_estimator"
	exclude_tests="$exclude_tests and not test_check_estimators_voting_estimator"
	exclude_tests="$exclude_tests and not test_common"
fi

for py in $pys; do
    echo "=== python$py ==="
    if [ "$pkgbuild" = "yes" ]; then
        module="$srcdir/debian/tmp/usr/lib/python3/dist-packages/sklearn"
        cd "$srcdir/build/"
    else
        module="/usr/lib/python3/dist-packages/sklearn"
        cd "$AUTOPKGTEST_TMP"
    fi

    python$py -m pytest -m 'not network' -s -v $module -k "$exclude_tests" 2>&1
done
