From 41eddfedea8d303d53ca250814576a4e9d56212f Mon Sep 17 00:00:00 2001 From: Lucas David Traverso Date: Mon, 8 Jan 2024 03:50:18 -0300 Subject: [PATCH] Update for newer hspec and update version --- packages/hspec/CHANGELOG.md | 17 ++++++++++---- packages/hspec/conferer-hspec.cabal | 21 ++++++++++++------ packages/hspec/package.yaml | 15 +++++++++++-- .../hspec/src/Conferer/FromConfig/Hspec.hs | 22 +++++++++++++++++++ 4 files changed, 62 insertions(+), 13 deletions(-) diff --git a/packages/hspec/CHANGELOG.md b/packages/hspec/CHANGELOG.md index 565bde6..d3b35fc 100644 --- a/packages/hspec/CHANGELOG.md +++ b/packages/hspec/CHANGELOG.md @@ -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 @@ -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 diff --git a/packages/hspec/conferer-hspec.cabal b/packages/hspec/conferer-hspec.cabal index 1723ae6..7545991 100644 --- a/packages/hspec/conferer-hspec.cabal +++ b/packages/hspec/conferer-hspec.cabal @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/packages/hspec/package.yaml b/packages/hspec/package.yaml index 6d8389d..6e6c029 100644 --- a/packages/hspec/package.yaml +++ b/packages/hspec/package.yaml @@ -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: | @@ -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: diff --git a/packages/hspec/src/Conferer/FromConfig/Hspec.hs b/packages/hspec/src/Conferer/FromConfig/Hspec.hs index 0e0fe7e..5d82f7c 100644 --- a/packages/hspec/src/Conferer/FromConfig/Hspec.hs +++ b/packages/hspec/src/Conferer/FromConfig/Hspec.hs @@ -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 @@ -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 ] @@ -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{..}