# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=emacs-plz
pkgver=0.9.1
pkgrel=0
_pkgreal=plz
pkgdesc="HTTP library with curl as backend"
url="https://github.com/alphapapa/plz.el"
arch="noarch"
license="GPL-3.0-or-later"
depends="cmd:curl cmd:emacs"
makedepends="emacs-nox"
source="https://github.com/alphapapa/plz.el/archive/v$pkgver/emacs-plz-$pkgver.tar.gz"
builddir="$srcdir/plz.el-$pkgver"
options="net" # tests access httpbin.org

build() {
	emacs -batch -q -no-site-file -L . \
		-eval '(setq byte-compile-error-on-warn t)' \
		-f batch-byte-compile \
		./*.el
}

check() {
	# Tests may fail due to network issues, try to repeat 3 times.
	local i; for i in $(seq 0 3); do
		[ $i -eq 0 ] || msg "Retrying ($i/3)..."
		emacs -batch -q -no-site-file -L . -L tests -l test-plz \
			-eval '(setq plz-test-uri-prefix "https://httpbin.org")' \
			-f ert-run-tests-batch-and-exit && return 0
		sleep 1
	done
	return 1
}

package() {
	install -Dvm644 ./*.el ./*.elc \
		-t "$pkgdir"/usr/share/emacs/site-lisp/plz/

	cd "$pkgdir"/usr/share/emacs/site-lisp/plz
	emacs -batch -q -no-site-file \
		-eval "(loaddefs-generate \".\" \"$_pkgreal-loaddefs.el\")"
}

sha512sums="
6e35e34accfba52428176345bfd07e1146587aed662c5df4443ba16ca02558a1137dc17ce7906d6e3ff296eb628ecca702d0f1595e504f0e102d4fb411ed295c  emacs-plz-0.9.1.tar.gz
"
