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

pkgname=python-flaky
pkgver=3.8.1
pkgrel=2
pkgdesc='Plugin for nose or py.test that automatically reruns flaky tests'
arch=('any')
license=('Apache')
url='https://github.com/box/flaky'
depends=('python')
makedepends=('git' 'python-setuptools')
checkdepends=('python-pytest')
source=("git+https://github.com/box/flaky.git#tag=v$pkgver")
sha512sums=('43e3479659daa5a67449bd9defb2ffab71232fcfc7d876e4e3ef1540932203a7357b35a200b69f735b93105aaacc6d84d31d842fd9b0f412a3498b39a7e4102b')

build() {
  cd flaky
  python setup.py build
}

check() {
  # Hack entry points by installing it

  cd flaky
  python setup.py install --root="$PWD/tmp_install" --optimize=1
  (
    export PYTHONPATH="$PWD/tmp_install/usr/lib/python3.12/site-packages:$PYTHONPATH"
    py.test -k 'example and not options' --doctest-modules test/test_pytest/
    py.test -p no:flaky test/test_pytest/test_flaky_pytest_plugin.py
    py.test --force-flaky --max-runs 2 test/test_pytest/test_pytest_options_example.py
  )
}

package() {
  cd flaky
  python setup.py install --root="$pkgdir" --optimize=1
}

# vim:set ts=2 sw=2 et:
