#!/bin/sh

set -ue

# Copying and patching tests

rsync -av python/test/ ${AUTOPKGTEST_TMP}
patch ${AUTOPKGTEST_TMP}/test_spglib.py debian/patches/fix-tests.patch

# Running the tests

for i in ${AUTOPKGTEST_TMP}/test_*.py
do
    echo $i:
    python3 $i 2>&1
done | tee ${AUTOPKGTEST_TMP}/test.log

# Examining the results

if grep --silent ^FAILED ${AUTOPKGTEST_TMP}/test.log
then
    echo Failed tests exist
    exit 1
fi
