From 84ebc6ed5fe6aa3f8955befe9c8bfb90b9c89fdd Mon Sep 17 00:00:00 2001 From: "Julian K. Arni" Date: Sun, 28 Aug 2016 20:53:14 -0300 Subject: [PATCH 1/4] bump version --- CHANGELOG.md | 5 +++++ servant-quickcheck.cabal | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94d987b..2a3bc39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 0.0.1.1 + +- Exclude GHC 7.8 base (it wasn't properly supported anyhow). +- More generous bounds for other packages. + # 0.0.1.0 - Better error messages. Error messages now contain failing predicate, failing diff --git a/servant-quickcheck.cabal b/servant-quickcheck.cabal index c79159b..453a664 100644 --- a/servant-quickcheck.cabal +++ b/servant-quickcheck.cabal @@ -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 From 653740996829bd58d3bf98b74c69a370d1c91ffb Mon Sep 17 00:00:00 2001 From: "Julian K. Arni" Date: Wed, 14 Sep 2016 09:37:14 -0300 Subject: [PATCH 2/4] support ghc 8 --- .travis.yml | 19 ++++------- servant-quickcheck.cabal | 8 ++--- src/Servant/QuickCheck/Internal/Predicates.hs | 4 +-- stack-ghc-8.0.1.yaml | 7 ++++ stack.yaml | 33 ++----------------- 5 files changed, 21 insertions(+), 50 deletions(-) create mode 100644 stack-ghc-8.0.1.yaml diff --git a/.travis.yml b/.travis.yml index c18b6f8..7e56a9f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,18 +2,12 @@ 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) @@ -25,7 +19,6 @@ install: script: - tinc && cabal configure --enable-tests && cabal build && cabal test - #- (cd doc && tinc cabal configure --enable-tests && cabal build && cabal test) cache: directories: diff --git a/servant-quickcheck.cabal b/servant-quickcheck.cabal index 453a664..97e4300 100644 --- a/servant-quickcheck.cabal +++ b/servant-quickcheck.cabal @@ -27,19 +27,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 diff --git a/src/Servant/QuickCheck/Internal/Predicates.hs b/src/Servant/QuickCheck/Internal/Predicates.hs index 9ece936..1954011 100644 --- a/src/Servant/QuickCheck/Internal/Predicates.hs +++ b/src/Servant/QuickCheck/Internal/Predicates.hs @@ -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 diff --git a/stack-ghc-8.0.1.yaml b/stack-ghc-8.0.1.yaml new file mode 100644 index 0000000..3867889 --- /dev/null +++ b/stack-ghc-8.0.1.yaml @@ -0,0 +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-09-07 +packages: +- '.' +extra-deps: [] +flags: {} +extra-package-dbs: [] diff --git a/stack.yaml b/stack.yaml index 51a5583..c301d0b 100644 --- a/stack.yaml +++ b/stack.yaml @@ -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 From 9ff43756ce370e285047107a003ae0daa6745735 Mon Sep 17 00:00:00 2001 From: "Julian K. Arni" Date: Wed, 14 Sep 2016 09:59:07 -0300 Subject: [PATCH 3/4] Update CHANGELOG to YAML syntax. --- CHANGELOG.md | 10 ---------- CHANGELOG.yaml | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 10 deletions(-) delete mode 100644 CHANGELOG.md create mode 100644 CHANGELOG.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 2a3bc39..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,10 +0,0 @@ -# 0.0.1.1 - -- Exclude GHC 7.8 base (it wasn't properly supported anyhow). -- More generous bounds for other packages. - -# 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. diff --git a/CHANGELOG.yaml b/CHANGELOG.yaml new file mode 100644 index 0000000..272001e --- /dev/null +++ b/CHANGELOG.yaml @@ -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 From 0337996c6c5a7c87762b61c648e0eefab0d5d950 Mon Sep 17 00:00:00 2001 From: "Julian K. Arni" Date: Wed, 14 Sep 2016 10:13:37 -0300 Subject: [PATCH 4/4] Support new CaptureAll combinator. --- .travis.yml | 3 ++- servant-quickcheck.cabal | 6 +++++- src/Servant/QuickCheck/Internal/HasGenRequest.hs | 15 +++++++++++++++ stack-ghc-8.0.1.yaml | 5 ++++- test/Servant/QuickCheck/InternalSpec.hs | 4 ++-- 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7e56a9f..4437ad7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ matrix: 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 @@ -19,6 +19,7 @@ install: script: - tinc && cabal configure --enable-tests && cabal build && cabal test + - cabal check cache: directories: diff --git a/servant-quickcheck.cabal b/servant-quickcheck.cabal index 97e4300..430670a 100644 --- a/servant-quickcheck.cabal +++ b/servant-quickcheck.cabal @@ -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 diff --git a/src/Servant/QuickCheck/Internal/HasGenRequest.hs b/src/Servant/QuickCheck/Internal/HasGenRequest.hs index 64ee033..407c0ab 100644 --- a/src/Servant/QuickCheck/Internal/HasGenRequest.hs +++ b/src/Servant/QuickCheck/Internal/HasGenRequest.hs @@ -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 diff --git a/stack-ghc-8.0.1.yaml b/stack-ghc-8.0.1.yaml index 3867889..ba8bdb2 100644 --- a/stack-ghc-8.0.1.yaml +++ b/stack-ghc-8.0.1.yaml @@ -2,6 +2,9 @@ resolver: nightly-2016-09-07 packages: - '.' -extra-deps: [] +extra-deps: +- 'servant-0.8.1' +- 'servant-server-0.8.1' +- 'servant-client-0.8.1' flags: {} extra-package-dbs: [] diff --git a/test/Servant/QuickCheck/InternalSpec.hs b/test/Servant/QuickCheck/InternalSpec.hs index 97ed739..91c5691 100644 --- a/test/Servant/QuickCheck/InternalSpec.hs +++ b/test/Servant/QuickCheck/InternalSpec.hs @@ -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