Skip to content

Commit

Permalink
hackport.cabal: Fix doctest-v2
Browse files Browse the repository at this point in the history
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 <hololeap@users.noreply.github.com>
  • Loading branch information
hololeap committed May 27, 2023
1 parent eeb7398 commit 73a79f5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ jobs:
- name: Configure
run: |
cabal update
cabal configure --enable-tests --enable-benchmarks --flag=pedantic
cabal configure --enable-tests --enable-benchmarks --flag=pedantic --flag=ci-depends
- name: Install dependencies
run: |
cabal build --only-dependencies
- name: Build
run: cabal build
- name: Run spec test
run: cabal test --test-option=--color --test-show-details=streaming spec
- name: Run all enabled tests
run: cabal test --test-option=--color --test-show-details=streaming
27 changes: 20 additions & 7 deletions hackport.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ flag profile
default: False
manual: True

flag ci-depends
description: Enable build-tool-depends for use with CI systems
default: False
manual: True

-- Turn off all warnings (for external libs and doctests-v2)
common no-warnings
ghc-options: -Wno-default -Wno-incomplete-uni-patterns
Expand Down Expand Up @@ -1026,9 +1031,6 @@ test-suite doctests

test-suite doctests-v2
import: warnings
-- doctests-v2 is causing problems, looking for ghc lib and alex on
-- github CI. This may be fixable.
buildable: False
type: exitcode-stdio-1.0
default-language: Haskell98
hs-source-dirs: tests/doctests-v2
Expand All @@ -1037,9 +1039,15 @@ test-suite doctests-v2
, base
, process

build-tool-depends:
, cabal-install:cabal >=3.4
, doctest:doctest >=0.8
if flag(ci-depends)
cpp-options: -DCI_DEPENDS
build-tool-depends:
, cabal-install:cabal >=3.4
, doctest:doctest >=0.8
else
build-depends:
-- cabal-install should already be installed if this is being built...
, doctest >=0.8

if flag(cabal-v1)
buildable: False
Expand Down Expand Up @@ -1087,5 +1095,10 @@ test-suite spec
, time
, xml

build-tool-depends: hspec-discover:hspec-discover >=2.0
if flag(ci-depends)
cpp-options: -DCI_DEPENDS
build-tool-depends: hspec-discover:hspec-discover >=2.0
else
build-depends:
, hspec-discover
other-extensions: DeriveDataTypeable
9 changes: 7 additions & 2 deletions tests/doctests-v2/Main.hs
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
{-# LANGUAGE CPP #-}

module Main (main) where

import Data.Foldable (for_)
import System.Exit (ExitCode (..), exitWith)
import System.Process (readProcess, createProcess, proc, waitForProcess, getProcessExitCode)
import System.Process


main :: IO ()
main = do

#if defined(CI_DEPENDS)
doctestPath:_ <- lines <$> readProcess "cabal" ["list-bin", "doctest"] []
#else
let doctestPath = "/usr/bin/doctest"
#endif

let components =
[ "hackport:lib:hackport-internal"
Expand Down

0 comments on commit 73a79f5

Please sign in to comment.