Skip to content

Commit 73a79f5

Browse files
committed
hackport.cabal: Fix doctest-v2
build-tool-depends doesn't play nice with Setup.hs installs, and tries to rebuild cabal-install/doctest locally. This has recently caused some compilation errors so there is now a 'ci-depends' flag to toggle between build-tool-depends (for CI systems) and build-depends (for users with the needed tools installed to their system). This reverts commit 51bc8c1. See: gentoo-haskell/gentoo-haskell#1074 See: haskell/cabal#8434 Signed-off-by: hololeap <[email protected]>
1 parent eeb7398 commit 73a79f5

File tree

3 files changed

+30
-12
lines changed

3 files changed

+30
-12
lines changed

.github/workflows/haskell.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ jobs:
5555
- name: Configure
5656
run: |
5757
cabal update
58-
cabal configure --enable-tests --enable-benchmarks --flag=pedantic
58+
cabal configure --enable-tests --enable-benchmarks --flag=pedantic --flag=ci-depends
5959
- name: Install dependencies
6060
run: |
6161
cabal build --only-dependencies
6262
- name: Build
6363
run: cabal build
64-
- name: Run spec test
65-
run: cabal test --test-option=--color --test-show-details=streaming spec
64+
- name: Run all enabled tests
65+
run: cabal test --test-option=--color --test-show-details=streaming

hackport.cabal

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ flag profile
4444
default: False
4545
manual: True
4646

47+
flag ci-depends
48+
description: Enable build-tool-depends for use with CI systems
49+
default: False
50+
manual: True
51+
4752
-- Turn off all warnings (for external libs and doctests-v2)
4853
common no-warnings
4954
ghc-options: -Wno-default -Wno-incomplete-uni-patterns
@@ -1026,9 +1031,6 @@ test-suite doctests
10261031

10271032
test-suite doctests-v2
10281033
import: warnings
1029-
-- doctests-v2 is causing problems, looking for ghc lib and alex on
1030-
-- github CI. This may be fixable.
1031-
buildable: False
10321034
type: exitcode-stdio-1.0
10331035
default-language: Haskell98
10341036
hs-source-dirs: tests/doctests-v2
@@ -1037,9 +1039,15 @@ test-suite doctests-v2
10371039
, base
10381040
, process
10391041

1040-
build-tool-depends:
1041-
, cabal-install:cabal >=3.4
1042-
, doctest:doctest >=0.8
1042+
if flag(ci-depends)
1043+
cpp-options: -DCI_DEPENDS
1044+
build-tool-depends:
1045+
, cabal-install:cabal >=3.4
1046+
, doctest:doctest >=0.8
1047+
else
1048+
build-depends:
1049+
-- cabal-install should already be installed if this is being built...
1050+
, doctest >=0.8
10431051

10441052
if flag(cabal-v1)
10451053
buildable: False
@@ -1087,5 +1095,10 @@ test-suite spec
10871095
, time
10881096
, xml
10891097

1090-
build-tool-depends: hspec-discover:hspec-discover >=2.0
1098+
if flag(ci-depends)
1099+
cpp-options: -DCI_DEPENDS
1100+
build-tool-depends: hspec-discover:hspec-discover >=2.0
1101+
else
1102+
build-depends:
1103+
, hspec-discover
10911104
other-extensions: DeriveDataTypeable

tests/doctests-v2/Main.hs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1+
{-# LANGUAGE CPP #-}
2+
13
module Main (main) where
24

35
import Data.Foldable (for_)
46
import System.Exit (ExitCode (..), exitWith)
5-
import System.Process (readProcess, createProcess, proc, waitForProcess, getProcessExitCode)
7+
import System.Process
68

79

810
main :: IO ()
911
main = do
10-
12+
#if defined(CI_DEPENDS)
1113
doctestPath:_ <- lines <$> readProcess "cabal" ["list-bin", "doctest"] []
14+
#else
15+
let doctestPath = "/usr/bin/doctest"
16+
#endif
1217

1318
let components =
1419
[ "hackport:lib:hackport-internal"

0 commit comments

Comments
 (0)