git.iko.soy/servant-quickcheck
on master help sign in
10 files changed+349−241
since splitsnapshots
unifiedsplit
.travis.yml+127−85 CHANGELOG.yaml+42 cabal.haskell-ci+7 cabal.project+4 servant-quickcheck.cabal+114−112 src/Servant/QuickCheck/Internal/HasGenRequest.hs+9−6 src/Servant/QuickCheck/Internal/Predicates.hs+14−15 src/Servant/QuickCheck/Internal/QuickCheck.hs+18−2 stack.yaml+5−9 test/Servant/QuickCheck/InternalSpec.hs+9−12
.travis.yml+127−85
@@ -1,116 +1,158 @@
11# This Travis job script has been generated by a script via
22#
3−# runghc make_travis_yml_2.hs '--branch' 'master' '-o' '.travis.yml' 'servant-quickcheck.cabal'
3+# haskell-ci '--config=cabal.haskell-ci' 'servant-quickcheck.cabal'
44#
5−# For more information, see https://github.com/hvr/multi-ghc-travis
5+# To regenerate the script (for example after adjusting tested-with) run
66#
7+# haskell-ci regenerate
8+#
9+# For more information, see https://github.com/haskell-CI/haskell-ci
10+#
11+# version: 0.10.1
12+#
13+version: ~> 1.0
714language: c
8−sudo: false
9−
15+os: linux
16+dist: xenial
1017git:
11− submodules: false # whether to recursively clone submodules
12−
18+ # whether to recursively clone submodules
19+ submodules: false
1320branches:
1421 only:
1522 - master
16−
1723cache:
1824 directories:
1925 - $HOME/.cabal/packages
2026 - $HOME/.cabal/store
21−
27+ - $HOME/.hlint
2228before_cache:
23− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
29+ - rm -fv $CABALHOME/packages/hackage.haskell.org/build-reports.log
2430 # remove files that are regenerated by 'cabal update'
25− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.*
26− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/*.json
27− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.cache
28− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar
29− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar.idx
30−
31− - rm -rfv $HOME/.cabal/packages/head.hackage
32−
33−matrix:
31+ - rm -fv $CABALHOME/packages/hackage.haskell.org/00-index.*
32+ - rm -fv $CABALHOME/packages/hackage.haskell.org/*.json
33+ - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.cache
34+ - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar
35+ - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar.idx
36+ - rm -rfv $CABALHOME/packages/head.hackage
37+jobs:
3438 include:
35− - compiler: "ghc-8.4.3"
36− # env: TEST=--disable-tests BENCH=--disable-benchmarks
37− addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-8.4.3], sources: [hvr-ghc]}}
38− - compiler: "ghc-8.2.2"
39− # env: TEST=--disable-tests BENCH=--disable-benchmarks
40− addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-8.2.2], sources: [hvr-ghc]}}
41− - compiler: "ghc-8.0.2"
42− # env: TEST=--disable-tests BENCH=--disable-benchmarks
43− addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-8.0.2], sources: [hvr-ghc]}}
44− - compiler: "ghc-7.10.3"
45− # env: TEST=--disable-tests BENCH=--disable-benchmarks
46− addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-7.10.3], sources: [hvr-ghc]}}
47−
39+ - compiler: ghc-8.8.3
40+ addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.8.3","cabal-install-3.2"]}}
41+ os: linux
42+ - compiler: ghc-8.6.5
43+ addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.6.5","cabal-install-3.2"]}}
44+ os: linux
45+ - compiler: ghc-8.4.4
46+ addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.4.4","cabal-install-3.2"]}}
47+ os: linux
48+ - compiler: ghc-8.2.2
49+ addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.2.2","cabal-install-3.2"]}}
50+ os: linux
51+ - compiler: ghc-8.0.2
52+ addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.0.2","cabal-install-3.2"]}}
53+ os: linux
4854before_install:
49− - HC=${CC}
50− - HCPKG=${HC/ghc/ghc-pkg}
55+ - HC=$(echo "/opt/$CC/bin/ghc" | sed 's/-/\//')
56+ - WITHCOMPILER="-w $HC"
57+ - HADDOCK=$(echo "/opt/$CC/bin/haddock" | sed 's/-/\//')
58+ - HCPKG="$HC-pkg"
5159 - unset CC
52− - ROOTDIR=$(pwd)
53− - mkdir -p $HOME/.local/bin
54− - "PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$HOME/local/bin:$PATH"
55− - HCNUMVER=$(( $(${HC} --numeric-version|sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\1 * 10000 + \2 * 100 + \3/') ))
60+ - CABAL=/opt/ghc/bin/cabal
61+ - CABALHOME=$HOME/.cabal
62+ - export PATH="$CABALHOME/bin:$PATH"
63+ - TOP=$(pwd)
64+ - "HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')"
5665 - echo $HCNUMVER
57−
66+ - CABAL="$CABAL -vnormal+nowrap"
67+ - set -o pipefail
68+ - TEST=--enable-tests
69+ - BENCH=--enable-benchmarks
70+ - HEADHACKAGE=false
71+ - rm -f $CABALHOME/config
72+ - |
73+ echo "verbose: normal +nowrap +markoutput" >> $CABALHOME/config
74+ echo "remote-build-reporting: anonymous" >> $CABALHOME/config
75+ echo "write-ghc-environment-files: always" >> $CABALHOME/config
76+ echo "remote-repo-cache: $CABALHOME/packages" >> $CABALHOME/config
77+ echo "logs-dir: $CABALHOME/logs" >> $CABALHOME/config
78+ echo "world-file: $CABALHOME/world" >> $CABALHOME/config
79+ echo "extra-prog-path: $CABALHOME/bin" >> $CABALHOME/config
80+ echo "symlink-bindir: $CABALHOME/bin" >> $CABALHOME/config
81+ echo "installdir: $CABALHOME/bin" >> $CABALHOME/config
82+ echo "build-summary: $CABALHOME/logs/build.log" >> $CABALHOME/config
83+ echo "store-dir: $CABALHOME/store" >> $CABALHOME/config
84+ echo "install-dirs user" >> $CABALHOME/config
85+ echo " prefix: $CABALHOME" >> $CABALHOME/config
86+ echo "repository hackage.haskell.org" >> $CABALHOME/config
87+ echo " url: http://hackage.haskell.org/" >> $CABALHOME/config
5888install:
59− - cabal --version
89+ - ${CABAL} --version
6090 - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
61− - BENCH=${BENCH---enable-benchmarks}
62− - TEST=${TEST---enable-tests}
63− - HADDOCK=${HADDOCK-true}
64− - UNCONSTRAINED=${UNCONSTRAINED-true}
65− - NOINSTALLEDCONSTRAINTS=${NOINSTALLEDCONSTRAINTS-false}
66− - GHCHEAD=${GHCHEAD-false}
67− - travis_retry cabal update -v
68− - "sed -i.bak 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config"
69− - rm -fv cabal.project cabal.project.local
70− - grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$'
71− - "printf 'packages: \".\"\\n' > cabal.project"
72− - touch cabal.project.local
73− - "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi"
91+ - |
92+ echo "program-default-options" >> $CABALHOME/config
93+ echo " ghc-options: $GHCJOBS +RTS -M6G -RTS" >> $CABALHOME/config
94+ - cat $CABALHOME/config
95+ - rm -fv cabal.project cabal.project.local cabal.project.freeze
96+ - travis_retry ${CABAL} v2-update -v
97+ # Generate cabal.project
98+ - rm -rf cabal.project cabal.project.local cabal.project.freeze
99+ - touch cabal.project
100+ - |
101+ echo "packages: ." >> cabal.project
102+ - if [ $HCNUMVER -ge 80200 ] ; then echo 'package servant-quickcheck' >> cabal.project ; fi
103+ - "if [ $HCNUMVER -ge 80200 ] ; then echo ' ghc-options: -Werror=missing-methods' >> cabal.project ; fi"
104+ - |
105+ - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(servant-quickcheck)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
74106 - cat cabal.project || true
75107 - cat cabal.project.local || true
76− - if [ -f "./configure.ac" ]; then
77− (cd "." && autoreconf -i);
78− fi
79− - rm -f cabal.project.freeze
80− - cabal new-build -w ${HC} ${TEST} ${BENCH} --project-file="cabal.project" --dep -j2 all
81− - cabal new-build -w ${HC} --disable-tests --disable-benchmarks --project-file="cabal.project" --dep -j2 all
82− - rm -rf .ghc.environment.* "."/dist
83− - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
84−
85−# Here starts the actual work to be performed for the package under test;
86−# any command which exits with a non-zero exit code causes the build to fail.
108+ - if [ -f "./configure.ac" ]; then (cd "." && autoreconf -i); fi
109+ - ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH}
110+ - "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'"
111+ - rm cabal.project.freeze
112+ - travis_wait 40 ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} --dep -j2 all
113+ - travis_wait 40 ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --dep -j2 all
87114script:
88− # test that source-distributions can be generated
89− - (cd "." && cabal sdist)
90− - mv "."/dist/servant-quickcheck-*.tar.gz ${DISTDIR}/
115+ - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
116+ # Packaging...
117+ - ${CABAL} v2-sdist all
118+ # Unpacking...
119+ - mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/
91120 - cd ${DISTDIR} || false
92− - find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;
93− - "printf 'packages: servant-quickcheck-*/*.cabal\\n' > cabal.project"
94− - touch cabal.project.local
95− - "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi"
121+ - find . -maxdepth 1 -type f -name '*.tar.gz' -exec tar -xvf '{}' \;
122+ - find . -maxdepth 1 -type f -name '*.tar.gz' -exec rm '{}' \;
123+ - PKGDIR_servant_quickcheck="$(find . -maxdepth 1 -type d -regex '.*/servant-quickcheck-[0-9.]*')"
124+ # Generate cabal.project
125+ - rm -rf cabal.project cabal.project.local cabal.project.freeze
126+ - touch cabal.project
127+ - |
128+ echo "packages: ${PKGDIR_servant_quickcheck}" >> cabal.project
129+ - if [ $HCNUMVER -ge 80200 ] ; then echo 'package servant-quickcheck' >> cabal.project ; fi
130+ - "if [ $HCNUMVER -ge 80200 ] ; then echo ' ghc-options: -Werror=missing-methods' >> cabal.project ; fi"
131+ - |
132+ - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(servant-quickcheck)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
96133 - cat cabal.project || true
97134 - cat cabal.project.local || true
135+ # Building...
98136 # this builds all libraries and executables (without tests/benchmarks)
99− - cabal new-build -w ${HC} --disable-tests --disable-benchmarks all
100−
137+ - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all
138+ # Building with tests and benchmarks...
101139 # build & run tests, build benchmarks
102− - cabal new-build -w ${HC} ${TEST} ${BENCH} all
103− - if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} ${BENCH} all; fi
104−
105− # cabal check
106− - (cd servant-quickcheck-* && cabal check)
107−
108− # haddock
109− - rm -rf ./dist-newstyle
110− - if $HADDOCK; then cabal new-haddock -w ${HC} ${TEST} ${BENCH} all; else echo "Skipping haddock generation";fi
111−
112− # Build without installed constraints for packages in global-db
113− - if $UNCONSTRAINED; then rm -f cabal.project.local; echo cabal new-build -w ${HC} --disable-tests --disable-benchmarks all; else echo "Not building without installed constraints"; fi
140+ - ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} all
141+ # Testing...
142+ - ${CABAL} v2-test $WITHCOMPILER ${TEST} ${BENCH} all
143+ # cabal check...
144+ - (cd ${PKGDIR_servant_quickcheck} && ${CABAL} -vnormal check)
145+ # haddock...
146+ - ${CABAL} v2-haddock $WITHCOMPILER --with-haddock $HADDOCK ${TEST} ${BENCH} all
147+ # Building without installed constraints for packages in global-db...
148+ - rm -f cabal.project.local
149+ - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all
150+ # Constraint sets
151+ - rm -rf cabal.project.local
152+ # Constraint set base-compat-0.10
153+ - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='base-compat ==0.10.*' all
154+ # Constraint set base-compat-0.11
155+ - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='base-compat ==0.11.*' all
114156
115−# REGENDATA ["--branch","master","-o",".travis.yml","servant-quickcheck.cabal"]
157+# REGENDATA ("0.10.1",["--config=cabal.haskell-ci","servant-quickcheck.cabal"])
116158# EOF
CHANGELOG.yaml+42
@@ -1,4 +1,46 @@
11releases:
2+ - version: "0.0.9.0"
3+ changes:
4+ - description: "Support servant-0.15 (#65)"
5+ authors: fizruk
6+ date: 2020-06-25
7+
8+ - description: "Relax constraints for GHC 8.10 (#70)"
9+ authors: felixmulder
10+ date: 2020-06-20
11+
12+ - version: "0.0.8.0"
13+ changes:
14+ - description: Support for servant-0.17
15+ authors: phadej
16+ date: 2019-01-23
17+
18+ - version: "0.0.7.3"
19+ changes:
20+ - description: Support for servant-0.14
21+ issue: 53
22+ authors: phadej
23+ date: 2018-06-12
24+
25+ - description: Fix a failure from OnlyJsonObjects when there is no content-type.
26+ issue: 55
27+ authors: Phenitei
28+ date: 2018-08-27
29+
30+ - description: A bug fix where notAllowedContainsAllowHeader would print the initial request alongside the failure instead of the request causing the failure when it failed.
31+ issue: 57
32+ authors: Phenitei
33+ date: 2018-08-29
34+
35+ - description: QuickCheck 2.12 compatibility
36+ issue: 58
37+ authors: parsonsmatt
38+ date: 2018-10-12
39+
40+ - description: GHC 8.6 compatibility
41+ issue: 59
42+ authors: phadej
43+ date: 2018-10-15
244
345 - version: "0.0.7.2"
446 changes:
cabal.haskell-cinew file+7
@@ -0,0 +1,7 @@
1+branches: master
2+
3+constraint-set base-compat-0.10
4+ constraints: base-compat ==0.10.*
5+
6+constraint-set base-compat-0.11
7+ constraints: base-compat ==0.11.*
cabal.projectnew file+4
@@ -0,0 +1,4 @@
1+packages: .
2+tests: true
3+
4+allow-newer: servant-blaze:servant
servant-quickcheck.cabal+114−112
@@ -1,28 +1,22 @@
1−name: servant-quickcheck
2−version: 0.0.7.2
3−x-revision: 1
4−synopsis: QuickCheck entire APIs
1+name: servant-quickcheck
2+version: 0.0.9.1
3+synopsis: QuickCheck entire APIs
54description:
6− This packages provides QuickCheck properties that are tested across an entire
7− API.
5+ This packages provides QuickCheck properties that are tested across an entire
6+ API.
87
9−license: BSD3
10−license-file: LICENSE
11−author: Julian K. Arni
12−maintainer: jkarni@gmail.com
13−category: Web
14−build-type: Simple
15−cabal-version: >=1.10
16−extra-source-files:
17− CHANGELOG.yaml
18−tested-with:
19− GHC==7.10.3,
20− GHC==8.0.2,
21− GHC==8.2.2,
22− GHC==8.4.3
8+license: BSD3
9+license-file: LICENSE
10+author: Julian K. Arni
11+maintainer: jkarni@gmail.com
12+category: Web
13+build-type: Simple
14+cabal-version: >=1.10
15+extra-source-files: CHANGELOG.yaml
16+tested-with: GHC ==8.0.2 || ==8.2.2 || ==8.4.4 || ==8.6.5 || == 8.8.3
2317
2418source-repository head
25− type: git
19+ type: git
2620 location: https://github.com/haskell-servant/servant-quickcheck
2721
2822flag long-tests
@@ -30,107 +24,115 @@ flag long-tests
3024 default: False
3125
3226library
33− exposed-modules: Servant.QuickCheck
34− , Servant.QuickCheck.Internal
35− , Servant.QuickCheck.Internal.Predicates
36− , Servant.QuickCheck.Internal.HasGenRequest
37− , Servant.QuickCheck.Internal.QuickCheck
38− , Servant.QuickCheck.Internal.Equality
39− , Servant.QuickCheck.Internal.ErrorTypes
40− build-depends: base >=4.8 && <4.12
41− , base-compat-batteries >= 0.10.1 && <0.11
42− , aeson > 0.8 && < 2
43− , bytestring == 0.10.*
44− , case-insensitive == 1.2.*
45− , clock >= 0.7 && < 0.8
46− , data-default-class >= 0.0 && < 0.2
47− , hspec >= 2.5 && < 2.6
48− , http-client >= 0.4.30 && < 0.6
49− , http-media >= 0.6 && <0.8
50− , http-types > 0.8 && < 0.13
51− , mtl > 2.1 && < 2.3
52− , pretty == 1.1.*
53− , process >= 1.2 && < 1.7
54− , QuickCheck > 2.7 && < 2.12
55− , servant >= 0.13 && < 0.15
56− , servant-client >= 0.13 && < 0.15
57− , servant-server >= 0.13 && < 0.15
58− , split == 0.2.*
59− , string-conversions > 0.3 && < 0.5
60− , temporary >= 1.2 && <1.4
61− , text == 1.*
62− , time >= 1.5 && < 1.9
63− , warp >= 3.2.4 && < 3.3
27+ exposed-modules:
28+ Servant.QuickCheck
29+ Servant.QuickCheck.Internal
30+ Servant.QuickCheck.Internal.Equality
31+ Servant.QuickCheck.Internal.ErrorTypes
32+ Servant.QuickCheck.Internal.HasGenRequest
33+ Servant.QuickCheck.Internal.Predicates
34+ Servant.QuickCheck.Internal.QuickCheck
6435
65− if !impl(ghc >= 8.0)
66− build-depends:
67− semigroups >= 0.18.3 && <0.19
36+ build-depends:
37+ aeson >=0.8 && <2
38+ , base >=4.9 && <4.15
39+ , base-compat-batteries >=0.10.1 && <0.12
40+ , bytestring >=0.10 && <0.11
41+ , case-insensitive >=1.2 && <1.3
42+ , clock >=0.7 && <0.9
43+ , data-default-class >=0.0 && <0.2
44+ , hspec >=2.5.6 && <2.8
45+ , http-client >=0.4.30 && <0.8
46+ , http-media >=0.6 && <0.9
47+ , http-types >=0.8 && <0.13
48+ , mtl >=2.1 && <2.3
49+ , pretty >=1.1 && <1.2
50+ , process >=1.2 && <1.7
51+ , QuickCheck >=2.7 && <2.15
52+ , servant >=0.17 && <0.19
53+ , servant-client >=0.17 && <0.19
54+ , servant-server >=0.17 && <0.19
55+ , split >=0.2 && <0.3
56+ , string-conversions >=0.3 && <0.5
57+ , temporary >=1.2 && <1.4
58+ , text >=1 && <2
59+ , time >=1.5 && <1.11
60+ , warp >=3.2.4 && <3.4
61+
62+ if !impl(ghc >=8.0)
63+ build-depends: semigroups >=0.18.3 && <0.20
64+
65+ hs-source-dirs: src
66+ default-extensions:
67+ NoImplicitPrelude
68+ ConstraintKinds
69+ DataKinds
70+ DeriveDataTypeable
71+ DeriveFunctor
72+ DeriveGeneric
73+ FlexibleContexts
74+ FlexibleInstances
75+ FunctionalDependencies
76+ GADTs
77+ KindSignatures
78+ MultiParamTypeClasses
79+ OverloadedStrings
80+ RankNTypes
81+ ScopedTypeVariables
82+ TypeOperators
6883
69− hs-source-dirs: src
70− default-extensions: TypeOperators
71− , FlexibleInstances
72− , FlexibleContexts
73− , DataKinds
74− , GADTs
75− , MultiParamTypeClasses
76− , DeriveFunctor
77− , KindSignatures
78− , RankNTypes
79− , ConstraintKinds
80− , DeriveGeneric
81− , ScopedTypeVariables
82− , OverloadedStrings
83− , FunctionalDependencies
84− , NoImplicitPrelude
85− , DeriveDataTypeable
86− default-language: Haskell2010
84+ default-language: Haskell2010
8785
8886test-suite spec
89− type: exitcode-stdio-1.0
90− ghc-options: -Wall -threaded
91− default-language: Haskell2010
92− hs-source-dirs: test
93− main-is: Spec.hs
94− other-modules: Servant.QuickCheck.InternalSpec
95− build-tool-depends: hspec-discover:hspec-discover
96− build-depends: base
97− , base-compat-batteries
98− , aeson
99− , servant-quickcheck
100− , bytestring
101− , hspec
102− , hspec-core
103− , http-client
104− , blaze-html
105− , warp
106− , servant-server
107− , servant-client
108− , servant
109− , servant-blaze
110− , transformers
111− , QuickCheck
112− , quickcheck-io
113− default-extensions: TypeOperators
114− , FlexibleInstances
115− , FlexibleContexts
116− , GADTs
117− , DataKinds
118− , NoImplicitPrelude
119− , OverloadedStrings
120− , ScopedTypeVariables
87+ type: exitcode-stdio-1.0
88+ ghc-options: -Wall -threaded
89+ default-language: Haskell2010
90+ hs-source-dirs: test
91+ main-is: Spec.hs
92+ other-modules: Servant.QuickCheck.InternalSpec
93+ build-tool-depends: hspec-discover:hspec-discover -any
94+ build-depends:
95+ aeson
96+ , base
97+ , base-compat-batteries
98+ , blaze-html
99+ , bytestring
100+ , hspec
101+ , hspec-core >=2.5.5 && <2.8
102+ , http-client
103+ , QuickCheck
104+ , quickcheck-io
105+ , servant
106+ , servant-blaze
107+ , servant-client
108+ , servant-quickcheck
109+ , servant-server
110+ , transformers
111+ , warp
112+
113+ default-extensions:
114+ NoImplicitPrelude
115+ DataKinds
116+ FlexibleContexts
117+ FlexibleInstances
118+ GADTs
119+ OverloadedStrings
120+ ScopedTypeVariables
121+ TypeOperators
122+
121123 if flag(long-tests)
122− cpp-options: -DLONG_TESTS
124+ cpp-options: -DLONG_TESTS
123125
124126test-suite example
125− type: exitcode-stdio-1.0
126− main-is: Main.hs
127− hs-source-dirs:
128− example
129− ghc-options: -Wall
127+ type: exitcode-stdio-1.0
128+ main-is: Main.hs
129+ hs-source-dirs: example
130+ ghc-options: -Wall
130131 build-depends:
131132 base
132133 , hspec
133− , servant-server
134134 , servant-quickcheck
135+ , servant-server
135136 , text
137+
136138 default-language: Haskell2010
src/Servant/QuickCheck/Internal/HasGenRequest.hs+9−6
@@ -63,18 +63,14 @@ instance (KnownSymbol path, HasGenRequest b) => HasGenRequest (path :> b) where
6363 (oldf, old) = genRequest (Proxy :: Proxy b)
6464 new = cs $ symbolVal (Proxy :: Proxy path)
6565
66−#if MIN_VERSION_servant(0,11,0)
6766instance HasGenRequest EmptyAPI where
6867 genRequest _ = (0, error "EmptyAPIs cannot be queried.")
69−#endif
7068
71−#if MIN_VERSION_servant(0,12,0)
7269instance HasGenRequest api => HasGenRequest (Summary d :> api) where
7370 genRequest _ = genRequest (Proxy :: Proxy api)
7471
7572instance HasGenRequest api => HasGenRequest (Description d :> api) where
7673 genRequest _ = genRequest (Proxy :: Proxy api)
77−#endif
7874
7975instance (Arbitrary c, HasGenRequest b, ToHttpApiData c )
8076 => HasGenRequest (Capture' mods x c :> b) where
@@ -86,7 +82,6 @@ instance (Arbitrary c, HasGenRequest b, ToHttpApiData c )
8682 (oldf, old) = genRequest (Proxy :: Proxy b)
8783 new = arbitrary :: Gen c
8884
89−#if MIN_VERSION_servant(0,8,0)
9085instance (Arbitrary c, HasGenRequest b, ToHttpApiData c )
9186 => HasGenRequest (CaptureAll x c :> b) where
9287 genRequest _ = (oldf, do
@@ -97,7 +92,6 @@ instance (Arbitrary c, HasGenRequest b, ToHttpApiData c )
9792 where
9893 (oldf, old) = genRequest (Proxy :: Proxy b)
9994 new = arbitrary :: Gen [c]
100−#endif
10195
10296instance (Arbitrary c, KnownSymbol h, HasGenRequest b, ToHttpApiData c)
10397 => HasGenRequest (Header' mods h c :> b) where
@@ -174,6 +168,15 @@ instance (ReflectMethod method)
174168 , method = reflectMethod (Proxy :: Proxy method)
175169 })
176170
171+instance (ReflectMethod method)
172+ => HasGenRequest (NoContentVerb (method :: k)) where
173+ genRequest _ = (1, return $ \burl -> defaultRequest
174+ { host = cs $ baseUrlHost burl
175+ , port = baseUrlPort burl
176+ , secure = baseUrlScheme burl == Https
177+ , method = reflectMethod (Proxy :: Proxy method)
178+ })
179+
177180instance (HasGenRequest a) => HasGenRequest (RemoteHost :> a) where
178181 genRequest _ = genRequest (Proxy :: Proxy a)
179182
src/Servant/QuickCheck/Internal/Predicates.hs+14−15
@@ -84,15 +84,13 @@ notLongerThan maxAllowed
8484-- /Since 0.0.0.0/
8585onlyJsonObjects :: ResponsePredicate
8686onlyJsonObjects
87− = ResponsePredicate (\resp -> case go resp of
88− Nothing -> throw $ PredicateFailure "onlyJsonObjects" Nothing resp
89− Just () -> return ())
90− where
91− go r = do
92− ctyp <- lookup "content-type" (first foldedCase <$> responseHeaders r)
93− when ("application/json" `SBS.isPrefixOf` ctyp) $ do
94− (_ :: Object) <- decode (responseBody r)
95− return ()
87+ = ResponsePredicate (\resp -> do
88+ case lookup "content-type" (first foldedCase <$> responseHeaders resp) of
89+ Nothing -> return ()
90+ Just ctype -> when ("application/json" `SBS.isPrefixOf` ctype) $ do
91+ case (decode (responseBody resp) :: Maybe Object) of
92+ Nothing -> throw $ PredicateFailure "onlyJsonObjects" Nothing resp
93+ Just _ -> return ())
9694
9795-- | __Optional__
9896--
@@ -189,14 +187,15 @@ getsHaveLastModifiedHeader
189187notAllowedContainsAllowHeader :: RequestPredicate
190188notAllowedContainsAllowHeader
191189 = RequestPredicate $ \req mgr -> do
192− resp <- mapM (flip httpLbs mgr) $ [ req { method = renderStdMethod m }
193− | m <- [minBound .. maxBound ]
194− , renderStdMethod m /= method req ]
195− case filter pred' resp of
196− (x:_) -> throw $ PredicateFailure "notAllowedContainsAllowHeader" (Just req) x
190+ let reqs = [ req { method = renderStdMethod m } | m <- [minBound .. maxBound]
191+ , renderStdMethod m /= method req ]
192+ resp <- mapM (flip httpLbs mgr) reqs
193+
194+ case filter pred' (zip reqs resp) of
195+ (x:_) -> throw $ PredicateFailure "notAllowedContainsAllowHeader" (Just $ fst x) (snd x)
197196 [] -> return resp
198197 where
199− pred' resp = responseStatus resp == status405 && not (hasValidHeader "Allow" go resp)
198+ pred' (_, resp) = responseStatus resp == status405 && not (hasValidHeader "Allow" go resp)
200199 where
201200 go x = all (\y -> isRight $ parseMethod $ SBSC.pack y)
202201 $ wordsBy (`elem` (", " :: [Char])) (SBSC.unpack x)
src/Servant/QuickCheck/Internal/QuickCheck.hs+18−2
@@ -11,6 +11,9 @@ import Network.Wai.Handler.Warp (withApplication)
1111import Prelude.Compat
1212import Servant (Context (EmptyContext), HasServer,
1313 Server, serveWithContext)
14+#if MIN_VERSION_servant_server(0,18,0)
15+import Servant (DefaultErrorFormatters, ErrorFormatters, HasContextEntry, type (.++))
16+#endif
1417import Servant.Client (BaseUrl (..), Scheme (..))
1518import System.IO.Unsafe (unsafePerformIO)
1619import Test.Hspec (Expectation, expectationFailure)
@@ -37,7 +40,11 @@ withServantServer api = withServantServerAndContext api EmptyContext
3740-- application.
3841--
3942-- /Since 0.0.0.0/
43+#if MIN_VERSION_servant_server(0,18,0)
44+withServantServerAndContext :: (HasServer a ctx, HasContextEntry (ctx .++ DefaultErrorFormatters) ErrorFormatters)
45+#else
4046withServantServerAndContext :: HasServer a ctx
47+#endif
4148 => Proxy a -> Context ctx -> IO (Server a) -> (BaseUrl -> IO r) -> IO r
4249withServantServerAndContext api ctx server t
4350 = withApplication (return . serveWithContext api ctx =<< server) $ \port ->
@@ -92,7 +99,10 @@ serversEqual api burl1 burl2 args req = do
9299 expectationFailure $ "We failed to record a reason for failure: " <> show r
93100 GaveUp { numTests = n } -> expectationFailure $ "Gave up after " ++ show n ++ " tests"
94101 NoExpectedFailure {} -> expectationFailure "No expected failure"
102+#if MIN_VERSION_QuickCheck(2,12,0)
103+#else
95104 InsufficientCoverage {} -> expectationFailure "Insufficient coverage"
105+#endif
96106
97107-- | Check that a server satisfies the set of properties specified.
98108--
@@ -145,7 +155,10 @@ serverSatisfiesMgr api manager burl args preds = do
145155 expectationFailure $ "We failed to record a reason for failure: " <> show r
146156 GaveUp { numTests = n } -> expectationFailure $ "Gave up after " ++ show n ++ " tests"
147157 NoExpectedFailure {} -> expectationFailure $ "No expected failure"
148− InsufficientCoverage {} -> expectationFailure $ "Insufficient coverage"
158+#if MIN_VERSION_QuickCheck(2,12,0)
159+#else
160+ InsufficientCoverage {} -> expectationFailure "Insufficient coverage"
161+#endif
149162
150163serverDoesntSatisfy :: (HasGenRequest a) =>
151164 Proxy a -> BaseUrl -> Args -> Predicates -> Expectation
@@ -163,7 +176,10 @@ serverDoesntSatisfyMgr api manager burl args preds = do
163176 GaveUp { numTests = n } -> expectationFailure $ "Gave up after " ++ show n ++ " tests"
164177 Failure { output = m } -> expectationFailure $ "Failed:\n" ++ show m
165178 NoExpectedFailure {} -> expectationFailure $ "No expected failure"
166− InsufficientCoverage {} -> expectationFailure $ "Insufficient coverage"
179+#if MIN_VERSION_QuickCheck(2,12,0)
180+#else
181+ InsufficientCoverage {} -> expectationFailure "Insufficient coverage"
182+#endif
167183
168184noCheckStatus :: C.Request -> C.Request
169185#if MIN_VERSION_http_client(0,5,0)
stack.yaml+5−9
@@ -1,14 +1,10 @@
1−resolver: lts-11.8
1+resolver: nightly-2018-09-03
22packages:
33- '.'
44extra-deps:
5−- base-compat-batteries-0.10.1
6−- base-compat-0.10.1
7−- hspec-discover-2.5.0
8−- hspec-core-2.5.0
9−- hspec-2.5.0
10−# aeson pre-1.3.1.0 has an upper bound on `base-compat-batteries` that preclude
11−# the 0.10.1 that we depend on
12−- aeson-1.3.1.0
5+- hspec-discover-2.5.6
6+- hspec-core-2.5.6
7+- hspec-2.5.6
8+- QuickCheck-2.12
139flags: {}
1410extra-package-dbs: []
test/Servant/QuickCheck/InternalSpec.hs+9−12
@@ -23,12 +23,7 @@ import Test.QuickCheck.Gen (generate, unGen)
2323import Test.QuickCheck.Random (mkQCGen)
2424
2525
26−#if MIN_VERSION_servant(0,8,0)
27−import Servant.API.Internal.Test.ComprehensiveAPI (comprehensiveAPIWithoutRaw)
28−#else
29−import Servant.API.Internal.Test.ComprehensiveAPI (ComprehensiveAPI,
30− comprehensiveAPI)
31−#endif
26+import Servant.Test.ComprehensiveAPI (comprehensiveAPIWithoutStreamingOrRaw)
3227
3328import Servant.QuickCheck
3429import Servant.QuickCheck.Internal (genRequest, runGenRequest,
@@ -133,6 +128,10 @@ onlyJsonObjectSpec = describe "onlyJsonObjects" $ do
133128 withServantServerAndContext octetAPI ctx serverOctetAPI $ \burl ->
134129 serverSatisfies octetAPI burl args (onlyJsonObjects <%> mempty)
135130
131+ it "does not fail when there is no content-type" $ do
132+ withServantServerAndContext api2 ctx serverFailing $ \burl ->
133+ serverSatisfies api2 burl args (onlyJsonObjects <%> mempty)
134+
136135notLongerThanSpec :: Spec
137136notLongerThanSpec = describe "notLongerThan" $ do
138137
@@ -150,7 +149,7 @@ isComprehensiveSpec :: Spec
150149isComprehensiveSpec = describe "HasGenRequest" $ do
151150
152151 it "has instances for all 'servant' combinators" $ do
153− let _g = genRequest comprehensiveAPIWithoutRaw
152+ let _g = genRequest comprehensiveAPIWithoutStreamingOrRaw
154153 True `shouldBe` True -- This is a type-level check
155154
156155deepPathSpec :: Spec
@@ -274,6 +273,9 @@ server2 = return $ return 1
274273server3 :: IO (Server API2)
275274server3 = return $ return 2
276275
276+serverFailing :: IO (Server API2)
277+serverFailing = return . throwError $ err405
278+
277279-- With Doctypes
278280type HtmlDoctype = Get '[HTML] Blaze.Html
279281
@@ -367,8 +369,3 @@ noOfTestCases = 20000
367369#else
368370noOfTestCases = 1000
369371#endif
370−
371−#if !MIN_VERSION_servant(0,8,0)
372−comprehensiveAPIWithoutRaw :: Proxy ComprehensiveAPI
373−comprehensiveAPIWithoutRaw = comprehensiveAPI
374−#endif