[pkg] Run all unit tests in autopkgtest
We previously forgot to copy `tox.ini` alongside the tests. As this
file configures pytest pattern matching rules, we were not running
quite a few tests. This is now fixed.
The added tests required some adjustments in the Debian dependencies.
Sadly, not all tests currently pass. It seems there are some ordering
dependencies between the tests in regards to how data are loaded.
Fixing this probably would probably be better debugged by ensuring
the test suite does not fail when using pytest random-order plugin.
#!/bin/sh
set -e
set -x
### Setup tests
find cubicweb -type d -name 'test' -a '!' -wholename 'cubicweb/skeleton/*' | while read dir; do
mkdir -p "$AUTOPKGTEST_TMP"/$(dirname "$dir")
cp -r "$dir" "$AUTOPKGTEST_TMP/$dir"
cp tox.ini "$AUTOPKGTEST_TMP"
done
chown -R nobody:nogroup "$AUTOPKGTEST_TMP"
### Find PostgreSQL binaries
POSTGRESQL_BINDIR=$(find /usr/lib/postgresql -type f -name 'initdb' -printf "%h\n" | head -n 1)
test "$POSTGRESQL_BINDIR" || { echo "Unable to find 'initdb'" >&2; exit 1; }
### Run tests
for py in $(py3versions -r 2>/dev/null); do
cd "$AUTOPKGTEST_TMP"
echo "Testing with $py:"
su nobody --shell /bin/sh \
-c "env PATH='$PATH:$POSTGRESQL_BINDIR' $py -m pytest -v"
done