# -*- 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-file 0.4.0 v
github.tarball_from archive
revision            0

categories          sysutils devel
platforms           any
supported_archs     noarch
# CC0 1.0, a public-domain dedication; MacPorts has no CC0 license name.
license             public-domain
maintainers         {@jrjsmrtn gmail.com:jrjsmrtn} openmaintainer

description         Filesystem assertions for Bats
long_description    bats-file is a helper library providing common filesystem related \
                    assertions for Bats, such as assert_file_exists.

checksums           rmd160  b6fcb474431d822c020a77fddaddf6b714bcef48 \
                    sha256  9b69043241f3af1c2d251f89b4fcafa5df3f05e97b89db18d7c9bdf5731bb27a \
                    size    22770

depends_run         port:bats-support

use_configure       no
build               {}

# Where bats-core's bats_load_library looks: bats_load_library bats-file.
destroot {
    set dir ${destroot}${prefix}/lib/bats/${name}
    xinstall -d ${dir} ${destroot}${prefix}/share/doc/${name}
    xinstall -m 0644 ${worksrcpath}/load.bash ${dir}
    copy ${worksrcpath}/src ${dir}
    xinstall -m 0644 ${worksrcpath}/README.md ${worksrcpath}/LICENSE \
        ${destroot}${prefix}/share/doc/${name}
}

depends_test        port:bats-core \
                    port:bats-support
test.run            yes
test.cmd            ${prefix}/bin/bats

# Left out, as the build environment cannot run them: the device-file (54, 55)
# and owner (59) tests run sudo, which the test phase may not; the setgid tests
# (62) need the build user in the fixture's group; and the socket tests (57)
# bind a socket in the work directory, whose 104-byte path is over macOS's
# AF_UNIX limit.
pre-test {
    set tests {}
    foreach f [lsort [glob -tails -directory ${worksrcpath} test/*.bats]] {
        if {![regexp {^test/(54|55|57|59|62)-} ${f}]} {
            lappend tests ${f}
        }
    }
    test.target {*}${tests}
}
