# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Carl Smedstad <carsme@archlinux.org>

pkgname=python-zope-testrunner
pkgver=8.2
pkgrel=1
pkgdesc="Zope testrunner script"
arch=('any')
url="https://github.com/zopefoundation/zope.testrunner"
license=('ZPL-2.1')
depends=(
  'python'
  'python-setuptools'
  'python-zope-exceptions'
  'python-zope-interface'
)
makedepends=(
  'git'
  'python-build'
  'python-installer'
  'python-wheel'
)
# NOTE: Causes circular dependency as python-zope-testing depends on this
# package.
checkdepends=('python-zope-testing')
source=("$pkgname::git+$url.git#tag=$pkgver")
b2sums=('07894afb1b751a43629ae8f2ab124d79acd592c383ee1aaba4f3f547b5daced02cb23b7898622b0d08d0374e3f2983652f364472393c261f714522eae7970359')

prepare() {
  cd $pkgname
  # Remove test file with invalid Python syntax, breaks installation.
  rm src/zope/testrunner/tests/testrunner-ex/sample2/badsyntax.py
}

build() {
  cd $pkgname
  python -m build --wheel --no-isolation --skip-dependency-check
}

check() {
  cd $pkgname
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl
  test-env/bin/zope-testrunner -vc --test-path src/
}

package() {
  cd $pkgname
  python -m installer --destdir="$pkgdir" dist/*.whl
}
