# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem      1.0
PortGroup       github 1.0

github.setup    bats-core bats-core 1.14.0 v
revision        0
categories      sysutils
platforms       any
supported_archs noarch
license         MIT
maintainers     {gmail.com:jrjsmrtn @jrjsmrtn} openmaintainer
description     Bash Automated Testing System
long_description \
    Bats is a TAP-compliant testing framework for Bash. It provides a simple way to \
    verify that the UNIX programs you write behave as expected.

github.tarball_from archive

checksums       rmd160  9b16cd72e113b5e1c8cecb2af6a184ecc0e57f74 \
                sha256  bb537b70b15b732f6d8827dd6578e3d8ce166636ce1f18ea9a074184fcce9177 \
                size    183385

patchfiles      patch-libexec-bats.diff \
                patch-test-timeout.diff

depends_run     port:bash \
                port:parallel

# Libraries such as bats-assert install under ${prefix}/lib/bats, where
# bats_load_library finds them; upstream's default is /usr/lib/bats.
post-patch {
    set f ${worksrcpath}/libexec/bats-core/bats
    reinplace "s|BATS_LIB_PATH-/usr/lib/bats\}|BATS_LIB_PATH-${prefix}/lib/bats\}|" ${f}
    set fd [open ${f}]
    set src [read ${fd}]
    close ${fd}
    if {[string first "BATS_LIB_PATH-${prefix}/lib/bats\}" ${src}] < 0} {
        return -code error "the default BATS_LIB_PATH was not patched"
    }
}

use_configure   no
build           {}

# test from bats-core github action
# depends_test            port:parallel
test.cmd                ./bin/bats
test.pre_args-prepend   --formatter tap --print-output-on-failure
test.env                TERM=linux
test.run                yes
destroot.cmd            ./install.sh
destroot.args           ${destroot}${prefix} lib
destroot.target-delete  install
