Merge pull request #37 from phadej/servant-0.12

Support for servant-0.12
This commit is contained in:
Oleg Grenrus 2017-11-08 13:27:13 +02:00 committed by GitHub
commit 6e6595f68c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 118 additions and 85 deletions

View File

@ -1,38 +1,95 @@
# This Travis job script has been generated by a script via
#
# make_travis_yml_2.hs '--branch' 'master' '-o' '.travis.yml' 'servant-quickcheck.cabal'
#
# For more information, see https://github.com/hvr/multi-ghc-travis
#
language: c
sudo: false
language: c
git:
submodules: false # whether to recursively clone submodules
env:
- STACK_YAML=stack.yaml
- STACK_YAML=stack-lts-7.yaml
- STACK_YAML=stack-lts-6.yaml
- STACK_YAML=stack-lts-9.yaml
addons:
apt:
packages: libgmp-dev
install:
# stack
- mkdir -p ~/.local/bin
- export PATH=~/.local/bin:$PATH
- travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
- stack --version
script:
- stack setup --no-terminal
- stack build --ghc-options=-Werror --no-terminal
- stack test --ghc-options=-Werror --no-terminal --coverage
- stack haddock --no-terminal
after_script:
# SHC only has a build for 8.0.1, not above
- if [ "$STACK_YAML" == stack-lts-7.yaml ]
- travis_retry curl -L https://github.com/rubik/stack-hpc-coveralls/releases/download/v0.0.4.0/shc-linux-x64-8.0.1.tar.bz2 | tar -xj
- ./shc servant-quickcheck spec
branches:
only:
- master
cache:
directories:
- $HOME/.stack
- $HOME/.cabal/packages
- $HOME/.cabal/store
before_cache:
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
# remove files that are regenerated by 'cabal update'
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.*
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/*.json
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.cache
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar.idx
matrix:
include:
- compiler: "ghc-7.10.3"
# env: TEST=--disable-tests BENCH=--disable-benchmarks
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.10.3], sources: [hvr-ghc]}}
- compiler: "ghc-8.0.2"
# env: TEST=--disable-tests BENCH=--disable-benchmarks
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.0.2], sources: [hvr-ghc]}}
- compiler: "ghc-8.2.1"
# env: TEST=--disable-tests BENCH=--disable-benchmarks
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.1], sources: [hvr-ghc]}}
before_install:
- HC=${CC}
- HCPKG=${HC/ghc/ghc-pkg}
- unset CC
- PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$PATH
install:
- cabal --version
- echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
- BENCH=${BENCH---enable-benchmarks}
- TEST=${TEST---enable-tests}
- HADDOCK=${HADDOCK-true}
- INSTALLED=${INSTALLED-true}
- travis_retry cabal update -v
- sed -i.bak 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
- rm -fv cabal.project.local
- "echo 'packages: .' > cabal.project"
- if [ -f "./configure.ac" ]; then
(cd "."; autoreconf -i);
fi
- rm -f cabal.project.freeze
- cabal new-build -w ${HC} ${TEST} ${BENCH} --project-file="cabal.project" --dep -j2 all
- cabal new-build -w ${HC} --disable-tests --disable-benchmarks --project-file="cabal.project" --dep -j2 all
- rm -rf "."/.ghc.environment.* "."/dist
- DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
# Here starts the actual work to be performed for the package under test;
# any command which exits with a non-zero exit code causes the build to fail.
script:
# test that source-distributions can be generated
- (cd "."; cabal sdist)
- mv "."/dist/servant-quickcheck-*.tar.gz ${DISTDIR}/
- cd ${DISTDIR}
- find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;
- "printf 'packages: servant-quickcheck-*/*.cabal\n' > cabal.project"
# this builds all libraries and executables (without tests/benchmarks)
- cabal new-build -w ${HC} --disable-tests --disable-benchmarks all
# Build with installed constraints for packages in global-db
- if $INSTALLED; then
echo cabal new-build -w ${HC} --disable-tests --disable-benchmarks $(${HCPKG} list --global --simple-output --names-only | sed 's/\([a-zA-Z0-9-]\{1,\}\) */--constraint="\1 installed" /g') all | sh;
else echo "Not building with installed constraints"; fi
# build & run tests, build benchmarks
- cabal new-build -w ${HC} ${TEST} ${BENCH} all
- if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} all; fi
# haddock
- rm -rf ./dist-newstyle
- if $HADDOCK; then cabal new-haddock -w ${HC} --disable-tests --disable-benchmarks all; else echo "Skipping haddock generation";fi
# REGENDATA ["--branch","master","-o",".travis.yml","servant-quickcheck.cabal"]
# EOF

View File

@ -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:

View File

@ -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
@ -82,6 +86,7 @@ test-suite spec
hs-source-dirs: test
main-is: Spec.hs
other-modules: Servant.QuickCheck.InternalSpec
build-tool-depends: hspec-discover:hspec-discover
build-depends: base == 4.*
, base-compat
, aeson

View File

@ -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

View File

@ -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