# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Morten Linderud <foxboron@archlinux.org>
# Maintainer: Robin Candau <antiz@archlinux.org>
# Contributor: Andre Schröder <andre.schroedr at gmail dot com>
# Contributor: Jan-Erik Rediger <badboy at archlinux dot us>

pkgname=bats
pkgver=1.11.1
pkgrel=1
pkgdesc='Bash Automated Testing System'
url='https://github.com/bats-core/bats-core'
arch=(any)
license=(MIT)
depends=(
  bash
  coreutils
  ncurses
  parallel
)
checkdepends=(
  procps-ng
)
provides=(bats-core)
replaces=(bash-bats)
source=(${url}/archive/refs/tags/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha256sums=('5c57ed9616b78f7fd8c553b9bae3c7c9870119edd727ec17dbd1185c599f79d9')
b2sums=('3e64257d45344a9e0a77178a77fe9f19f65aae6bb4cbba497e6ee960cb2a1d8bbcc5078b0600024f25da5c298d075c89d1fe054ee0529fb23489af05b97c1e80')

prepare() {
  cd "bats-core-${pkgver}"
  # move everything to /usr/lib instead of /usr/libexec
  sed 's|libexec|lib|g' -i \
    bin/* \
    libexec/bats-core/* \
    lib/bats-core/* \
    test/*.bats \
    *install.sh
  mv -v libexec/bats-core/* lib/bats-core/
}

check() {
  cd "bats-core-${pkgver}"
  TERM=linux bin/bats --jobs "$(nproc)" --tap test
}

package() {
  cd "bats-core-${pkgver}"

  install -Dm 755 bin/bats -t "${pkgdir}/usr/bin"
  install -Dm 644 lib/bats-core/*.bash -t "${pkgdir}/usr/lib/bats-core"
  install -Dm 755 lib/bats-core/bats* -t "${pkgdir}/usr/lib/bats-core"

  install -Dm 644 man/bats.1 -t "${pkgdir}/usr/share/man/man1"
  install -Dm 644 man/bats.7 -t "${pkgdir}/usr/share/man/man7"
  install -Dm 644 LICENSE.md -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}"
}

# vim: ts=2 sw=2 et:
