#!/bin/bash

# ensure that a test suite failure is registered
set -e
set -o pipefail

# 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 -SVersion \
                                        | cut -d- -f1)
export SETUPTOOLS_SCM_PRETEND_VERSION

# 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>&-
