commit: 3ecb7ee883bbeb1fa5fc00f26439f650b767ed10
parent 8de979b07dc4ef1e51e2e5540c5a6c0554d776db
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Mon, 2 Oct 2023 03:14:33 +0200
dev-go/sys: Add ability to run tests
Diffstat:
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/dev-go/sys/sys-0.12.0.ebuild b/dev-go/sys/sys-0.12.0.ebuild
@@ -13,8 +13,32 @@ LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64"
+IUSE="test"
+
+RESTRICT="!test? ( test )"
+
+DEPEND="test? ( dev-lang/go )"
+
+src_prepare() {
+ default
+
+ mkdir -p "$(dirname "${WORKDIR}/src/${EGO_PN}")" || die
+ mv "${S}/${P}" "${WORKDIR}/src/${EGO_PN}" || die
+}
+
+src_test() {
+ # disable module-aware mode
+ export GO111MODULE=off
+
+ # With GO111MODULE=off WORKDIR needs to be included
+ export GOPATH="${WORKDIR}:${EPREFIX}/usr/lib/go-gentoo"
+
+ # `go test` doesn't recurses in directories by itself
+ go test "${EGO_PN}/cpu" "${EGO_PN}/execabs" "${EGO_PN}/unix" || die
+}
+
src_install() {
- mkdir -p "$(dirname "${ED}/usr/lib/go-gentoo/src/${EGO_PN}")" || die
- cp -r "${P}" "${ED}/usr/lib/go-gentoo/src/${EGO_PN}" || die
+ mkdir -p "${ED}/usr/lib/go-gentoo/" || die
+ cp -r "${WORKDIR}/src" "${ED}/usr/lib/go-gentoo/src" || die
test -f "${ED}/usr/lib/go-gentoo/src/${EGO_PN}/go.mod" || die
}