diff --git a/cabal.project b/cabal.project index 434dfcf77..d4a92d4ac 100644 --- a/cabal.project +++ b/cabal.project @@ -6,3 +6,14 @@ packages: hledger-lib allow-newer: brick:base config-ini:containers + +-- generate a ghc environment file, needed by doctest +-- (eg: ./.ghc.environment.x86_64-darwin-8.8.3). +-- cabal 3 doesn't write these by default. +-- https://github.com/simonmichael/hledger/issues/1139 +-- https://github.com/sol/doctest/issues/245#issuecomment-583171683 +-- cabal 2 doesn't understand this flag, but it's just a warning; should be ok. +-- cabal 3 still fails with doctest the first time; you have to run it +-- a second time. Hopefully in practice it won't fail, because of a +-- preceding cabal build. +write-ghc-environment-files: always diff --git a/hledger-lib/hledger-lib.cabal b/hledger-lib/hledger-lib.cabal index 1e17a849a..d94c27757 100644 --- a/hledger-lib/hledger-lib.cabal +++ b/hledger-lib/hledger-lib.cabal @@ -4,7 +4,7 @@ cabal-version: 1.12 -- -- see: https://github.com/sol/hpack -- --- hash: 4f9a789b279703a75cecaf4e5cca835f20a5ddb9cfeb9e98e62db665a573d016 +-- hash: 3d3dab519880fdc9325ef53cd2811154ab38f1e15f6e59e3d0b2b1c935d40337 name: hledger-lib version: 1.17.0.1 @@ -199,7 +199,6 @@ test-suite doctest , transformers >=0.2 , uglymemo , utf8-string >=0.3.5 - buildable: False if (impl(ghc < 8.2)) buildable: False default-language: Haskell2010 diff --git a/hledger-lib/package.yaml b/hledger-lib/package.yaml index b332d8d6f..96f0ecc9e 100644 --- a/hledger-lib/package.yaml +++ b/hledger-lib/package.yaml @@ -164,10 +164,10 @@ tests: dependencies: - hledger-lib - # Running this test suite with cabal requires cabal exec: - # cabal exec -- cabal test hledger-lib:test:doctest + # Note when run by cabal, doctest requires a ghc environment file, + # so we ensure this is generated, see cabal.project. + # https://github.com/simonmichael/hledger/issues/1139 doctest: - buildable: false # doesn't run with cabal test, https://github.com/simonmichael/hledger/issues/1139 source-dirs: test main: doctests.hs # can't call it doctest.hs ("File name does not match module name") other-modules: [] # prevent double compilation, https://github.com/sol/hpack/issues/188