Skip to content

Commit 524b072

Browse files
committed
Change build-type: Simple; run doctests on CI via haskell-ci
Don't use hspec-discover in tutorial, so doctests work on CI
1 parent ec0cd8a commit 524b072

File tree

15 files changed

+72
-200
lines changed

15 files changed

+72
-200
lines changed

.travis.yml

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# For more information, see https://github.com/haskell-CI/haskell-ci
66
#
7-
# version: 0.9.20191209
7+
# version: 0.9.20200110
88
#
99
version: ~> 1.0
1010
language: c
@@ -73,26 +73,8 @@ before_install:
7373
- TOP=$(pwd)
7474
- "HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')"
7575
- echo $HCNUMVER
76-
- CABAL="$CABAL -vnormal+nowrap+markoutput"
76+
- CABAL="$CABAL -vnormal+nowrap"
7777
- set -o pipefail
78-
- |
79-
echo 'function blue(s) { printf "\033[0;34m" s "\033[0m " }' >> .colorful.awk
80-
echo 'BEGIN { state = "output"; }' >> .colorful.awk
81-
echo '/^-----BEGIN CABAL OUTPUT-----$/ { state = "cabal" }' >> .colorful.awk
82-
echo '/^-----END CABAL OUTPUT-----$/ { state = "output" }' >> .colorful.awk
83-
echo '!/^(-----BEGIN CABAL OUTPUT-----|-----END CABAL OUTPUT-----)/ {' >> .colorful.awk
84-
echo ' if (state == "cabal") {' >> .colorful.awk
85-
echo ' print blue($0)' >> .colorful.awk
86-
echo ' } else {' >> .colorful.awk
87-
echo ' print $0' >> .colorful.awk
88-
echo ' }' >> .colorful.awk
89-
echo '}' >> .colorful.awk
90-
- cat .colorful.awk
91-
- |
92-
color_cabal_output () {
93-
awk -f $TOP/.colorful.awk
94-
}
95-
- echo text | color_cabal_output
9678
install:
9779
- ${CABAL} --version
9880
- echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
@@ -133,8 +115,9 @@ install:
133115
- cat $CABALHOME/config
134116
- rm -fv cabal.project cabal.project.local cabal.project.freeze
135117
- travis_retry ${CABAL} v2-update -v
136-
- if $GHCJS ; then (cd /tmp && ${CABAL} v2-install -w ghc-8.4.4 cabal-plan --constraint='cabal-plan ^>=0.6.0.0' --constraint='cabal-plan +exe' | color_cabal_output) ; fi
137-
- if $GHCJS ; then (cd /tmp && ${CABAL} v2-install -w ghc-8.4.4 hspec-discover | color_cabal_output) ; fi
118+
- if ! $GHCJS ; then (cd /tmp && ${CABAL} v2-install $WITHCOMPILER -j2 doctest --constraint='doctest ==0.16.2.*') ; fi
119+
- if $GHCJS ; then (cd /tmp && ${CABAL} v2-install -w ghc-8.4.4 cabal-plan --constraint='cabal-plan ^>=0.6.0.0' --constraint='cabal-plan +exe') ; fi
120+
- if $GHCJS ; then (cd /tmp && ${CABAL} v2-install -w ghc-8.4.4 hspec-discover) ; fi
138121
# Generate cabal.project
139122
- rm -rf cabal.project cabal.project.local cabal.project.freeze
140123
- touch cabal.project
@@ -212,14 +195,14 @@ install:
212195
- if [ -f "doc/cookbook/structuring-apis/configure.ac" ]; then (cd "doc/cookbook/structuring-apis" && autoreconf -i); fi
213196
- if [ -f "doc/cookbook/using-custom-monad/configure.ac" ]; then (cd "doc/cookbook/using-custom-monad" && autoreconf -i); fi
214197
- if [ -f "doc/cookbook/using-free-client/configure.ac" ]; then (cd "doc/cookbook/using-free-client" && autoreconf -i); fi
215-
- ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH} | color_cabal_output
198+
- ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH}
216199
- "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'"
217200
- rm cabal.project.freeze
218201
script:
219202
- DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
220203
# Packaging...
221204
- echo 'Packaging...' && echo -en 'travis_fold:start:sdist\\r'
222-
- ${CABAL} v2-sdist all | color_cabal_output
205+
- ${CABAL} v2-sdist all
223206
- echo -en 'travis_fold:end:sdist\\r'
224207
# Unpacking...
225208
- echo 'Unpacking...' && echo -en 'travis_fold:start:unpack\\r'
@@ -335,15 +318,29 @@ script:
335318
# Building with tests and benchmarks...
336319
- echo 'Building with tests and benchmarks...' && echo -en 'travis_fold:start:build-everything\\r'
337320
# build & run tests, build benchmarks
338-
- ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output
321+
- ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} all
339322
- echo -en 'travis_fold:end:build-everything\\r'
340323
# Testing...
341-
- if ! $GHCJS ; then ${CABAL} v2-test $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output ; fi
324+
- if ! $GHCJS ; then ${CABAL} v2-test $WITHCOMPILER ${TEST} ${BENCH} all ; fi
342325
- if $GHCJS ; then cabal-plan list-bins '*:test:*' | while read -r line; do testpkg=$(echo "$line" | perl -pe 's/:.*//'); testexe=$(echo "$line" | awk '{ print $2 }'); echo "testing $textexe in package $textpkg"; (cd "$(pkgdir $testpkg)" && nodejs "$testexe".jsexe/all.js); done ; fi
326+
# Doctest...
327+
- echo 'Doctest...' && echo -en 'travis_fold:start:doctest\\r'
328+
- perl -i -e 'while (<ARGV>) { print unless /package-id\s+(base-compat-batteries)-\d+(\.\d+)*/; }' .ghc.environment.*
329+
- if ! $GHCJS ; then (cd ${PKGDIR_servant} && doctest src) ; fi
330+
- if ! $GHCJS ; then (cd ${PKGDIR_servant_client} && doctest src) ; fi
331+
- if ! $GHCJS ; then (cd ${PKGDIR_servant_client_core} && doctest src) ; fi
332+
- if ! $GHCJS ; then (cd ${PKGDIR_servant_http_streams} && doctest src) ; fi
333+
- if ! $GHCJS ; then (cd ${PKGDIR_servant_docs} && doctest src) ; fi
334+
- if ! $GHCJS ; then (cd ${PKGDIR_servant_foreign} && doctest src) ; fi
335+
- if ! $GHCJS ; then (cd ${PKGDIR_servant_server} && doctest src) ; fi
336+
- if ! $GHCJS ; then (cd ${PKGDIR_servant_machines} && doctest src) ; fi
337+
- if ! $GHCJS ; then (cd ${PKGDIR_servant_conduit} && doctest src) ; fi
338+
- if ! $GHCJS ; then (cd ${PKGDIR_servant_pipes} && doctest src) ; fi
339+
- echo -en 'travis_fold:end:doctest\\r'
343340
# haddock...
344341
- echo 'haddock...' && echo -en 'travis_fold:start:haddock\\r'
345-
- if ! $GHCJS ; then ${CABAL} v2-haddock $WITHCOMPILER --with-haddock $HADDOCK ${TEST} ${BENCH} all | color_cabal_output ; fi
342+
- if ! $GHCJS ; then ${CABAL} v2-haddock $WITHCOMPILER --with-haddock $HADDOCK ${TEST} ${BENCH} all ; fi
346343
- echo -en 'travis_fold:end:haddock\\r'
347344

348-
# REGENDATA ("0.9.20191209",["--config=cabal.haskell-ci","--output=.travis.yml","cabal.project"])
345+
# REGENDATA ("0.9.20200110",["--config=cabal.haskell-ci","--output=.travis.yml","cabal.project"])
349346
# EOF

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,13 @@ build-ghcjs :
2020

2121
packdeps :
2222
packdeps */*.cabal
23+
24+
doctest : doctest-servant doctest-servant-server
25+
perl -i -e 'while (<ARGV>) { print unless /package-id\s+base-compat-\d+(\.\d+)*/; }' .ghc.environment.*
26+
27+
doctest-servant :
28+
(cd servant && doctest src)
29+
(cd servant && doctest test/Servant/LinksSpec.hs)
30+
31+
doctest-servant-server :
32+
(cd servant-server && doctest src)

cabal.haskell-ci

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ branches: master
44
jobs-selection: any
55
google-chrome: True
66
ghcjs-tests: True
7+
doctest: True
8+
doctest-filter-packages: base-compat-batteries
9+
doctest-skip: tutorial
710

811
-- https://github.com/haskell/cabal/issues/6176
912
ghcjs-tools: hspec-discover

cabal.project

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,6 @@ allow-newer: jsaddle-dom-0.9.3.2:lens
7676
allow-newer: jsaddle-warp-0.9.6.0:time
7777

7878
constraints: base-compat ^>=0.11
79+
80+
-- needed for doctests
81+
write-ghc-environment-files: always

changelog.d/pr1249

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
synopsis: use queryString to parse QueryParam, QueryParams and QueryFlag
22
packages: servant-server
3-
prs: #1249
3+
prs: #1249 #1262
4+
significance: significant
45
description: {
56

67
Some APIs need query parameters rewriting, e.g. in order to support

changelog.d/pr1263

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
synopsis: Make packages `build-type: Simple`
2+
packages: servant servant-server
3+
prs: #1263
4+
significance: significant
5+
description: {
6+
7+
We used `build-type: Custom`, but it's problematic e.g.
8+
for cross-compiling. The benefit is small, as the doctests
9+
can be run other ways too (though not so conviniently).
10+
11+
}

doc/tutorial/test/Spec.hs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
1+
module Main where
2+
3+
import qualified JavascriptSpec
4+
5+
import Test.Hspec (Spec, hspec, describe)
6+
7+
main :: IO ()
8+
main = hspec spec
9+
10+
spec :: Spec
11+
spec = describe "Javascript" JavascriptSpec.spec

doc/tutorial/tutorial.cabal

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ test-suite spec
8383
hs-source-dirs: test
8484
main-is: Spec.hs
8585
other-modules: JavascriptSpec
86-
build-tool-depends:
87-
hspec-discover:hspec-discover
8886
build-depends: base
8987
, tutorial
9088
, hspec

servant-server/Setup.hs

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,2 @@
1-
{-# LANGUAGE CPP #-}
2-
{-# OPTIONS_GHC -Wall #-}
3-
module Main (main) where
4-
5-
#ifndef MIN_VERSION_cabal_doctest
6-
#define MIN_VERSION_cabal_doctest(x,y,z) 0
7-
#endif
8-
9-
#if MIN_VERSION_cabal_doctest(1,0,0)
10-
11-
import Distribution.Extra.Doctest ( defaultMainWithDoctests )
12-
main :: IO ()
13-
main = defaultMainWithDoctests "doctests"
14-
15-
#else
16-
17-
#ifdef MIN_VERSION_Cabal
18-
-- If the macro is defined, we have new cabal-install,
19-
-- but for some reason we don't have cabal-doctest in package-db
20-
--
21-
-- Probably we are running cabal sdist, when otherwise using new-build
22-
-- workflow
23-
#warning You are configuring this package without cabal-doctest installed. \
24-
The doctests test-suite will not work as a result. \
25-
To fix this, install cabal-doctest before configuring.
26-
#endif
27-
28-
import Distribution.Simple
29-
30-
main :: IO ()
1+
import Distribution.Simple
312
main = defaultMain
32-
33-
#endif

servant-server/servant-server.cabal

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ license-file: LICENSE
2222
author: Servant Contributors
2323
maintainer: [email protected]
2424
copyright: 2014-2016 Zalora South East Asia Pte Ltd, 2016-2019 Servant Contributors
25-
build-type: Custom
25+
build-type: Simple
2626
tested-with:
2727
GHC ==8.0.2
2828
|| ==8.2.2
@@ -38,12 +38,6 @@ source-repository head
3838
type: git
3939
location: http://github.com/haskell-servant/servant.git
4040

41-
custom-setup
42-
setup-depends:
43-
base >= 4 && <5,
44-
Cabal,
45-
cabal-doctest >= 1.0.6 && <1.1
46-
4741
library
4842
exposed-modules:
4943
Servant
@@ -173,16 +167,3 @@ test-suite spec
173167

174168
build-tool-depends:
175169
hspec-discover:hspec-discover >= 2.6.0 && <2.8
176-
177-
test-suite doctests
178-
build-depends:
179-
base
180-
, servant-server
181-
, doctest >= 0.16.0 && <0.17
182-
type: exitcode-stdio-1.0
183-
main-is: test/doctests.hs
184-
buildable: True
185-
default-language: Haskell2010
186-
ghc-options: -Wall -threaded
187-
if impl(ghc >= 8.2)
188-
x-doctest-options: -fdiagnostics-color=never

0 commit comments

Comments
 (0)