#!/bin/sh
set -efu

export LANG=C.UTF-8
export LC_ALL=C.UTF-8

if [ -z "$AUTOPKGTEST_TMP" ]; then
    AUTOPKGTEST_TMP=tmp
    mkdir -p "$AUTOPKGTEST_TMP"
fi

SRCDIR=$(pwd)

# Copy the tests and required assets
cp -rv "$SRCDIR"/tests "$AUTOPKGTEST_TMP"
cp -v "$SRCDIR"/examples/guizero_flash.gif "$AUTOPKGTEST_TMP"/tests
cp -v "$SRCDIR"/examples/guizero.gif "$AUTOPKGTEST_TMP"/tests
cp -v "$SRCDIR"/examples/guizero.jpg "$AUTOPKGTEST_TMP"/tests
cp -v "$SRCDIR"/examples/guizero.png "$AUTOPKGTEST_TMP"/tests

cd "$AUTOPKGTEST_TMP"

for py in $(py3versions -s); do
    xvfb-run -a $py -m pytest
done
