From 3571f543fdd2b1dcc81c124e57934ef127a469ec Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Tue, 7 Nov 2017 14:51:13 +0200 Subject: [PATCH] Support for servant-0.12 --- CHANGELOG.yaml | 7 +++ servant-quickcheck.cabal | 22 ++++++---- .../QuickCheck/Internal/HasGenRequest.hs | 8 ++++ test/Doctest.hs | 44 ------------------- 4 files changed, 28 insertions(+), 53 deletions(-) delete mode 100644 test/Doctest.hs diff --git a/CHANGELOG.yaml b/CHANGELOG.yaml index 26881b7..968027e 100644 --- a/CHANGELOG.yaml +++ b/CHANGELOG.yaml @@ -1,6 +1,13 @@ upcoming: releases: + - version: "0.0.4" + changes: + + - description: Support for Servant 0.12 + issue: none + authors: phadej + date: 2017-11-07 - version: "0.0.3.1" changes: diff --git a/servant-quickcheck.cabal b/servant-quickcheck.cabal index a752d29..97b6bd3 100644 --- a/servant-quickcheck.cabal +++ b/servant-quickcheck.cabal @@ -1,5 +1,5 @@ name: servant-quickcheck -version: 0.0.3.1 +version: 0.0.4 synopsis: QuickCheck entire APIs description: This packages provides QuickCheck properties that are tested across an entire @@ -14,6 +14,10 @@ build-type: Simple cabal-version: >=1.10 extra-source-files: CHANGELOG.yaml +tested-with: + GHC==7.10.3, + GHC==8.0.2, + GHC==8.2.1 source-repository head type: git @@ -31,7 +35,7 @@ library , Servant.QuickCheck.Internal.QuickCheck , Servant.QuickCheck.Internal.Equality , Servant.QuickCheck.Internal.ErrorTypes - build-depends: base >=4.8 && <4.10 + build-depends: base >=4.8 && <4.11 , base-compat == 0.9.* , aeson > 0.8 && < 2 , bytestring == 0.10.* @@ -40,20 +44,20 @@ library , data-default-class >= 0.0 && < 0.2 , hspec >= 2.2 && < 2.5 , http-client >= 0.4.30 && < 0.6 - , http-media == 0.6.* - , http-types > 0.8 && < 0.10 + , http-media >= 0.6 && <0.8 + , http-types > 0.8 && < 0.11 , mtl > 2.1 && < 2.3 , pretty == 1.1.* - , process >= 1.2 && < 1.5 + , process >= 1.2 && < 1.7 , QuickCheck > 2.7 && < 2.11 - , servant > 0.6 && < 0.12 - , servant-client > 0.6 && < 0.12 - , servant-server > 0.6 && < 0.12 + , servant > 0.6 && < 0.13 + , servant-client > 0.6 && < 0.13 + , servant-server > 0.6 && < 0.13 , split == 0.2.* , string-conversions > 0.3 && < 0.5 , temporary == 1.2.* , text == 1.* - , time >= 1.5 && < 1.7 + , time >= 1.5 && < 1.9 , warp >= 3.2.4 && < 3.3 hs-source-dirs: src diff --git a/src/Servant/QuickCheck/Internal/HasGenRequest.hs b/src/Servant/QuickCheck/Internal/HasGenRequest.hs index 3da08a2..bc6fbd9 100644 --- a/src/Servant/QuickCheck/Internal/HasGenRequest.hs +++ b/src/Servant/QuickCheck/Internal/HasGenRequest.hs @@ -69,6 +69,14 @@ instance HasGenRequest EmptyAPI where genRequest _ = (0, error "EmptyAPIs cannot be queried.") #endif +#if MIN_VERSION_servant(0,12,0) +instance HasGenRequest api => HasGenRequest (Summary d :> api) where + genRequest _ = genRequest (Proxy :: Proxy api) + +instance HasGenRequest api => HasGenRequest (Description d :> api) where + genRequest _ = genRequest (Proxy :: Proxy api) +#endif + instance (Arbitrary c, HasGenRequest b, ToHttpApiData c ) => HasGenRequest (Capture x c :> b) where genRequest _ = (oldf, do diff --git a/test/Doctest.hs b/test/Doctest.hs deleted file mode 100644 index b6f23e5..0000000 --- a/test/Doctest.hs +++ /dev/null @@ -1,44 +0,0 @@ -module Main where - -import Data.List (isPrefixOf) -import System.Directory -import System.FilePath -import System.FilePath.Find -import Test.DocTest - -main :: IO () -main = do - files <- find always (extension ==? ".hs") "src" - mCabalMacrosFile <- getCabalMacrosFile - doctest $ "-isrc" : "-Iinclude" : - (maybe [] (\ f -> ["-optP-include", "-optP" ++ f]) mCabalMacrosFile) ++ - "-XOverloadedStrings" : - "-XDeriveFunctor" : - "-XFlexibleInstances" : - "-XFlexibleContexts" : - "-XMultiParamTypeClasses" : - "-XDataKinds" : - "-XTypeOperators" : - "-XGADTs" : - files - -getCabalMacrosFile :: IO (Maybe FilePath) -getCabalMacrosFile = do - exists <- doesDirectoryExist "dist" - if exists - then do - contents <- getDirectoryContents "dist" - let rest = "build" "autogen" "cabal_macros.h" - whenExists $ case filter ("dist-sandbox-" `isPrefixOf`) contents of - [x] -> "dist" x rest - [] -> "dist" rest - xs -> error $ "ran doctests with multiple dist/dist-sandbox-xxxxx's: \n" - ++ show xs ++ "\nTry cabal clean" - else return Nothing - where - whenExists :: FilePath -> IO (Maybe FilePath) - whenExists file = do - exists <- doesFileExist file - return $ if exists - then Just file - else Nothing