git.iko.soy/typeable/cabal2nix
on master help sign in
Run doctests on Travis, not via Cabal.
commit44bfcd9c5d99c4896fa95327c6d5723a6361d3cd authorPeter Simons <simons@cryp.to> dateFri 19 Jan 2018, 16:58 (9 years ago) parent44c4b3c
4 files changed+13−64
.travis.yml+10−6 Setup.hs+1−29 cabal2nix.cabal+2−19 test/doctests.hs−10
.travis.yml+10−6
@@ -1,6 +1,6 @@
11# This Travis job script has been generated by a script via
22#
3−# runghc make_travis_yml_2.hs '-o' '.travis.yml' 'cabal2nix.cabal'
3+# runghc make_travis_yml_2.hs '--doctest' '--doctest-options=-i ../dist-newstyle/build/*/*/cabal2nix-*/build/autogen' '--hlint' '-o' '.travis.yml' 'cabal2nix.cabal'
44#
55# For more information, see https://github.com/hvr/multi-ghc-travis
66#
@@ -28,9 +28,6 @@ before_cache:
2828
2929matrix:
3030 include:
31− - compiler: "ghc-8.2.1"
32− # env: TEST=--disable-tests BENCH=--disable-benchmarks
33− addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.1], sources: [hvr-ghc]}}
3431 - compiler: "ghc-8.2.2"
3532 # env: TEST=--disable-tests BENCH=--disable-benchmarks
3633 addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.2], sources: [hvr-ghc]}}
@@ -57,6 +54,8 @@ install:
5754 - "sed -i.bak 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config"
5855 - rm -fv cabal.project cabal.project.local
5956 - grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$'
57+ - if [ $HCNUMVER -ge 80000 ]; then cabal new-install -w ${HC} --symlink-bindir=$HOME/.local/bin doctest --constraint='doctest ==0.13.*'; fi
58+ - if [ $HCNUMVER -eq 80202 ]; then cabal new-install -w ${HC} --symlink-bindir=$HOME/.local/bin hlint --constraint='hlint ==2.0.*'; fi
6059 - "printf 'packages: \".\"\\n' > cabal.project"
6160 - cat cabal.project
6261 - if [ -f "./configure.ac" ]; then
@@ -86,7 +85,12 @@ script:
8685
8786 # build & run tests, build benchmarks
8887 - cabal new-build -w ${HC} ${TEST} ${BENCH} all
89− - if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} ${BENCH} all; fi
88+
89+ # doctest
90+ - if [ $HCNUMVER -ge 80000 ]; then (cd cabal2nix-* && doctest -i ../dist-newstyle/build/*/*/cabal2nix-*/build/autogen src); fi
91+
92+ # hlint
93+ - if [ $HCNUMVER -eq 80202 ]; then (cd cabal2nix-* && hlint src); fi
9094
9195 # cabal check
9296 - (cd cabal2nix-* && cabal check)
@@ -95,5 +99,5 @@ script:
9599 - rm -rf ./dist-newstyle
96100 - if $HADDOCK; then cabal new-haddock -w ${HC} ${TEST} ${BENCH} all; else echo "Skipping haddock generation";fi
97101
98−# REGENDATA ["-o",".travis.yml","cabal2nix.cabal"]
102+# REGENDATA ["--doctest","--doctest-options=-i ../dist-newstyle/build/*/*/cabal2nix-*/build/autogen","--hlint","-o",".travis.yml","cabal2nix.cabal"]
99103# EOF
Setup.hs+1−29
@@ -1,34 +1,6 @@
1−{-# LANGUAGE CPP #-}
2−{-# OPTIONS_GHC -Wall #-}
3−
4−module Main ( main ) where
5−
6−#ifndef MIN_VERSION_cabal_doctest
7−#define MIN_VERSION_cabal_doctest(x,y,z) 0
8−#endif
9−
10−#if MIN_VERSION_cabal_doctest(1,0,0)
11−
12−import Distribution.Extra.Doctest ( defaultMainWithDoctests )
13−main :: IO ()
14−main = defaultMainWithDoctests "doctests"
15−
16−#else
17−
18−#ifdef MIN_VERSION_Cabal
19−-- If the macro is defined, we have new cabal-install,
20−-- but for some reason we don't have cabal-doctest in package-db
21−--
22−-- Probably we are running cabal sdist, when otherwise using new-build
23−-- workflow
24−#warning You are configuring this package without cabal-doctest installed. \
25− The doctests test-suite will not work as a result. \
26− To fix this, install cabal-doctest before configuring.
27−#endif
1+module Main (main) where
282
293import Distribution.Simple
304
315main :: IO ()
326main = defaultMain
33−
34−#endif
cabal2nix.cabal+2−19
@@ -75,8 +75,8 @@ author: Peter Simons,
7575maintainer: Peter Simons <simons@cryp.to>
7676license: BSD3
7777license-file: LICENSE
78−tested-with: GHC > 8.2 && < 8.3
79−build-type: Custom
78+tested-with: GHC == 8.2.2
79+build-type: Simple
8080cabal-version: 1.24
8181
8282extra-source-files:
@@ -86,12 +86,6 @@ source-repository head
8686 type: git
8787 location: https://github.com/nixos/cabal2nix
8888
89−custom-setup
90− setup-depends:
91− Cabal
92− , base >=4 && <5
93− , cabal-doctest >=1 && <1.1
94−
9589library
9690 hs-source-dirs:
9791 src
@@ -176,14 +170,3 @@ executable hackage2nix
176170 Paths_cabal2nix
177171 HackageGit
178172 default-language: Haskell2010
179−
180−test-suite doctests
181− type: exitcode-stdio-1.0
182− main-is: doctests.hs
183− other-modules:
184− Paths_cabal2nix
185− hs-source-dirs:
186− test
187− ghc-options: -Wall -threaded
188− build-depends: base, doctest
189− default-language: Haskell2010
test/doctests.hsdeleted−10
@@ -1,10 +0,0 @@
1−module Main where
2−
3−import Build_doctests (flags, pkgs, module_sources)
4−import Data.Foldable (traverse_)
5−import Test.DocTest (doctest)
6−
7−main :: IO ()
8−main = do let args = flags ++ pkgs ++ module_sources
9− traverse_ putStrLn args -- optionally print arguments
10− doctest args