#!/bin/sh

set -e
set -x


export OSLO_PACKAGE_VERSION=$(dpkg-parsechangelog -SVersion | sed -e 's/^[[:digit:]]*://' -e 's/[-].*//' -e 's/~git.*//' -e 's/~bpo.*//' -e 's/~/.0/' -e 's/+dfsg1//' -e 's/+ds1//' -e 's/~/.0/' | head -n 1)
export PBR_VERSION=$(dpkg-parsechangelog -SVersion | sed -e 's/^[[:digit:]]*://' -e 's/[-].*//' -e 's/~git.*//' -e 's/~bpo.*//' -e 's/~/.0/' -e 's/+dfsg1//' -e 's/+ds1//' -e 's/~/.0/' | head -n 1)

pkgos-dh_auto_install --no-py2 --in-tmp
for PYVER in $(py3versions -rv 2>/dev/null); do
	PYTHONPATH=`pwd`/debian/tmp/usr/lib/python3/dist-packages \
	PYTHON=python$PYVER \
	python$PYVER -m pytest -Wignore -Wignore::pytest.PytestCollectionWarning --ignore tests/unit/test_pytest_launcher.py tests/unit -k 'not test_all_plugins_have_docstrings and not test_schema_is_valid and not test_schema_is_valid and not test_plugins_loaded'
done
