#!/bin/sh
# Run the upstream unit tests against the installed openshot_qt package.
# Some tests read fixtures from the source tree and find it through setup.py
# above the module, so lay out the installed module the way the build does.
set -eu

src=$(pwd)
cd "$AUTOPKGTEST_TMP"
cp -a /usr/lib/python3/dist-packages/openshot_qt openshot_qt
ln -s openshot_qt src   # fixtures read src/... relative to setup.py
for f in "$src"/* "$src"/.[!.]*; do
	[ -e "$f" ] || continue
	case "${f##*/}" in src|debian|.pc|.git) ;; *) cp -a "$f" . ;; esac
done

export HOME="$AUTOPKGTEST_TMP/home" QT_QPA_PLATFORM=offscreen OPENSHOT_QT_API=pyqt6
mkdir -p "$HOME"
cd openshot_qt
PYTHONPATH="$AUTOPKGTEST_TMP/openshot_qt:$AUTOPKGTEST_TMP" \
	timeout 3600 "$src/debian/run-unit-tests" python3
