on master help sign in
Enable testing recipe
commita4151acf9efaabfc311f1871b5f94c234c184ab1 authorOleg Grenrus <oleg.grenrus@iki.fi> dateThu 25 Oct 2018, 23:16 (8 years ago) parent28f0cdb
9 files changed+36−25
.travis.yml+8−5 cabal.project+1−1 doc/cookbook/testing/Testing.lhs+7−4 doc/cookbook/testing/testing.cabal+1 servant-client-core/servant-client-core.cabal+4−4 servant-client/servant-client.cabal+5−5 servant-server/servant-server.cabal+1−1 servant/servant.cabal+4−4 stack.yaml+5−1
.travis.yml+8−5
@@ -69,11 +69,11 @@ install:
6969 - rm -fv cabal.project cabal.project.local
7070 - "if [ $HCNUMVER -ge 70800 ]; then sed -i.bak 's/-- ghc-options:.*/ghc-options: -j2/' ${HOME}/.cabal/config; fi"
7171 - grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$'
72− - "printf 'packages: \"servant\" \"servant-client\" \"servant-client-core\" \"servant-docs\" \"servant-foreign\" \"servant-server\" \"doc/tutorial\" \"doc/cookbook/basic-auth\" \"doc/cookbook/curl-mock\" \"doc/cookbook/db-postgres-pool\" \"doc/cookbook/db-sqlite-simple\" \"doc/cookbook/file-upload\" \"doc/cookbook/generic\" \"doc/cookbook/https\" \"doc/cookbook/sentry\" \"doc/cookbook/structuring-apis\" \"doc/cookbook/using-custom-monad\" \"doc/cookbook/using-free-client\"\\n' > cabal.project"
72+ - "printf 'packages: \"servant\" \"servant-client\" \"servant-client-core\" \"servant-docs\" \"servant-foreign\" \"servant-server\" \"doc/tutorial\" \"doc/cookbook/basic-auth\" \"doc/cookbook/curl-mock\" \"doc/cookbook/db-postgres-pool\" \"doc/cookbook/db-sqlite-simple\" \"doc/cookbook/file-upload\" \"doc/cookbook/generic\" \"doc/cookbook/https\" \"doc/cookbook/sentry\" \"doc/cookbook/testing\" \"doc/cookbook/structuring-apis\" \"doc/cookbook/using-custom-monad\" \"doc/cookbook/using-free-client\"\\n' > cabal.project"
7373 - "echo 'constraints: foundation >=0.0.14,memory <0.14.12 || >0.14.12' >> cabal.project"
7474 - "echo 'allow-newer: servant-auth-server:http-types,servant-auth-server:servant-server,servant-js:base, servant-pagination:servant,servant-pagination:servant-server' >> cabal.project"
7575 - touch cabal.project.local
76− - "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg | grep -vw -- servant | grep -vw -- servant-client | grep -vw -- servant-client-core | grep -vw -- servant-docs | grep -vw -- servant-foreign | grep -vw -- servant-server | grep -vw -- tutorial | grep -vw -- cookbook-basic-auth | grep -vw -- cookbook-curl-mock | grep -vw -- cookbook-db-postgres-pool | grep -vw -- cookbook-db-sqlite-simple | grep -vw -- cookbook-file-upload | grep -vw -- cookbook-generic | grep -vw -- cookbook-https | grep -vw -- cookbook-sentry | grep -vw -- cookbook-structuring-apis | grep -vw -- cookbook-using-custom-monad | grep -vw -- cookbook-using-free-client | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi"
76+ - "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg | grep -vw -- servant | grep -vw -- servant-client | grep -vw -- servant-client-core | grep -vw -- servant-docs | grep -vw -- servant-foreign | grep -vw -- servant-server | grep -vw -- tutorial | grep -vw -- cookbook-basic-auth | grep -vw -- cookbook-curl-mock | grep -vw -- cookbook-db-postgres-pool | grep -vw -- cookbook-db-sqlite-simple | grep -vw -- cookbook-file-upload | grep -vw -- cookbook-generic | grep -vw -- cookbook-https | grep -vw -- cookbook-sentry | grep -vw -- cookbook-testing | grep -vw -- cookbook-structuring-apis | grep -vw -- cookbook-using-custom-monad | grep -vw -- cookbook-using-free-client | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi"
7777 - cat cabal.project || true
7878 - cat cabal.project.local || true
7979 - if [ -f "servant/configure.ac" ]; then
@@ -121,6 +121,9 @@ install:
121121 - if [ -f "doc/cookbook/sentry/configure.ac" ]; then
122122 (cd "doc/cookbook/sentry" && autoreconf -i);
123123 fi
124+ - if [ -f "doc/cookbook/testing/configure.ac" ]; then
125+ (cd "doc/cookbook/testing" && autoreconf -i);
126+ fi
124127 - if [ -f "doc/cookbook/structuring-apis/configure.ac" ]; then
125128 (cd "doc/cookbook/structuring-apis" && autoreconf -i);
126129 fi
@@ -131,7 +134,7 @@ install:
131134 (cd "doc/cookbook/using-free-client" && autoreconf -i);
132135 fi
133136 - rm -f cabal.project.freeze
134− - rm -rf .ghc.environment.* "servant"/dist "servant-client"/dist "servant-client-core"/dist "servant-docs"/dist "servant-foreign"/dist "servant-server"/dist "doc/tutorial"/dist "doc/cookbook/basic-auth"/dist "doc/cookbook/curl-mock"/dist "doc/cookbook/db-postgres-pool"/dist "doc/cookbook/db-sqlite-simple"/dist "doc/cookbook/file-upload"/dist "doc/cookbook/generic"/dist "doc/cookbook/https"/dist "doc/cookbook/sentry"/dist "doc/cookbook/structuring-apis"/dist "doc/cookbook/using-custom-monad"/dist "doc/cookbook/using-free-client"/dist
137+ - rm -rf .ghc.environment.* "servant"/dist "servant-client"/dist "servant-client-core"/dist "servant-docs"/dist "servant-foreign"/dist "servant-server"/dist "doc/tutorial"/dist "doc/cookbook/basic-auth"/dist "doc/cookbook/curl-mock"/dist "doc/cookbook/db-postgres-pool"/dist "doc/cookbook/db-sqlite-simple"/dist "doc/cookbook/file-upload"/dist "doc/cookbook/generic"/dist "doc/cookbook/https"/dist "doc/cookbook/sentry"/dist "doc/cookbook/testing"/dist "doc/cookbook/structuring-apis"/dist "doc/cookbook/using-custom-monad"/dist "doc/cookbook/using-free-client"/dist
135138 - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
136139
137140# Here starts the actual work to be performed for the package under test;
@@ -145,11 +148,11 @@ script:
145148 - mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/
146149 - cd ${DISTDIR} || false
147150 - find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;
148− - "printf 'packages: servant-*/*.cabal servant-client-*/*.cabal servant-client-core-*/*.cabal servant-docs-*/*.cabal servant-foreign-*/*.cabal servant-server-*/*.cabal tutorial-*/*.cabal cookbook-basic-auth-*/*.cabal cookbook-curl-mock-*/*.cabal cookbook-db-postgres-pool-*/*.cabal cookbook-db-sqlite-simple-*/*.cabal cookbook-file-upload-*/*.cabal cookbook-generic-*/*.cabal cookbook-https-*/*.cabal cookbook-sentry-*/*.cabal cookbook-structuring-apis-*/*.cabal cookbook-using-custom-monad-*/*.cabal cookbook-using-free-client-*/*.cabal\\n' > cabal.project"
151+ - "printf 'packages: servant-*/*.cabal servant-client-*/*.cabal servant-client-core-*/*.cabal servant-docs-*/*.cabal servant-foreign-*/*.cabal servant-server-*/*.cabal tutorial-*/*.cabal cookbook-basic-auth-*/*.cabal cookbook-curl-mock-*/*.cabal cookbook-db-postgres-pool-*/*.cabal cookbook-db-sqlite-simple-*/*.cabal cookbook-file-upload-*/*.cabal cookbook-generic-*/*.cabal cookbook-https-*/*.cabal cookbook-sentry-*/*.cabal cookbook-testing-*/*.cabal cookbook-structuring-apis-*/*.cabal cookbook-using-custom-monad-*/*.cabal cookbook-using-free-client-*/*.cabal\\n' > cabal.project"
149152 - "echo 'constraints: foundation >=0.0.14,memory <0.14.12 || >0.14.12' >> cabal.project"
150153 - "echo 'allow-newer: servant-auth-server:http-types,servant-auth-server:servant-server,servant-js:base, servant-pagination:servant,servant-pagination:servant-server' >> cabal.project"
151154 - touch cabal.project.local
152− - "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg | grep -vw -- servant | grep -vw -- servant-client | grep -vw -- servant-client-core | grep -vw -- servant-docs | grep -vw -- servant-foreign | grep -vw -- servant-server | grep -vw -- tutorial | grep -vw -- cookbook-basic-auth | grep -vw -- cookbook-curl-mock | grep -vw -- cookbook-db-postgres-pool | grep -vw -- cookbook-db-sqlite-simple | grep -vw -- cookbook-file-upload | grep -vw -- cookbook-generic | grep -vw -- cookbook-https | grep -vw -- cookbook-sentry | grep -vw -- cookbook-structuring-apis | grep -vw -- cookbook-using-custom-monad | grep -vw -- cookbook-using-free-client | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi"
155+ - "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg | grep -vw -- servant | grep -vw -- servant-client | grep -vw -- servant-client-core | grep -vw -- servant-docs | grep -vw -- servant-foreign | grep -vw -- servant-server | grep -vw -- tutorial | grep -vw -- cookbook-basic-auth | grep -vw -- cookbook-curl-mock | grep -vw -- cookbook-db-postgres-pool | grep -vw -- cookbook-db-sqlite-simple | grep -vw -- cookbook-file-upload | grep -vw -- cookbook-generic | grep -vw -- cookbook-https | grep -vw -- cookbook-sentry | grep -vw -- cookbook-testing | grep -vw -- cookbook-structuring-apis | grep -vw -- cookbook-using-custom-monad | grep -vw -- cookbook-using-free-client | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi"
153156 - cat cabal.project || true
154157 - cat cabal.project.local || true
155158 - echo -en 'travis_fold:end:unpack\\r'
cabal.project+1−1
@@ -19,7 +19,7 @@ packages: servant/
1919 -- doc/cookbook/jwt-and-basic-auth/
2020 -- doc/cookbook/pagination
2121 doc/cookbook/sentry
22− -- doc/cookbook/testing
22+ doc/cookbook/testing
2323 doc/cookbook/structuring-apis
2424 doc/cookbook/using-custom-monad
2525 doc/cookbook/using-free-client
doc/cookbook/testing/Testing.lhs+7−4
@@ -41,6 +41,9 @@ This recipe starts with the following ingredients:
4141```haskell
4242{-# LANGUAGE OverloadedStrings, TypeFamilies, DataKinds,
4343 DeriveGeneric, TypeOperators #-}
44+import Prelude ()
45+import Prelude.Compat
46+
4447import qualified Control.Concurrent as C
4548import Control.Concurrent.MVar
4649import Control.Exception (bracket)
@@ -48,9 +51,9 @@ import Control.Lens hiding (Context)
4851import Data.Aeson
4952import Data.Aeson.Lens
5053import qualified Data.HashMap.Strict as HM
51−import Data.Text
54+import Data.Text (Text, unpack)
5255import GHC.Generics
53−import Network.HTTP.Client hiding (Proxy)
56+import Network.HTTP.Client hiding (Proxy)
5457import Network.HTTP.Types
5558import Network.Wai
5659import qualified Network.Wai.Handler.Warp as Warp
@@ -407,7 +410,7 @@ server :: IO (Server API)
407410server = do
408411 mvar <- newMVar ""
409412 return $ (\x -> liftIO $ swapMVar mvar x)
410− :<|> (liftIO $ readMVar mvar >>= return . Prelude.length)
413+ :<|> (liftIO $ readMVar mvar >>= return . length)
411414 :<|> (const $ return ())
412415```
413416
@@ -502,4 +505,4 @@ Lastly, if you want a broad overview of where your application fits in with
502505regard to best practices, consider using `servant-quickcheck`.
503506
504507This program is available as a cabal project
505−[here](https://github.com/haskell-servant/servant/tree/master/doc/cookbook/testing).
508+[here](https://github.com/haskell-servant/servant/tree/master/doc/cookbook/testing).
doc/cookbook/testing/testing.cabal+1
@@ -15,6 +15,7 @@ tested-with: GHC==8.0.2, GHC==8.2.2, GHC==8.4.4, GHC==8.6.1
1515executable cookbook-testing
1616 main-is: Testing.lhs
1717 build-depends: base == 4.*
18+ , base-compat
1819 , text >= 1.2
1920 , aeson >= 1.2
2021 , lens-aeson
servant-client-core/servant-client-core.cabal+4−4
@@ -66,7 +66,7 @@ library
6666 , base64-bytestring >= 1.0.0.1 && < 1.1
6767 , exceptions >= 0.10.0 && < 0.11
6868 , free >= 5.0.2 && < 5.2
69− , generics-sop >= 0.3.2.0 && < 0.4
69+ , generics-sop >= 0.4.0.1 && < 0.5
7070 , http-api-data >= 0.3.8.1 && < 0.4
7171 , http-media >= 0.7.1.2 && < 0.8
7272 , http-types >= 0.12.1 && < 0.13
@@ -94,9 +94,9 @@ test-suite spec
9494
9595 -- Additonal dependencies
9696 build-depends:
97− deepseq >= 1.3.0.2 && <1.5
98− , hspec >= 2.4.1 && <2.6
99− , QuickCheck >= 2.11.3 && < 2.12
97+ deepseq >= 1.3.0.2 && < 1.5
98+ , hspec >= 2.4.1 && < 2.6
99+ , QuickCheck >= 2.12.6.1 && < 2.13
100100
101101 build-tool-depends:
102102 hspec-discover:hspec-discover >= 2.5.1 && <2.6
servant-client/servant-client.cabal+5−5
@@ -100,11 +100,11 @@ test-suite spec
100100
101101 -- Additonal dependencies
102102 build-depends:
103− generics-sop >= 0.3.2.0 && < 0.4
104− , hspec >= 2.5.1 && < 2.6
105− , HUnit >= 1.6 && < 1.7
106− , network >= 2.6.3.2 && < 2.8
107− , QuickCheck >= 2.10.1 && < 2.12
103+ generics-sop >= 0.4.0.1 && < 0.5
104+ , hspec >= 2.5.1 && < 2.6
105+ , HUnit >= 1.6 && < 1.7
106+ , network >= 2.8.0.0 && < 2.9
107+ , QuickCheck >= 2.12.6.1 && < 2.13
108108 , servant == 0.14.*
109109 , servant-server == 0.14.*
110110
servant-server/servant-server.cabal+1−1
@@ -164,7 +164,7 @@ test-suite spec
164164 , directory >= 1.2.1.0 && < 1.4
165165 , hspec >= 2.5.1 && < 2.6
166166 , hspec-wai >= 0.9.0 && < 0.10
167− , QuickCheck >= 2.11.3 && < 2.12
167+ , QuickCheck >= 2.12.6.1 && < 2.13
168168 , should-not-typecheck >= 2.1.0 && < 2.2
169169 , temporary >= 1.3 && < 1.4
170170 , wai-extra >= 3.0.21.0 && < 3.1
servant/servant.cabal+4−4
@@ -146,10 +146,10 @@ test-suite spec
146146
147147 -- Additonal dependencies
148148 build-depends:
149− aeson-compat >= 0.3.8 && < 0.4
150− , hspec >= 2.5.4 && < 2.6
151− , QuickCheck >= 2.11.3 && < 2.12
152− , quickcheck-instances >= 0.3.18 && < 0.4
149+ aeson-compat >= 0.3.8 && < 0.4
150+ , hspec >= 2.5.4 && < 2.6
151+ , QuickCheck >= 2.12.6.1 && < 2.13
152+ , quickcheck-instances >= 0.3.19 && < 0.4
153153
154154 build-tool-depends:
155155 hspec-discover:hspec-discover >= 2.5.4 && < 2.6
stack.yaml+5−1
@@ -1,5 +1,5 @@
11# Let's try to keep resolver at the first day of the month
2−resolver: nightly-2018-07-08
2+resolver: nightly-2018-09-28 # Last nightly with GHC-8.4.3
33packages:
44- servant-client/
55- servant-client-core/
@@ -10,3 +10,7 @@ packages:
1010
1111# allow-newer: true # ignores all bounds, that's a sledgehammer
1212# - doc/tutorial/
13+
14+extra-deps:
15+- generics-sop-0.4.0.1
16+- sop-core-0.4.0.0