hspec-core 2.10.0 → 2.10.0.1
raw patch · 4 files changed
+77/−9 lines, 4 files
Files
- hspec-core.cabal +1/−1
- src/Test/Hspec/Core/Hooks.hs +7/−5
- test/Test/Hspec/Core/HooksSpec.hs +68/−2
- version.yaml +1/−1
hspec-core.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: hspec-core-version: 2.10.0+version: 2.10.0.1 license: MIT license-file: LICENSE copyright: (c) 2011-2022 Simon Hengel,
src/Test/Hspec/Core/Hooks.hs view
@@ -173,11 +173,13 @@ release :: IO () release = do- signal doCleanupNow- r <- takeMVar released- case r of- Released -> return ()- ExceptionDuringRelease err -> throwIO err+ acquireHasNotBeenCalled <- isEmptyMVar acquired -- NOTE: This can happen if an outer beforeAll fails+ unless acquireHasNotBeenCalled $ do+ signal doCleanupNow+ r <- takeMVar released+ case r of+ Released -> return ()+ ExceptionDuringRelease err -> throwIO err return (acquire, release)
test/Test/Hspec/Core/HooksSpec.hs view
@@ -504,6 +504,36 @@ , "after" ] + it "wrap actions around a spec in order" $ do+ (rec, retrieve) <- mkAppend+ let action i inner = rec ("before " <> i) *> inner <* rec ("after " <> i)+ evalSpec_ $ H.aroundAll_ (action "1") $ H.aroundAll_ (action "2") $ do+ H.it "foo" $ rec "foo"+ H.it "bar" $ rec "bar"+ retrieve `shouldReturn` [+ "before 1"+ , "before 2"+ , "foo"+ , "bar"+ , "after 2"+ , "after 1"+ ]++ it "does not call actions wrapped around a failing action" $ do+ (rec, retrieve) <- mkAppend+ let action i inner = rec ("before " <> i) *> inner <* rec ("after " <> i)+ evalSpec_ $+ H.aroundAll_ (action "1") $+ H.aroundAll_ (action "2 failing" . const throwException) $+ H.aroundAll_ (action "3") $ do+ H.it "foo" $ rec "foo"+ H.it "bar" $ rec "bar"+ retrieve `shouldReturn` [+ "before 1"+ , "before 2 failing"+ , "after 1"+ ]+ it "does not memoize subject" $ do mock <- newMock let action :: IO Int@@ -557,6 +587,36 @@ ] mockCounter mock `shouldReturn` 3 + it "wrap actions around a spec in order" $ do+ (rec, retrieve) <- mkAppend+ let action i inner a = rec ("before " <> i) *> inner a <* rec ("after " <> i)+ evalSpec_ $ H.aroundAllWith (action "1") $ H.aroundAllWith (action "2") $ do+ H.it "foo" $ rec "foo"+ H.it "bar" $ rec "bar"+ retrieve `shouldReturn` [+ "before 1"+ , "before 2"+ , "foo"+ , "bar"+ , "after 2"+ , "after 1"+ ]++ it "does not call actions wrapped around a failing action" $ do+ (rec, retrieve) <- mkAppend+ let action i inner a = rec ("before " <> i) *> inner a <* rec ("after " <> i)+ evalSpec_ $+ H.aroundAllWith (action "1") $+ H.aroundAllWith (action "2 failing" . const . const throwException) $+ H.aroundAllWith (action "3") $ do+ H.it "foo" $ rec "foo"+ H.it "bar" $ rec "bar"+ retrieve `shouldReturn` [+ "before 1"+ , "before 2 failing"+ , "after 1"+ ]+ it "reports exceptions on acquire" $ do evalSpec $ do H.aroundAllWith (\ action () -> throwException >>= action) $ do@@ -578,9 +638,15 @@ describe "decompose" $ do it "decomposes a with-style action into acquire / release" $ do (acquire, release) <- H.decompose $ \ action x -> do- action (x + 42)- acquire 23 `shouldReturn` (65 :: Int)+ action (x + 42 :: Int)+ acquire 23 `shouldReturn` 65 release++ context "when release is called before acquire" $ do+ it "does nothing" $ do+ (_, release) <- H.decompose $ \ action x -> do+ action (x + 42 :: Int)+ release context "with an exception during resource acquisition" $ do it "propagates that exception" $ do
version.yaml view
@@ -1,1 +1,1 @@-&version 2.10.0+&version 2.10.0.1