Skip to content

Use cabal-doctest only during CI #365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@ install:
- rm -fv cabal.project.local
- "echo 'packages: .' > cabal.project"
- rm -f cabal.project.freeze
- cabal install hspec-discover
- cabal install cabal-doctest
- cabal new-build -w ${HC} ${TEST} ${BENCH} --dep -j2 all
- cabal new-build -w ${HC} --disable-tests --disable-benchmarks --dep -j2 all
- cabal v2-build -w ${HC} ${TEST} ${BENCH} --dep -j2 all
- cabal v2-build -w ${HC} --disable-tests --disable-benchmarks --dep -j2 all

# Here starts the actual work to be performed for the package under test;
# any command which exits with a non-zero exit code causes the build to fail.
Expand All @@ -88,13 +86,13 @@ script:
- "echo 'packages: .' > cabal.project"
# this builds all libraries and executables (without tests/benchmarks)
- rm -f cabal.project.freeze
- cabal new-build -w ${HC} --disable-tests --disable-benchmarks all
- cabal v2-build -w ${HC} --disable-tests --disable-benchmarks all
# this builds all libraries and executables (including tests/benchmarks)
# - rm -rf ./dist-newstyle

# build & run tests
- cabal new-build -w ${HC} ${TEST} ${BENCH} all

- if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} all; fi
- ../../enable_doctest.sh
- cabal v2-build -w ${HC} ${TEST} ${BENCH} all
- if [ "x$TEST" = "x--enable-tests" ]; then cabal v2-test -w ${HC} ${TEST} all; fi

# EOF
10 changes: 4 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,15 @@ install:
- "cabal --version"
- "ghc --version"
- "cabal %CABOPTS% update -vverbose+nowrap"
- "cabal %CABOPTS% install hspec-discover"
- "cabal %CABOPTS% install cabal-doctest"

build: off
deploy: off

test_script:
- IF EXIST configure.ac bash -c "autoreconf -i"
- "cabal %CABOPTS% new-build -j1 -vnormal+nowrap --dry all"
- "cabal %CABOPTS% v2-build -j1 -vnormal+nowrap --dry all"
- ps: Push-AppveyorArtifact dist-newstyle\cache\plan.json
- "cabal %CABOPTS% new-build -j1 -vnormal+nowrap all"
- IF "%DOCTEST%"=="YES" (set TESTSUITE=all) ELSE (set TESTSUITE=network:test:spec)
- "cabal %CABOPTS% new-test -j1 -vnormal+nowrap %TESTSUITE%"
- "cabal %CABOPTS% v2-build -j1 -vnormal+nowrap all"
- IF "%DOCTEST%"=="YES" bash enable_doctest.sh
- "cabal %CABOPTS% v2-test -j1 -vnormal+nowrap all"
- ps: ls network*.log -recurse | %{ Push-AppveyorArtifact $_}
15 changes: 13 additions & 2 deletions Setup.hs → enable_doctest.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
#!/bin/sh

sed -i~ '/^library/i\
custom-setup { setup-depends: base, Cabal >= 2, cabal-doctest >=1.0.6 && <1.1 }
' network.cabal
sed -i~ 's/^build-type:.*$/build-type: Custom/' network.cabal
sed -i~ 's/buildable: False/buildable: True/' network.cabal

cat > Setup.hs <<EOF
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -Wall #-}
module Main (main) where
Expand All @@ -20,8 +29,8 @@ main = defaultMainAutoconfWithDoctests "doctests"
--
-- Probably we are running cabal sdist, when otherwise using new-build
-- workflow
#warning You are configuring this package without cabal-doctest installed. \
The doctests test-suite will not work as a result. \
#warning You are configuring this package without cabal-doctest installed. \\
The doctests test-suite will not work as a result. \\
To fix this, install cabal-doctest before configuring.
#endif

Expand All @@ -31,3 +40,5 @@ main :: IO ()
main = defaultMain

#endif
EOF

14 changes: 8 additions & 6 deletions network.cabal
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cabal-version: 1.18
name: network
version: 3.0.0.0
license: BSD3
Expand Down Expand Up @@ -28,8 +29,7 @@ description:
> library
> build-depends: network-uri-flag
category: Network
build-type: Custom
cabal-version: >=1.10
build-type: Configure
extra-tmp-files:
config.log config.status autom4te.cache network.buildinfo
include/HsNetworkConfig.h
Expand All @@ -50,9 +50,6 @@ tested-with: GHC == 7.8.4
, GHC == 8.4.4
, GHC == 8.6.2

custom-setup
setup-depends: base, Cabal, cabal-doctest >=1.0.6 && <1.1

library
default-language: Haskell2010
exposed-modules:
Expand Down Expand Up @@ -122,15 +119,20 @@ test-suite spec
SimpleSpec
type: exitcode-stdio-1.0
ghc-options: -Wall -threaded
-- NB: make sure to versions of hspec and hspec-discover
-- that work together; easiest way is to constraint
-- both packages to a small enough version range.
build-tools: hspec-discover == 2.6.*
build-depends:
base >= 4.7 && < 5,
bytestring,
directory,
HUnit,
network,
hspec
hspec == 2.6.*

test-suite doctests
buildable: False
default-language: Haskell2010
hs-source-dirs: tests
main-is: doctests.hs
Expand Down