commit:     d8791e9c56f660b15ca89f04dba85add4d5c15d3
Author:     hololeap <hololeap <AT> users <DOT> noreply <DOT> github <DOT> com>
AuthorDate: Fri Aug 12 03:47:58 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Aug 21 02:21:44 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d8791e9c

dev-haskell/parser-combinators: Fix tests

Make creation of temporary GHC package DB conditional

Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../parser-combinators-1.3.0.ebuild                | 27 +++++++++++-----------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/dev-haskell/parser-combinators/parser-combinators-1.3.0.ebuild 
b/dev-haskell/parser-combinators/parser-combinators-1.3.0.ebuild
index fc3e4a9d5cb2..7c57fcc85c7d 100644
--- a/dev-haskell/parser-combinators/parser-combinators-1.3.0.ebuild
+++ b/dev-haskell/parser-combinators/parser-combinators-1.3.0.ebuild
@@ -9,18 +9,16 @@ EAPI=8
 CABAL_FEATURES="lib profile haddock hoogle hscolour test-suite"
 inherit haskell-cabal
 
-TESTS_PN="${PN}-tests"
-TESTS_P="${TESTS_PN}-${PV}"
+TESTS_PN="${CABAL_PN}-tests"
+TESTS_P="${TESTS_PN}-${CABAL_PV}"
 
 DESCRIPTION="Lightweight package providing commonly useful parser combinators"
 HOMEPAGE="https://github.com/mrkkrp/parser-combinators";
-SRC_URI="https://hackage.haskell.org/package/${P}/${P}.tar.gz
-       https://hackage.haskell.org/package/${TESTS_P}/${TESTS_P}.tar.gz";
+SRC_URI+=" https://hackage.haskell.org/package/${TESTS_P}/${TESTS_P}.tar.gz";
 
 LICENSE="BSD"
 SLOT="0/${PV}"
 KEYWORDS="~amd64 ~ppc64 ~x86"
-RESTRICT="test" # tests only work if not already installed
 
 RDEPEND=">=dev-lang/ghc-8.6.3:=
 "
@@ -41,18 +39,21 @@ src_configure() {
 
 src_test() {
        if use test; then
-               ./setup register --inplace --gen-pkg-config || die
-               ghc-pkg init pkgdb || die
-               ghc-pkg -f pkgdb register "${P}.conf"
+               local -a configure_flags=( "--flag=-dev" )
 
-               old_S="${S}"
+               # Runs the block if the main package is not installed currently
+               if ! ghc-pkg describe "${CABAL_PN}" &>/dev/null; then
+                       ./setup register --inplace --gen-pkg-config || die
+                       ghc-pkg init pkgdb || die
+                       ghc-pkg -f pkgdb register "${CABAL_P}.conf" || die
+                       configure_flags+=( "--package-db=${S}/pkgdb" )
+               fi
+
+               local old_S="${S}"
                export S="${WORKDIR}/${TESTS_P}"
                pushd "${S}" > /dev/null || die
 
-               haskell-cabal_src_configure \
-                       --package-db="${old_S}/pkgdb" \
-                       --flag=-dev
-
+               haskell-cabal_src_configure "${configure_flags[@]}"
                haskell-cabal_src_compile
                haskell-cabal_src_test
 

Reply via email to