Merge pull request #16 from haskell-servant/ghc8-support

Ghc8 support
This commit is contained in:
Julian Arni 2016-09-14 10:53:30 -03:00 committed by GitHub
commit 2411e2966c
9 changed files with 96 additions and 60 deletions

View File

@ -2,22 +2,16 @@ sudo: false
language: c
env:
- GHCVER=7.10.2
addons:
apt:
sources:
- hvr-ghc
packages:
- ghc-7.10.2
- cabal-install-1.22
- libgmp-dev
- wrk
matrix:
include:
- env: CABALVER=1.22 GHCVER=7.10.1
addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.1],sources: [hvr-ghc]}}
- env: CABALVER=1.24 GHCVER=8.0.1
addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1], sources: [hvr-ghc]}}
install:
- (mkdir -p $HOME/.local/bin && cd $HOME/.local/bin && wget https://zalora-public.s3.amazonaws.com/tinc && chmod +x tinc)
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/1.22/bin:$PATH
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
- ghc --version
- cabal --version
- travis_retry cabal update
@ -25,7 +19,7 @@ install:
script:
- tinc && cabal configure --enable-tests && cabal build && cabal test
#- (cd doc && tinc cabal configure --enable-tests && cabal build && cabal test)
- cabal check
cache:
directories:

View File

@ -1,5 +0,0 @@
# 0.0.1.0
- Better error messages. Error messages now contain failing predicate, failing
response and (except for response predicates), failing requests.
- Significant changes to RequestPredicate and ResponsePredicate types.

47
CHANGELOG.yaml Normal file
View File

@ -0,0 +1,47 @@
upcoming:
changes:
- description: Update CHANGELOG to YAML syntax.
pr: 16
authors: jkarni
date: 2016-09-14
- description: Support new CaptureAll combinator
pr: 16
authors: jkarni
date: 2016-09-14
- description: Support GHC 8
pr: 16
authors: jkarni
date: 2016-09-14
releases:
- version: "0.0.1.1"
changes:
- description: Exclude GHC 7.8 (by bumping base lower bound to 4.8)
pr: none
authors: jkarni
- description: More generous bounds for other packages.
pr: none
authors: jkarni
- version: "0.0.1.0"
changes:
- description: Better error messages.
notes: >
Error messages now contain failing predicate, failing response and
(except for response predicates), failing requests.
pr: none
authors: jkarni
- description: Signicant changes to RequestPredicate and ResponsePredicate types.
pr: none
authors: jkarni

View File

@ -1,5 +1,5 @@
name: servant-quickcheck
version: 0.0.1.0
version: 0.0.1.1
synopsis: QuickCheck entire APIs
description:
This packages provides QuickCheck properties that are tested across an entire
@ -13,7 +13,11 @@ category: Web
build-type: Simple
cabal-version: >=1.10
extra-source-files:
CHANGELOG.md
CHANGELOG.yaml
source-repository head
type: git
location: https://github.com/haskell-servant/servant-quickcheck
flag long-tests
description: Run more QuickCheck tests
@ -27,19 +31,19 @@ library
, Servant.QuickCheck.Internal.QuickCheck
, Servant.QuickCheck.Internal.Equality
, Servant.QuickCheck.Internal.ErrorTypes
build-depends: base >=4.8 && <4.9
build-depends: base >=4.8 && <4.10
, base-compat == 0.9.*
, aeson > 0.8 && < 0.12
, bytestring == 0.10.*
, case-insensitive == 1.2.*
, data-default-class == 0.0.*
, data-default-class >= 0.0 && < 0.2
, hspec == 2.2.*
, http-client == 0.4.*
, http-client >= 0.4.30 && < 0.5
, http-media == 0.6.*
, http-types > 0.8 && < 0.10
, mtl > 2.1 && < 2.3
, pretty == 1.1.*
, process == 1.2.*
, process >= 1.2 && < 1.5
, QuickCheck > 2.7 && < 2.9
, servant > 0.6 && < 0.9
, servant-client > 0.6 && < 0.9

View File

@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE PolyKinds #-}
module Servant.QuickCheck.Internal.HasGenRequest where
@ -5,6 +6,7 @@ import Data.Default.Class (def)
import Data.Monoid ((<>))
import Data.String (fromString)
import Data.String.Conversions (cs)
import qualified Data.ByteString as BS
import GHC.TypeLits (KnownSymbol, Nat, symbolVal)
import Network.HTTP.Client (Request, RequestBody (..), host, method, path,
port, queryString, requestBody, requestHeaders,
@ -44,6 +46,19 @@ instance (Arbitrary c, HasGenRequest b, ToHttpApiData c )
old = genRequest (Proxy :: Proxy b)
new = arbitrary :: Gen c
#if MIN_VERSION_servant(0,8,0)
instance (Arbitrary c, HasGenRequest b, ToHttpApiData c )
=> HasGenRequest (CaptureAll x c :> b) where
genRequest _ = do
old' <- old
new' <- fmap (cs . toUrlPiece) <$> new
let new'' = BS.intercalate "/" new'
return $ \burl -> let r = old' burl in r { path = new'' <> path r }
where
old = genRequest (Proxy :: Proxy b)
new = arbitrary :: Gen [c]
#endif
instance (Arbitrary c, KnownSymbol h, HasGenRequest b, ToHttpApiData c)
=> HasGenRequest (Header h c :> b) where
genRequest _ = do

View File

@ -14,7 +14,7 @@ import Data.Monoid ((<>))
import GHC.Generics (Generic)
import Network.HTTP.Client (Manager, Request, Response, httpLbs,
method, requestHeaders, responseBody,
responseHeaders, parseUrl, responseStatus)
responseHeaders, parseRequest, responseStatus)
import Network.HTTP.Media (matchAccept)
import Network.HTTP.Types (methodGet, methodHead, parseMethod,
renderStdMethod, status100, status200,
@ -92,7 +92,7 @@ createContainsValidLocation
if responseStatus resp == status201
then case lookup "Location" $ responseHeaders resp of
Nothing -> fail n
Just l -> case parseUrl $ SBSC.unpack l of
Just l -> case parseRequest $ SBSC.unpack l of
Nothing -> fail n
Just x -> do
resp2 <- httpLbs x mgr

10
stack-ghc-8.0.1.yaml Normal file
View File

@ -0,0 +1,10 @@
# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
resolver: nightly-2016-09-07
packages:
- '.'
extra-deps:
- 'servant-0.8.1'
- 'servant-server-0.8.1'
- 'servant-client-0.8.1'
flags: {}
extra-package-dbs: []

View File

@ -1,36 +1,7 @@
# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
resolver: nightly-2016-04-20
# Local packages, usually specified by relative directory name
resolver: lts-6.17
packages:
- '.'
# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)
extra-deps:
- servant-0.8
- servant-client-0.8
- servant-server-0.8
# Override default flag values for local packages and extra-deps
extra-deps: []
flags: {}
# Extra package databases containing global packages
extra-package-dbs: []
# Control whether we use the GHC we find on the path
# system-ghc: true
# Require a specific version of stack, using version ranges
# require-stack-version: -any # Default
# require-stack-version: >= 1.0.0
# Override the architecture used by stack, especially useful on Windows
# arch: i386
# arch: x86_64
# Extra directories used by stack for building
# extra-include-dirs: [/path/to/dir]
# extra-lib-dirs: [/path/to/dir]
# Allow a newer minor version of GHC than the snapshot specifies
# compiler-check: newer-minor

View File

@ -5,7 +5,7 @@ import Control.Concurrent.MVar (newMVar, readMVar, swapMVar)
import Control.Monad.IO.Class (liftIO)
import Prelude.Compat
import Servant
import Servant.API.Internal.Test.ComprehensiveAPI (comprehensiveAPI)
import Servant.API.Internal.Test.ComprehensiveAPI (comprehensiveAPIWithoutRaw)
import Test.Hspec (Spec, context, describe, it,
shouldBe, shouldContain)
import Test.Hspec.Core.Spec (Arg, Example, Result (..),
@ -81,7 +81,7 @@ isComprehensiveSpec :: Spec
isComprehensiveSpec = describe "HasGenRequest" $ do
it "has instances for all 'servant' combinators" $ do
let _g = genRequest comprehensiveAPI
let _g = genRequest comprehensiveAPIWithoutRaw
True `shouldBe` True -- This is a type-level check