hspec-discover 2.10.0.1 → 2.10.1
raw patch · 6 files changed
+38/−22 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- hspec-discover.cabal +1/−1
- src/Test/Hspec/Discover/Config.hs +2/−2
- src/Test/Hspec/Discover/Run.hs +8/−14
- src/Test/Hspec/Discover/Sort.hs +1/−1
- test/Test/Hspec/Discover/RunSpec.hs +25/−3
- version.yaml +1/−1
hspec-discover.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: hspec-discover-version: 2.10.0.1+version: 2.10.1 license: MIT license-file: LICENSE copyright: (c) 2012-2022 Simon Hengel
src/Test/Hspec/Discover/Config.hs view
@@ -35,9 +35,9 @@ parseConfig :: String -> [String] -> Either String Config parseConfig prog args = case getOpt Permute options args of (opts, [], []) -> let- c = (foldl (flip id) defaultConfig opts)+ c = foldl (flip id) defaultConfig opts in- if (configNoMain c && isJust (configFormatter c))+ if configNoMain c && isJust (configFormatter c) then formatError "option `--formatter=<fmt>' does not make sense with `--no-main'\n" else
src/Test/Hspec/Discover/Run.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, OverloadedStrings #-}+{-# LANGUAGE FlexibleInstances, OverloadedStrings #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -- | A preprocessor that finds and combines specs. --@@ -62,7 +62,7 @@ ( "{-# LINE 1 " . shows src . " #-}\n" . showString "{-# LANGUAGE NoImplicitPrelude #-}\n" . showString "{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}\n"- . showString ("module " ++ moduleName src conf ++" where\n")+ . showString ("module " ++ moduleName ++ exports ++ " where\n") . importList nodes . showString "import Test.Hspec.Discover\n" . maybe driver driverWithFormatter (configFormatter conf)@@ -71,15 +71,11 @@ . formatSpecs nodes ) "\n" where- driver =- case configNoMain conf of- False ->- showString "main :: IO ()\n"- . showString "main = hspec spec\n"- True -> ""--moduleName :: FilePath -> Config -> String-moduleName src conf = fromMaybe (if configNoMain conf then pathToModule src else "Main") (configModuleName conf)+ ifNoMain x y = if configNoMain conf then x else y+ defaultModuleName = ifNoMain (pathToModule src) "Main"+ moduleName = fromMaybe defaultModuleName (configModuleName conf)+ exports = " (" ++ ifNoMain "" "main, " ++ "spec)"+ driver = showString $ ifNoMain "" "main :: IO ()\nmain = hspec spec\n" -- | Derive module name from specified path. pathToModule :: FilePath -> String@@ -121,9 +117,7 @@ sequenceS = foldr (.) "" . intersperse " >> " formatSpecs :: Maybe [Spec] -> ShowS-formatSpecs specs = case specs of- Nothing -> "return ()"- Just xs -> fromForest xs+formatSpecs = maybe "return ()" fromForest where fromForest :: [Spec] -> ShowS fromForest = sequenceS . map fromTree
src/Test/Hspec/Discover/Sort.hs view
@@ -15,7 +15,7 @@ sortNaturallyBy :: (a -> (String, Int)) -> [a] -> [a] sortNaturallyBy f = sortBy (comparing ((\ (k, t) -> (naturalSortKey k, t)) . f)) -data NaturalSortKey = NaturalSortKey [Chunk]+newtype NaturalSortKey = NaturalSortKey [Chunk] deriving (Eq, Ord) data Chunk = Numeric Integer Int | Textual [(Char, Char)]
test/Test/Hspec/Discover/RunSpec.hs view
@@ -18,7 +18,7 @@ "{-# LINE 1 \"test/Spec.hs\" #-}" , "{-# LANGUAGE NoImplicitPrelude #-}" , "{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}"- , "module Main where"+ , "module Main (main, spec) where" , "import qualified FooSpec" , "import qualified Foo.BarSpec" , "import qualified Foo.Bar.BazSpec"@@ -33,6 +33,28 @@ ] ] + it "generates a test driver with no Main/main" $ do+ touch "test/FooSpec.hs"+ touch "test/Foo/Bar/BazSpec.hs"+ touch "test/Foo/BarSpec.hs"+ run ["test/Spec.hs", "", "out", "--no-main"]+ readFile "out" `shouldReturn` unlines [+ "{-# LINE 1 \"test/Spec.hs\" #-}"+ , "{-# LANGUAGE NoImplicitPrelude #-}"+ , "{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}"+ , "module Spec (spec) where"+ , "import qualified FooSpec"+ , "import qualified Foo.BarSpec"+ , "import qualified Foo.Bar.BazSpec"+ , "import Test.Hspec.Discover"+ , "spec :: Spec"+ , "spec = " ++ unwords [+ "describe \"Foo\" FooSpec.spec"+ , ">> describe \"Foo.Bar\" Foo.BarSpec.spec"+ , ">> describe \"Foo.Bar.Baz\" Foo.Bar.BazSpec.spec"+ ]+ ]+ it "generates a test driver with hooks" $ do touch "test/FooSpec.hs" touch "test/Foo/Bar/BazSpec.hs"@@ -44,7 +66,7 @@ "{-# LINE 1 \"test/Spec.hs\" #-}" , "{-# LANGUAGE NoImplicitPrelude #-}" , "{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}"- , "module Main where"+ , "module Main (main, spec) where" , "import qualified SpecHook" , "import qualified FooSpec" , "import qualified Foo.SpecHook"@@ -68,7 +90,7 @@ "{-# LINE 1 \"test/Spec.hs\" #-}" , "{-# LANGUAGE NoImplicitPrelude #-}" , "{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}"- , "module Main where"+ , "module Main (main, spec) where" , "import Test.Hspec.Discover" , "main :: IO ()" , "main = hspec spec"
version.yaml view
@@ -1,1 +1,1 @@-&version 2.10.0.1+&version 2.10.1