# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=py3-pytest-benchmark
_pkgname=pytest-benchmark
pkgver=4.0.0
pkgrel=4
pkgdesc="pytest fixture for benchmarking code"
url="https://github.com/ionelmc/pytest-benchmark"
arch="noarch"
license="BSD-2-Clause"
depends="python3 py3-pytest py3-py-cpuinfo"
makedepends="py3-gpep517 py3-setuptools py3-wheel"
checkdepends="py3-pytest-xdist py3-freezegun py3-pygal py3-pygaljs py3-elasticsearch"
subpackages="$pkgname-pyc"
source="https://github.com/ionelmc/pytest-benchmark/archive/v$pkgver/pytest-benchmark-$pkgver.tar.gz
	$pkgname-$pkgver-py3.11.patch::https://github.com/ionelmc/pytest-benchmark/commit/b2f624afd68a3090f20187a46284904dd4baa4f6.patch
	$pkgname-$pkgver-tests.patch::https://github.com/ionelmc/pytest-benchmark/commit/2b987f5be1873617f02f24cb6d76196f9aed21bd.patch
	"
builddir="$srcdir/$_pkgname-$pkgver"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl

	# disable three tests that require aspectlib (needs packaging)
	# last 2 tests fail when run inside a git repository, see: https://github.com/ionelmc/pytest-benchmark/issues/163
	PATH="$builddir/.testenv/bin:PATH" .testenv/bin/python3 -m \
		pytest tests -n auto -p no:warnings \
		--deselect tests/test_with_testcase.py::TerribleTerribleWayToWritePatchTests::test_foo2 \
		--deselect tests/test_with_weaver.py::test_weave_fixture \
		--deselect tests/test_with_weaver.py::test_weave_method \
		--deselect tests/test_utils.py::test_parse_elasticsearch_storage \
		--deselect tests/test_cli.py::test_help_compare \
		--deselect tests/test_cli.py::test_help_list \
		--deselect tests/test_cli.py::test_help_command \
		--deselect tests/test_cli.py::test_help \
		--deselect tests/test_utils.py::test_commit_info_error
}

package() {
	python3 -m installer -d "$pkgdir" .dist/*.whl
}

sha512sums="
88636e44c184f5072ad081a89f08e8838a11397e6b88298d7f235b531f894792001b858fc5c810b1399d41ec55de5db9057552fb7544fb405a04c3ba5ffbe329  pytest-benchmark-4.0.0.tar.gz
6964ba9608dc36cd75913b85bea89f8fc0925d43064aed81b57b04c8801547c270015cd73c97285da91fead46d667fe75e043e5ecd09198ba6b48830c6c26927  py3-pytest-benchmark-4.0.0-py3.11.patch
f053925aab4f615767c3cc7d4d61c6f3d15f8acc8600a50d9938181e728c03073a5a1eddf0c862e59427da8a9e22cefe0e36f4a9496391ac0178dadc3989fe05  py3-pytest-benchmark-4.0.0-tests.patch
"
