#!/bin/bash

# setuptools-scm's heuristics fail to determine the package version
# which causes the test suite to fail, so just override it

SETUPTOOLS_SCM_PRETEND_VERSION=$(dpkg-parsechangelog \
                                        | sed -rne 's/^Version: ([0-9.]+)[-+].*$$/\1/p')
export SETUPTOOLS_SCM_PRETEND_VERSION

# pytest will try to run the 'tests' it finds in the quilt patches, so
# delete the .pc directory to avoid that
rm -r .pc

# We must filter harmless output from stderr, or adt-run will consider
# the test to have failed

# This technique from: http://tldp.org/LDP/abs/html/io-redirection.html

okay="zip_safe flag not set; analyzing archive contents..."

exec 3>&1
python3 setup.py test 2>&1 >&3 3>&- | grep -v "$okay" 3>&-
exec 3>&-
