packages feed

hspec-discover 2.7.10 → 2.8.0

raw patch · 4 files changed

+28/−28 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Test.Hspec.Discover.Run: [specFile] :: Spec -> FilePath
- Test.Hspec.Discover.Run: Spec :: FilePath -> String -> Spec
+ Test.Hspec.Discover.Run: Spec :: String -> Spec
- Test.Hspec.Discover.Run: fileToSpec :: FilePath -> FilePath -> Maybe Spec
+ Test.Hspec.Discover.Run: fileToSpec :: FilePath -> Maybe Spec

Files

hspec-discover.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:             hspec-discover-version:          2.7.10+version:          2.8.0 license:          MIT license-file:     LICENSE copyright:        (c) 2012-2021 Simon Hengel
src/Test/Hspec/Discover/Run.hs view
@@ -36,8 +36,7 @@   fromString = showString  data Spec = Spec {-  specFile :: FilePath-, specModule :: String+  specModule :: String } deriving (Eq, Show)  run :: [String] -> IO ()@@ -49,7 +48,9 @@         hPutStrLn stderr err         exitFailure       Right conf -> do-        when (configNested conf) (hPutStrLn stderr "hspec-discover: WARNING - The `--nested' option is deprecated and will be removed in a future release!")+        when (configNested conf)             (hPutStrLn stderr "hspec-discover: WARNING - The `--nested' option is deprecated and will be removed in a future release!")+        when (configNoMain conf)             (hPutStrLn stderr "hspec-discover: WARNING - The `--no-main' option is deprecated and will be removed in a future release!")+        when (isJust $ configFormatter conf) (hPutStrLn stderr "hspec-discover: WARNING - The `--formatter' option is deprecated and will be removed in a future release!")         specs <- findSpecs src         writeFile dst (mkSpecModule src conf specs)     _ -> do@@ -59,6 +60,7 @@ mkSpecModule :: FilePath -> Config -> [Spec] -> String mkSpecModule src conf nodes =   ( "{-# LINE 1 " . shows src . " #-}\n"+  . showString "{-# LANGUAGE NoImplicitPrelude #-}\n"   . showString "{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}\n"   . showString ("module " ++ moduleName src conf ++" where\n")   . importList nodes@@ -115,18 +117,18 @@  -- | Convert a spec to code. formatSpec :: Spec -> ShowS-formatSpec (Spec file name) = "postProcessSpec " . shows file . " (describe " . shows name . " " . showString name . "Spec.spec)"+formatSpec (Spec name) = "describe " . shows name . " " . showString name . "Spec.spec"  findSpecs :: FilePath -> IO [Spec] findSpecs src = do   let (dir, file) = splitFileName src-  mapMaybe (fileToSpec dir) . filter (/= file) <$> getFilesRecursive dir+  mapMaybe fileToSpec . filter (/= file) <$> getFilesRecursive dir -fileToSpec :: FilePath -> FilePath -> Maybe Spec-fileToSpec dir file = case reverse $ splitDirectories file of+fileToSpec :: FilePath -> Maybe Spec+fileToSpec file = case reverse $ splitDirectories file of   x:xs -> case stripSuffix "Spec.hs" x <|> stripSuffix "Spec.lhs" x of     Just name | isValidModuleName name && all isValidModuleName xs ->-      Just . Spec (dir </> file) $ (intercalate "." . reverse) (name : xs)+      Just . Spec $ (intercalate "." . reverse) (name : xs)     _ -> Nothing   _ -> Nothing   where
test/Test/Hspec/Discover/RunSpec.hs view
@@ -8,7 +8,7 @@ import           Data.List (sort)  import           Test.Hspec.Discover.Run hiding (Spec)-import qualified Test.Hspec.Discover.Run+import qualified Test.Hspec.Discover.Run as Run  main :: IO () main = hspec spec@@ -28,6 +28,7 @@       run ["test-data/nested-spec/Spec.hs", "", f]       readFile f `shouldReturn` unlines [           "{-# LINE 1 \"test-data/nested-spec/Spec.hs\" #-}"+        , "{-# LANGUAGE NoImplicitPrelude #-}"         , "{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}"         , "module Main where"         , "import qualified Foo.Bar.BazSpec"@@ -38,9 +39,9 @@         , "main = hspec spec"         , "spec :: Spec"         , "spec = " ++ unwords [-               "postProcessSpec \"test-data/nested-spec/Foo/Bar/BazSpec.hs\" (describe \"Foo.Bar.Baz\" Foo.Bar.BazSpec.spec)"-          , ">> postProcessSpec \"test-data/nested-spec/Foo/BarSpec.hs\" (describe \"Foo.Bar\" Foo.BarSpec.spec)"-          , ">> postProcessSpec \"test-data/nested-spec/FooSpec.hs\" (describe \"Foo\" FooSpec.spec)"+               "describe \"Foo.Bar.Baz\" Foo.Bar.BazSpec.spec"+          , ">> describe \"Foo.Bar\" Foo.BarSpec.spec"+          , ">> describe \"Foo\" FooSpec.spec"           ]         ] @@ -48,6 +49,7 @@       run ["test-data/empty-dir/Spec.hs", "", f]       readFile f `shouldReturn` unlines [           "{-# LINE 1 \"test-data/empty-dir/Spec.hs\" #-}"+        , "{-# LANGUAGE NoImplicitPrelude #-}"         , "{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}"         , "module Main where"         , "import Test.Hspec.Discover"@@ -72,37 +74,35 @@    describe "fileToSpec" $ do     it "converts path to spec name" $ do-      fileToSpec "" "FooSpec.hs" `shouldBe` Just (spec_ "FooSpec.hs" "Foo")+      fileToSpec "FooSpec.hs" `shouldBe` Just (Run.Spec "Foo")      it "rejects spec with empty name" $ do-      fileToSpec "" "Spec.hs" `shouldBe` Nothing+      fileToSpec "Spec.hs" `shouldBe` Nothing      it "works for lhs files" $ do-      fileToSpec "" "FooSpec.lhs" `shouldBe` Just (spec_ "FooSpec.lhs" "Foo")+      fileToSpec "FooSpec.lhs" `shouldBe` Just (Run.Spec "Foo")      it "returns Nothing for invalid spec name" $ do-      fileToSpec "" "foo" `shouldBe` Nothing+      fileToSpec "foo" `shouldBe` Nothing      context "when spec does not have a valid module name" $ do       it "returns Nothing" $ do-        fileToSpec "" "flycheck_Spec.hs" `shouldBe` Nothing+        fileToSpec "flycheck_Spec.hs" `shouldBe` Nothing      context "when any component of a hierarchical module name is not valid"$ do       it "returns Nothing" $ do-        fileToSpec "" ("Valid" </> "invalid"  </>"MiddleNamesSpec.hs") `shouldBe` Nothing+        fileToSpec ("Valid" </> "invalid"  </>"MiddleNamesSpec.hs") `shouldBe` Nothing      context "when path has directory component" $ do       it "converts path to spec name" $ do-        let file = "Foo" </> "Bar" </> "BazSpec.hs"-        fileToSpec "" file `shouldBe` Just (spec_ file "Foo.Bar.Baz")+        fileToSpec ("Foo" </> "Bar" </> "BazSpec.hs") `shouldBe` Just (Run.Spec "Foo.Bar.Baz")        it "rejects spec with empty name" $ do-        fileToSpec "" ("Foo" </> "Bar" </> "Spec.hs") `shouldBe` Nothing+        fileToSpec ("Foo" </> "Bar" </> "Spec.hs") `shouldBe` Nothing    describe "findSpecs" $ do     it "finds specs" $ do-      let dir = "test-data/nested-spec"-      findSpecs (dir </> "Spec.hs") `shouldReturn` [spec_ (dir </> "Foo/Bar/BazSpec.hs") "Foo.Bar.Baz", spec_ (dir </> "Foo/BarSpec.hs") "Foo.Bar", spec_ (dir </> "FooSpec.hs") "Foo"]+      findSpecs ("test-data" </> "nested-spec" </> "Spec.hs") `shouldReturn` [Run.Spec "Foo.Bar.Baz", Run.Spec "Foo.Bar", Run.Spec "Foo"]    describe "driverWithFormatter" $ do     it "generates a test driver that uses a custom formatter" $ do@@ -118,9 +118,7 @@    describe "importList" $ do     it "generates imports for a list of specs" $ do-      importList [spec_ "FooSpec.hs" "Foo", spec_ "BarSpec.hs" "Bar"] "" `shouldBe` unlines [+      importList [Run.Spec "Foo", Run.Spec "Bar"] "" `shouldBe` unlines [           "import qualified FooSpec"         , "import qualified BarSpec"         ]-  where-    spec_ = Test.Hspec.Discover.Run.Spec
version.yaml view
@@ -1,1 +1,1 @@-&version 2.7.10+&version 2.8.0