diff --git a/freckle-app/CHANGELOG.md b/freckle-app/CHANGELOG.md index 4ee5fa1..881de16 100644 --- a/freckle-app/CHANGELOG.md +++ b/freckle-app/CHANGELOG.md @@ -1,11 +1,16 @@ -## [_Unreleased_](https://github.com/freckle/freckle-app/compare/freckle-app-v1.20.0.2...main) +## [_Unreleased_](https://github.com/freckle/freckle-app/compare/freckle-app-v1.20.1.0...main) -## [v1.20.0.2](https://github.com/freckle/freckle-app/compare/freckle-app-v1.20.0.1...freckle-app-v1.20.0.2) +## [v1.20.1.0](https://github.com/freckle/freckle-app/compare/freckle-app-v1.20.0.1...freckle-app-v1.20.1.0) + +Modules moving between packages: - `Freckle.App.Prelude` has moved to the `freckle-prelude` package - `Freckle.App.Exception(.*)` has moved to the `freckle-exception` package +- All moved modules are re-exported from `freckle-app`. -All moved modules are re-exported from `freckle-app`. +- Added `Freckle.App.Test.Hspec.AnnotatedException` (`unwrapAnnotatedHUnitFailure`). + It is recommended that all hspec test suites for packages that use `freckle-prelude` + add this spec hook. ## [v1.20.0.1](https://github.com/freckle/freckle-app/compare/freckle-app-v1.20.0.0...freckle-app-v1.20.0.1) diff --git a/freckle-app/freckle-app.cabal b/freckle-app/freckle-app.cabal index 9d1d2c3..647e646 100644 --- a/freckle-app/freckle-app.cabal +++ b/freckle-app/freckle-app.cabal @@ -5,7 +5,7 @@ cabal-version: 1.22 -- see: https://github.com/sol/hpack name: freckle-app -version: 1.20.0.1 +version: 1.20.1.0 synopsis: Haskell application toolkit used at Freckle description: Please see README.md category: Utils @@ -46,6 +46,7 @@ library Freckle.App.Stats.Rts Freckle.App.Test Freckle.App.Test.DocTest + Freckle.App.Test.Hspec.AnnotatedException Freckle.App.Test.Hspec.Runner Freckle.App.Test.Properties.JSON Freckle.App.Test.Properties.PathPiece @@ -97,6 +98,7 @@ library Blammo , Blammo-wai , Glob + , HUnit , MonadRandom , QuickCheck , aeson diff --git a/freckle-app/library/Freckle/App/Test/Hspec/AnnotatedException.hs b/freckle-app/library/Freckle/App/Test/Hspec/AnnotatedException.hs new file mode 100644 index 0000000..05bca4f --- /dev/null +++ b/freckle-app/library/Freckle/App/Test/Hspec/AnnotatedException.hs @@ -0,0 +1,22 @@ +module Freckle.App.Test.Hspec.AnnotatedException + ( unwrapAnnotatedHUnitFailure + ) where + +import Freckle.App.Prelude + +import Control.Exception qualified +import Freckle.App.Exception (AnnotatedException (..)) +import Test.HUnit.Lang (HUnitFailure) +import Test.Hspec + +-- | An hspec hook that lets hspec catch and pretty-print 'HUnitFailure', the +-- exception that is thrown when a test assertion fails +-- +-- Tests for any code that might throw 'AnnotatedException' (which includes anything +-- that uses freckle-app) should add this hook to their test suite. Without it, if +-- you end up with an @'AnnotatedException' 'HUnitFailure'@, hspec doesn't recognize +-- it as an assertion failure and you get ugly output instead of nice output. +unwrapAnnotatedHUnitFailure :: Spec -> Spec +unwrapAnnotatedHUnitFailure = around_ $ + Control.Exception.handle $ \AnnotatedException {exception = e} -> + Control.Exception.throw (e :: HUnitFailure) diff --git a/freckle-app/package.yaml b/freckle-app/package.yaml index 4cc88ad..635b55b 100644 --- a/freckle-app/package.yaml +++ b/freckle-app/package.yaml @@ -1,5 +1,5 @@ name: freckle-app -version: 1.20.0.1 +version: 1.20.1.0 maintainer: Freckle Education category: Utils github: freckle/freckle-app @@ -77,6 +77,7 @@ library: - Blammo - Blammo-wai - Glob + - HUnit - MonadRandom - QuickCheck - autodocodec