# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit dune edo git-r3

DESCRIPTION="Assemble and manage fully vendored Dune repositories"
HOMEPAGE="https://github.com/tarides/opam-monorepo"
EGIT_REPO_URI="https://github.com/tarides/${PN}.git"

LICENSE="ISC"
SLOT="0/${PV}"
IUSE="+ocamlopt test"
RESTRICT="test"
PROPERTIES="test_network"

RDEPEND="dev-ml/opam:0=[ocamlopt?]"
BDEPEND="virtual/pkgconfig"

src_test() {
	# tests invoke opam-monorepo, which requires an initialized OPAM root
	# and a named current switch (path switch is not recognized)
	export OPAMROOT="${T}/opam"
	edo git config --global user.email "you@example.com"
	edo git config --global user.name "Your Name"
	edo opam init --bare -n --no-opamrc --disable-sandboxing
	edo opam switch create "portage" ocaml-system --yes
	dune_src_test
}