Skip to content

Commit

Permalink
Update for newer hspec and update version
Browse files Browse the repository at this point in the history
  • Loading branch information
ludat committed Jan 8, 2024
1 parent 594e1a9 commit 41eddfe
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 13 deletions.
17 changes: 13 additions & 4 deletions packages/hspec/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [PVP](https://pvp.haskell.org/).

## [Unreleased]
### Fixed
### Changed
### Added

## [v1.1.1.0] 2024-01-08

### Fixed

Expand All @@ -17,10 +22,14 @@ and this project adheres to [PVP](https://pvp.haskell.org/).

### Added

* `randomize` key is used for configuring `configRandomize`
* `"printSlowItems"`, `"quickCheckMaxShrinks"`, `"times"`, `"format"` configure
`configPrintSlowItems`, `configQuickCheckMaxShrinks`, `configTimes` and `configFormat`
respectively (for `hspec >= 2.8.0`)
* `"randomize"` key is used for configuring `configRandomize`
* `"printSlowItems"` key is used for configuring `configPrintSlowItems`
* `"quickCheckMaxShrinks"` key is used for configuring `configQuickCheckMaxShrinks`
* `"times"` key is used for configuring `configTimes`
* `"format"` key is used for configuring `configFormat`
* `"failOnEmptyDescription"` key is used for configuring `configFailOnEmptyDescription`
* `"expertMode"` key is used for configuring `configExpertMode`
* `"foformatException` key is used for configuring `configFormatException`

## [v1.1.0.0] 2021-03-07

Expand Down
21 changes: 14 additions & 7 deletions packages/hspec/conferer-hspec.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cabal-version: 1.18
-- see: https://github.com/sol/hpack

name: conferer-hspec
version: 1.1.0.0
version: 1.1.1.0
synopsis: conferer's FromConfig instances for hspec Config

description: Library to abstract the parsing of many haskell config values from different config sources
Expand All @@ -23,6 +23,11 @@ extra-doc-files:
CHANGELOG.md
LICENSE

flag no-hspec-api
description: Disable the hspec-api library dependency for older versions of hspec
manual: False
default: False

library
exposed-modules:
Conferer.FromConfig.Hspec
Expand All @@ -41,11 +46,12 @@ library
build-depends:
base >=4.3 && <5
, conferer >=1.1.0.0 && <2.0.0.0
, hspec-core >=2.0.0 && <2.11.0
, hspec-core >=2.0.0 && <2.12.0
, text >=1.1 && <2.2
default-language: Haskell2010
if impl(ghc >= 8.4.1)
ghc-options: -Wpartial-fields
if ! flag(no-hspec-api)
build-depends:
hspec-api

test-suite specs
type: exitcode-stdio-1.0
Expand All @@ -68,8 +74,9 @@ test-suite specs
, conferer >=1.1.0.0 && <2.0.0.0
, conferer-hspec
, hspec
, hspec-core >=2.0.0 && <2.11.0
, hspec-core >=2.0.0 && <2.12.0
, text >=1.1 && <2.2
default-language: Haskell2010
if impl(ghc >= 8.4.1)
ghc-options: -Wpartial-fields
if ! flag(no-hspec-api)
build-depends:
hspec-api
15 changes: 13 additions & 2 deletions packages/hspec/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: conferer-hspec
version: 1.1.0.0
version: 1.1.1.0
synopsis: |
conferer's FromConfig instances for hspec Config
description: |
Expand All @@ -9,11 +9,22 @@ _common/lib: !include ../../utils/package.common.yaml

<<: *everything

flags:
no-hspec-api:
description: Disable the hspec-api library dependency for older versions of hspec
default: false
manual: false


dependencies:
- base >= 4.3 && < 5
- conferer >= 1.1.0.0 && < 2.0.0.0
- text >= 1.1 && < 2.2
- hspec-core >= 2.0.0 && < 2.11.0
- hspec-core >= 2.0.0 && < 2.12.0

when:
- condition: '! flag(no-hspec-api)'
dependencies: hspec-api

tests:
specs:
Expand Down
22 changes: 22 additions & 0 deletions packages/hspec/src/Conferer/FromConfig/Hspec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ import Data.Dynamic (toDyn, Dynamic)
import qualified Test.Hspec.Core.Runner as Hspec
#if MIN_VERSION_hspec_core(2,8,0)
import qualified Test.Hspec.Core.Format as Hspec
#if MIN_VERSION_hspec_core(2,11,0)
import qualified Test.Hspec.Api.Formatters.V1 as FormattersV1
#else
import qualified Test.Hspec.Core.Formatters.V1 as FormattersV1
#endif
import qualified Test.Hspec.Core.Formatters.V2 as FormattersV2
#else
import qualified Test.Hspec.Core.Formatters as FormattersV1
Expand Down Expand Up @@ -157,6 +161,15 @@ desconstructHspecConfigToDefaults Hspec.Config{..} =
#if MIN_VERSION_hspec_core(2,10,6)
, ("diffContext", toDyn configDiffContext)
, ("externalDiff", toDyn configExternalDiff)
#endif
#if MIN_VERSION_hspec_core(2,11,0)
, ("failOnEmptyDescription", toDyn configFailOnEmptyDescription)
#endif
#if MIN_VERSION_hspec_core(2,11,2)
, ("expertMode", toDyn configExpertMode)
#endif
#if MIN_VERSION_hspec_core(2,11,5)
, ("formatException", toDyn configFormatException)
#endif
]

Expand Down Expand Up @@ -232,5 +245,14 @@ instance FromConfig Hspec.Config where
#if MIN_VERSION_hspec_core(2,10,6)
configDiffContext <- fetchFromConfig (key /. "diffContext") config
NotUserConfigurable configExternalDiff <- fetchFromConfig (key /. "externalDiff") config
#endif
#if MIN_VERSION_hspec_core(2,11,0)
configFailOnEmptyDescription <- fetchFromConfig (key /. "failOnEmptyDescription") config
#endif
#if MIN_VERSION_hspec_core(2,11,2)
configExpertMode <- fetchFromConfig (key /. "expertMode") config
#endif
#if MIN_VERSION_hspec_core(2,11,5)
NotUserConfigurable configFormatException <- fetchFromConfig (key /. "formatException") config
#endif
pure Hspec.Config{..}

0 comments on commit 41eddfe

Please sign in to comment.