git.iko.soy/servant-quickcheck
on master help sign in
Merge pull request #16 from haskell-servant/ghc8-support

Ghc8 support

commit2411e2966ce6bd5e0f906e5d3d0695ec9453d484 authorJulian Arni <jkarni@gmail.com> dateWed 14 Sep 2016, 10:53 (10 years ago) parent343f55f0337996
9 files changed+96−60
.travis.yml+8−14 CHANGELOG.md−5 CHANGELOG.yaml+47 servant-quickcheck.cabal+10−6 src/Servant/QuickCheck/Internal/HasGenRequest.hs+15 src/Servant/QuickCheck/Internal/Predicates.hs+2−2 stack-ghc-8.0.1.yaml+10 stack.yaml+2−31 test/Servant/QuickCheck/InternalSpec.hs+2−2
.travis.yml+8−14
@@ -2,22 +2,16 @@ sudo: false
22
33language: c
44
5−env:
6− - GHCVER=7.10.2
7−
8−addons:
9− apt:
10− sources:
11− - hvr-ghc
12− packages:
13− - ghc-7.10.2
14− - cabal-install-1.22
15− - libgmp-dev
16− - wrk
5+matrix:
6+ include:
7+ - env: CABALVER=1.22 GHCVER=7.10.1
8+ addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.1],sources: [hvr-ghc]}}
9+ - env: CABALVER=1.24 GHCVER=8.0.1
10+ addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1], sources: [hvr-ghc]}}
1711
1812install:
1913 - (mkdir -p $HOME/.local/bin && cd $HOME/.local/bin && wget https://zalora-public.s3.amazonaws.com/tinc && chmod +x tinc)
20− - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/1.22/bin:$PATH
14+ - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
2115 - ghc --version
2216 - cabal --version
2317 - travis_retry cabal update
@@ -25,7 +19,7 @@ install:
2519
2620script:
2721 - tinc && cabal configure --enable-tests && cabal build && cabal test
28− #- (cd doc && tinc cabal configure --enable-tests && cabal build && cabal test)
22+ - cabal check
2923
3024cache:
3125 directories:
CHANGELOG.mddeleted−5
@@ -1,5 +0,0 @@
1−# 0.0.1.0
2−
3−- Better error messages. Error messages now contain failing predicate, failing
4−response and (except for response predicates), failing requests.
5−- Significant changes to RequestPredicate and ResponsePredicate types.
CHANGELOG.yamlnew file+47
@@ -0,0 +1,47 @@
1+upcoming:
2+
3+ changes:
4+
5+ - description: Update CHANGELOG to YAML syntax.
6+ pr: 16
7+ authors: jkarni
8+ date: 2016-09-14
9+
10+ - description: Support new CaptureAll combinator
11+ pr: 16
12+ authors: jkarni
13+ date: 2016-09-14
14+
15+ - description: Support GHC 8
16+ pr: 16
17+ authors: jkarni
18+ date: 2016-09-14
19+
20+
21+
22+releases:
23+
24+ - version: "0.0.1.1"
25+ changes:
26+
27+ - description: Exclude GHC 7.8 (by bumping base lower bound to 4.8)
28+ pr: none
29+ authors: jkarni
30+
31+ - description: More generous bounds for other packages.
32+ pr: none
33+ authors: jkarni
34+
35+ - version: "0.0.1.0"
36+ changes:
37+
38+ - description: Better error messages.
39+ notes: >
40+ Error messages now contain failing predicate, failing response and
41+ (except for response predicates), failing requests.
42+ pr: none
43+ authors: jkarni
44+
45+ - description: Signicant changes to RequestPredicate and ResponsePredicate types.
46+ pr: none
47+ authors: jkarni
servant-quickcheck.cabal+10−6
@@ -1,5 +1,5 @@
11name: servant-quickcheck
2−version: 0.0.1.0
2+version: 0.0.1.1
33synopsis: QuickCheck entire APIs
44description:
55 This packages provides QuickCheck properties that are tested across an entire
@@ -13,7 +13,11 @@ category: Web
1313build-type: Simple
1414cabal-version: >=1.10
1515extra-source-files:
16− CHANGELOG.md
16+ CHANGELOG.yaml
17+
18+source-repository head
19+ type: git
20+ location: https://github.com/haskell-servant/servant-quickcheck
1721
1822flag long-tests
1923 description: Run more QuickCheck tests
@@ -27,19 +31,19 @@ library
2731 , Servant.QuickCheck.Internal.QuickCheck
2832 , Servant.QuickCheck.Internal.Equality
2933 , Servant.QuickCheck.Internal.ErrorTypes
30− build-depends: base >=4.8 && <4.9
34+ build-depends: base >=4.8 && <4.10
3135 , base-compat == 0.9.*
3236 , aeson > 0.8 && < 0.12
3337 , bytestring == 0.10.*
3438 , case-insensitive == 1.2.*
35− , data-default-class == 0.0.*
39+ , data-default-class >= 0.0 && < 0.2
3640 , hspec == 2.2.*
37− , http-client == 0.4.*
41+ , http-client >= 0.4.30 && < 0.5
3842 , http-media == 0.6.*
3943 , http-types > 0.8 && < 0.10
4044 , mtl > 2.1 && < 2.3
4145 , pretty == 1.1.*
42− , process == 1.2.*
46+ , process >= 1.2 && < 1.5
4347 , QuickCheck > 2.7 && < 2.9
4448 , servant > 0.6 && < 0.9
4549 , servant-client > 0.6 && < 0.9
src/Servant/QuickCheck/Internal/HasGenRequest.hs+15
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE PolyKinds #-}
23module Servant.QuickCheck.Internal.HasGenRequest where
34
@@ -5,6 +6,7 @@ import Data.Default.Class (def)
56import Data.Monoid ((<>))
67import Data.String (fromString)
78import Data.String.Conversions (cs)
9+import qualified Data.ByteString as BS
810import GHC.TypeLits (KnownSymbol, Nat, symbolVal)
911import Network.HTTP.Client (Request, RequestBody (..), host, method, path,
1012 port, queryString, requestBody, requestHeaders,
@@ -44,6 +46,19 @@ instance (Arbitrary c, HasGenRequest b, ToHttpApiData c )
4446 old = genRequest (Proxy :: Proxy b)
4547 new = arbitrary :: Gen c
4648
49+#if MIN_VERSION_servant(0,8,0)
50+instance (Arbitrary c, HasGenRequest b, ToHttpApiData c )
51+ => HasGenRequest (CaptureAll x c :> b) where
52+ genRequest _ = do
53+ old' <- old
54+ new' <- fmap (cs . toUrlPiece) <$> new
55+ let new'' = BS.intercalate "/" new'
56+ return $ \burl -> let r = old' burl in r { path = new'' <> path r }
57+ where
58+ old = genRequest (Proxy :: Proxy b)
59+ new = arbitrary :: Gen [c]
60+#endif
61+
4762instance (Arbitrary c, KnownSymbol h, HasGenRequest b, ToHttpApiData c)
4863 => HasGenRequest (Header h c :> b) where
4964 genRequest _ = do
src/Servant/QuickCheck/Internal/Predicates.hs+2−2
@@ -14,7 +14,7 @@ import Data.Monoid ((<>))
1414import GHC.Generics (Generic)
1515import Network.HTTP.Client (Manager, Request, Response, httpLbs,
1616 method, requestHeaders, responseBody,
17− responseHeaders, parseUrl, responseStatus)
17+ responseHeaders, parseRequest, responseStatus)
1818import Network.HTTP.Media (matchAccept)
1919import Network.HTTP.Types (methodGet, methodHead, parseMethod,
2020 renderStdMethod, status100, status200,
@@ -92,7 +92,7 @@ createContainsValidLocation
9292 if responseStatus resp == status201
9393 then case lookup "Location" $ responseHeaders resp of
9494 Nothing -> fail n
95− Just l -> case parseUrl $ SBSC.unpack l of
95+ Just l -> case parseRequest $ SBSC.unpack l of
9696 Nothing -> fail n
9797 Just x -> do
9898 resp2 <- httpLbs x mgr
stack-ghc-8.0.1.yamlnew file+10
@@ -0,0 +1,10 @@
1+# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
2+resolver: nightly-2016-09-07
3+packages:
4+- '.'
5+extra-deps:
6+- 'servant-0.8.1'
7+- 'servant-server-0.8.1'
8+- 'servant-client-0.8.1'
9+flags: {}
10+extra-package-dbs: []
stack.yaml+2−31
@@ -1,36 +1,7 @@
11# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
2−resolver: nightly-2016-04-20
3−
4−# Local packages, usually specified by relative directory name
2+resolver: lts-6.17
53packages:
64- '.'
7−
8−# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)
9−extra-deps:
10−- servant-0.8
11−- servant-client-0.8
12−- servant-server-0.8
13−
14−# Override default flag values for local packages and extra-deps
5+extra-deps: []
156flags: {}
16−
17−# Extra package databases containing global packages
187extra-package-dbs: []
19−
20−# Control whether we use the GHC we find on the path
21−# system-ghc: true
22−
23−# Require a specific version of stack, using version ranges
24−# require-stack-version: -any # Default
25−# require-stack-version: >= 1.0.0
26−
27−# Override the architecture used by stack, especially useful on Windows
28−# arch: i386
29−# arch: x86_64
30−
31−# Extra directories used by stack for building
32−# extra-include-dirs: [/path/to/dir]
33−# extra-lib-dirs: [/path/to/dir]
34−
35−# Allow a newer minor version of GHC than the snapshot specifies
36−# compiler-check: newer-minor
test/Servant/QuickCheck/InternalSpec.hs+2−2
@@ -5,7 +5,7 @@ import Control.Concurrent.MVar (newMVar, readMVar, swapMVar)
55import Control.Monad.IO.Class (liftIO)
66import Prelude.Compat
77import Servant
8−import Servant.API.Internal.Test.ComprehensiveAPI (comprehensiveAPI)
8+import Servant.API.Internal.Test.ComprehensiveAPI (comprehensiveAPIWithoutRaw)
99import Test.Hspec (Spec, context, describe, it,
1010 shouldBe, shouldContain)
1111import Test.Hspec.Core.Spec (Arg, Example, Result (..),
@@ -81,7 +81,7 @@ isComprehensiveSpec :: Spec
8181isComprehensiveSpec = describe "HasGenRequest" $ do
8282
8383 it "has instances for all 'servant' combinators" $ do
84− let _g = genRequest comprehensiveAPI
84+ let _g = genRequest comprehensiveAPIWithoutRaw
8585 True `shouldBe` True -- This is a type-level check
8686
8787