Merge pull request #1062 from phadej/enable-testing-recipe

Enable testing recipe
This commit is contained in:
Oleg Grenrus 2018-10-26 13:01:52 +03:00 committed by GitHub
commit 56c2f4eda3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 36 additions and 25 deletions

View file

@ -69,11 +69,11 @@ install:
- rm -fv cabal.project cabal.project.local - rm -fv cabal.project cabal.project.local
- "if [ $HCNUMVER -ge 70800 ]; then sed -i.bak 's/-- ghc-options:.*/ghc-options: -j2/' ${HOME}/.cabal/config; fi" - "if [ $HCNUMVER -ge 70800 ]; then sed -i.bak 's/-- ghc-options:.*/ghc-options: -j2/' ${HOME}/.cabal/config; fi"
- grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$' - grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$'
- "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" - "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"
- "echo 'constraints: foundation >=0.0.14,memory <0.14.12 || >0.14.12' >> cabal.project" - "echo 'constraints: foundation >=0.0.14,memory <0.14.12 || >0.14.12' >> cabal.project"
- "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" - "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"
- touch cabal.project.local - touch cabal.project.local
- "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" - "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"
- cat cabal.project || true - cat cabal.project || true
- cat cabal.project.local || true - cat cabal.project.local || true
- if [ -f "servant/configure.ac" ]; then - if [ -f "servant/configure.ac" ]; then
@ -121,6 +121,9 @@ install:
- if [ -f "doc/cookbook/sentry/configure.ac" ]; then - if [ -f "doc/cookbook/sentry/configure.ac" ]; then
(cd "doc/cookbook/sentry" && autoreconf -i); (cd "doc/cookbook/sentry" && autoreconf -i);
fi fi
- if [ -f "doc/cookbook/testing/configure.ac" ]; then
(cd "doc/cookbook/testing" && autoreconf -i);
fi
- if [ -f "doc/cookbook/structuring-apis/configure.ac" ]; then - if [ -f "doc/cookbook/structuring-apis/configure.ac" ]; then
(cd "doc/cookbook/structuring-apis" && autoreconf -i); (cd "doc/cookbook/structuring-apis" && autoreconf -i);
fi fi
@ -131,7 +134,7 @@ install:
(cd "doc/cookbook/using-free-client" && autoreconf -i); (cd "doc/cookbook/using-free-client" && autoreconf -i);
fi fi
- rm -f cabal.project.freeze - rm -f cabal.project.freeze
- 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 - 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
- DISTDIR=$(mktemp -d /tmp/dist-test.XXXX) - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
# Here starts the actual work to be performed for the package under test; # Here starts the actual work to be performed for the package under test;
@ -145,11 +148,11 @@ script:
- mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/ - mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/
- cd ${DISTDIR} || false - cd ${DISTDIR} || false
- find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \; - find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;
- "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" - "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"
- "echo 'constraints: foundation >=0.0.14,memory <0.14.12 || >0.14.12' >> cabal.project" - "echo 'constraints: foundation >=0.0.14,memory <0.14.12 || >0.14.12' >> cabal.project"
- "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" - "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"
- touch cabal.project.local - touch cabal.project.local
- "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" - "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"
- cat cabal.project || true - cat cabal.project || true
- cat cabal.project.local || true - cat cabal.project.local || true
- echo -en 'travis_fold:end:unpack\\r' - echo -en 'travis_fold:end:unpack\\r'

View file

@ -19,7 +19,7 @@ packages: servant/
-- doc/cookbook/jwt-and-basic-auth/ -- doc/cookbook/jwt-and-basic-auth/
-- doc/cookbook/pagination -- doc/cookbook/pagination
doc/cookbook/sentry doc/cookbook/sentry
-- doc/cookbook/testing doc/cookbook/testing
doc/cookbook/structuring-apis doc/cookbook/structuring-apis
doc/cookbook/using-custom-monad doc/cookbook/using-custom-monad
doc/cookbook/using-free-client doc/cookbook/using-free-client

View file

@ -41,6 +41,9 @@ This recipe starts with the following ingredients:
```haskell ```haskell
{-# LANGUAGE OverloadedStrings, TypeFamilies, DataKinds, {-# LANGUAGE OverloadedStrings, TypeFamilies, DataKinds,
DeriveGeneric, TypeOperators #-} DeriveGeneric, TypeOperators #-}
import Prelude ()
import Prelude.Compat
import qualified Control.Concurrent as C import qualified Control.Concurrent as C
import Control.Concurrent.MVar import Control.Concurrent.MVar
import Control.Exception (bracket) import Control.Exception (bracket)
@ -48,9 +51,9 @@ import Control.Lens hiding (Context)
import Data.Aeson import Data.Aeson
import Data.Aeson.Lens import Data.Aeson.Lens
import qualified Data.HashMap.Strict as HM import qualified Data.HashMap.Strict as HM
import Data.Text import Data.Text (Text, unpack)
import GHC.Generics import GHC.Generics
import Network.HTTP.Client hiding (Proxy) import Network.HTTP.Client hiding (Proxy)
import Network.HTTP.Types import Network.HTTP.Types
import Network.Wai import Network.Wai
import qualified Network.Wai.Handler.Warp as Warp import qualified Network.Wai.Handler.Warp as Warp
@ -407,7 +410,7 @@ server :: IO (Server API)
server = do server = do
mvar <- newMVar "" mvar <- newMVar ""
return $ (\x -> liftIO $ swapMVar mvar x) return $ (\x -> liftIO $ swapMVar mvar x)
:<|> (liftIO $ readMVar mvar >>= return . Prelude.length) :<|> (liftIO $ readMVar mvar >>= return . length)
:<|> (const $ return ()) :<|> (const $ return ())
``` ```
@ -502,4 +505,4 @@ Lastly, if you want a broad overview of where your application fits in with
regard to best practices, consider using `servant-quickcheck`. regard to best practices, consider using `servant-quickcheck`.
This program is available as a cabal project This program is available as a cabal project
[here](https://github.com/haskell-servant/servant/tree/master/doc/cookbook/testing). [here](https://github.com/haskell-servant/servant/tree/master/doc/cookbook/testing).

View file

@ -15,6 +15,7 @@ tested-with: GHC==8.0.2, GHC==8.2.2, GHC==8.4.4, GHC==8.6.1
executable cookbook-testing executable cookbook-testing
main-is: Testing.lhs main-is: Testing.lhs
build-depends: base == 4.* build-depends: base == 4.*
, base-compat
, text >= 1.2 , text >= 1.2
, aeson >= 1.2 , aeson >= 1.2
, lens-aeson , lens-aeson

View file

@ -66,7 +66,7 @@ library
, base64-bytestring >= 1.0.0.1 && < 1.1 , base64-bytestring >= 1.0.0.1 && < 1.1
, exceptions >= 0.10.0 && < 0.11 , exceptions >= 0.10.0 && < 0.11
, free >= 5.0.2 && < 5.2 , free >= 5.0.2 && < 5.2
, generics-sop >= 0.3.2.0 && < 0.4 , generics-sop >= 0.4.0.1 && < 0.5
, http-api-data >= 0.3.8.1 && < 0.4 , http-api-data >= 0.3.8.1 && < 0.4
, http-media >= 0.7.1.2 && < 0.8 , http-media >= 0.7.1.2 && < 0.8
, http-types >= 0.12.1 && < 0.13 , http-types >= 0.12.1 && < 0.13
@ -94,9 +94,9 @@ test-suite spec
-- Additonal dependencies -- Additonal dependencies
build-depends: build-depends:
deepseq >= 1.3.0.2 && <1.5 deepseq >= 1.3.0.2 && < 1.5
, hspec >= 2.4.1 && <2.6 , hspec >= 2.4.1 && < 2.6
, QuickCheck >= 2.11.3 && < 2.12 , QuickCheck >= 2.12.6.1 && < 2.13
build-tool-depends: build-tool-depends:
hspec-discover:hspec-discover >= 2.5.1 && <2.6 hspec-discover:hspec-discover >= 2.5.1 && <2.6

View file

@ -100,11 +100,11 @@ test-suite spec
-- Additonal dependencies -- Additonal dependencies
build-depends: build-depends:
generics-sop >= 0.3.2.0 && < 0.4 generics-sop >= 0.4.0.1 && < 0.5
, hspec >= 2.5.1 && < 2.6 , hspec >= 2.5.1 && < 2.6
, HUnit >= 1.6 && < 1.7 , HUnit >= 1.6 && < 1.7
, network >= 2.6.3.2 && < 2.8 , network >= 2.8.0.0 && < 2.9
, QuickCheck >= 2.10.1 && < 2.12 , QuickCheck >= 2.12.6.1 && < 2.13
, servant == 0.14.* , servant == 0.14.*
, servant-server == 0.14.* , servant-server == 0.14.*

View file

@ -164,7 +164,7 @@ test-suite spec
, directory >= 1.2.1.0 && < 1.4 , directory >= 1.2.1.0 && < 1.4
, hspec >= 2.5.1 && < 2.6 , hspec >= 2.5.1 && < 2.6
, hspec-wai >= 0.9.0 && < 0.10 , hspec-wai >= 0.9.0 && < 0.10
, QuickCheck >= 2.11.3 && < 2.12 , QuickCheck >= 2.12.6.1 && < 2.13
, should-not-typecheck >= 2.1.0 && < 2.2 , should-not-typecheck >= 2.1.0 && < 2.2
, temporary >= 1.3 && < 1.4 , temporary >= 1.3 && < 1.4
, wai-extra >= 3.0.21.0 && < 3.1 , wai-extra >= 3.0.21.0 && < 3.1

View file

@ -146,10 +146,10 @@ test-suite spec
-- Additonal dependencies -- Additonal dependencies
build-depends: build-depends:
aeson-compat >= 0.3.8 && < 0.4 aeson-compat >= 0.3.8 && < 0.4
, hspec >= 2.5.4 && < 2.6 , hspec >= 2.5.4 && < 2.6
, QuickCheck >= 2.11.3 && < 2.12 , QuickCheck >= 2.12.6.1 && < 2.13
, quickcheck-instances >= 0.3.18 && < 0.4 , quickcheck-instances >= 0.3.19 && < 0.4
build-tool-depends: build-tool-depends:
hspec-discover:hspec-discover >= 2.5.4 && < 2.6 hspec-discover:hspec-discover >= 2.5.4 && < 2.6

View file

@ -1,5 +1,5 @@
# Let's try to keep resolver at the first day of the month # Let's try to keep resolver at the first day of the month
resolver: nightly-2018-07-08 resolver: nightly-2018-09-28 # Last nightly with GHC-8.4.3
packages: packages:
- servant-client/ - servant-client/
- servant-client-core/ - servant-client-core/
@ -10,3 +10,7 @@ packages:
# allow-newer: true # ignores all bounds, that's a sledgehammer # allow-newer: true # ignores all bounds, that's a sledgehammer
# - doc/tutorial/ # - doc/tutorial/
extra-deps:
- generics-sop-0.4.0.1
- sop-core-0.4.0.0