hspec 1.12.0 → 1.12.1
raw patch · 5 files changed
+33/−22 lines, 5 filesdep ~hspec-meta
Dependency ranges changed: hspec-meta
Files
- hspec-discover/src/Config.hs +6/−4
- hspec-discover/src/Run.hs +6/−6
- hspec-discover/test/ConfigSpec.hs +3/−3
- hspec-discover/test/RunSpec.hs +10/−6
- hspec.cabal +8/−3
hspec-discover/src/Config.hs view
@@ -12,20 +12,22 @@ configNested :: Bool , configFormatter :: Maybe String , configNoMain :: Bool+, configModuleName :: Maybe String } deriving (Eq, Show) defaultConfig :: Config-defaultConfig = Config False Nothing False+defaultConfig = Config False Nothing False Nothing options :: [OptDescr (Config -> Config)] options = [- Option [] ["nested"] (NoArg $ \c -> c {configNested = True}) ""+ Option [] ["nested"] (NoArg $ \c -> c {configNested = True}) "" , Option [] ["formatter"] (ReqArg (\s c -> c {configFormatter = Just s}) "FORMATTER") ""- , Option [] ["no-main"] (NoArg $ \c -> c {configNoMain = True}) ""+ , Option [] ["module-name"] (ReqArg (\s c -> c {configModuleName = Just s}) "NAME") ""+ , Option [] ["no-main"] (NoArg $ \c -> c {configNoMain = True}) "" ] usage :: String -> String-usage prog = "\nUsage: " ++ prog ++ " SRC CUR DST [--formatter=FORMATTER] [--no-main]\n"+usage prog = "\nUsage: " ++ prog ++ " SRC CUR DST [--module-name=NAME]\n" parseConfig :: String -> [String] -> Either String Config parseConfig prog args = case getOpt Permute options args of
hspec-discover/src/Run.hs view
@@ -59,6 +59,8 @@ . importList nodes . showString "import Test.Hspec.Discover\n" . maybe driver driverWithFormatter (configFormatter c)+ . showString "spec :: Spec\n"+ . showString "spec = " . formatSpecs nodes ) "\n" where@@ -66,11 +68,9 @@ case configNoMain c of False -> showString "main :: IO ()\n"- . showString "main = hspec $ "- True ->- showString "spec :: Spec\n"- . showString "spec = "- module_ = if configNoMain c then pathToModule src else "Main"+ . showString "main = hspec spec\n"+ True -> ""+ module_ = fromMaybe (if configNoMain c then pathToModule src else "Main") (configModuleName c) pathToModule f = let fileName = last $ splitDirectories f m:ms = takeWhile (/='.') fileName@@ -82,7 +82,7 @@ driverWithFormatter f = showString "import qualified " . showString (moduleName f) . showString "\n" . showString "main :: IO ()\n"- . showString "main = hspecWithFormatter " . showString f . showString " $ "+ . showString "main = hspecWithFormatter " . showString f . showString " spec\n" moduleName :: String -> String moduleName = reverse . dropWhile (== '.') . dropWhile (/= '.') . reverse
hspec-discover/test/ConfigSpec.hs view
@@ -25,21 +25,21 @@ parse ["--foo"] `shouldBe` (Left . unlines) [ "hspec-discover: unrecognized option `--foo'" , ""- , "Usage: hspec-discover SRC CUR DST [--formatter=FORMATTER] [--no-main]"+ , "Usage: hspec-discover SRC CUR DST [--module-name=NAME]" ] it "returns error message on unexpected argument" $ do parse ["foo"] `shouldBe` (Left . unlines) [ "hspec-discover: unexpected argument `foo'" , ""- , "Usage: hspec-discover SRC CUR DST [--formatter=FORMATTER] [--no-main]"+ , "Usage: hspec-discover SRC CUR DST [--module-name=NAME]" ] it "returns error message on --formatter=<fmt> with --no-main" $ do parse ["--no-main", "--formatter=foo"] `shouldBe` (Left . unlines) [ "hspec-discover: option `--formatter=<fmt>' does not make sense with `--no-main'" , ""- , "Usage: hspec-discover SRC CUR DST [--formatter=FORMATTER] [--no-main]"+ , "Usage: hspec-discover SRC CUR DST [--module-name=NAME]" ] context "when option is given multiple times" $ do
hspec-discover/test/RunSpec.hs view
@@ -6,7 +6,7 @@ import System.IO import System.Directory import System.FilePath-import Data.List (intercalate, sort)+import Data.List (sort) import Run hiding (Spec) import qualified Run@@ -36,8 +36,10 @@ , "import qualified FooSpec" , "import Test.Hspec.Discover" , "main :: IO ()"- , "main = hspec $" ++ unwords [- " postProcessSpec \"hspec-discover/test-data/nested-spec/Foo/Bar/BazSpec.hs\" (describe \"Foo.Bar.Baz\" Foo.Bar.BazSpec.spec)"+ , "main = hspec spec"+ , "spec :: Spec"+ , "spec = " ++ unwords [+ "postProcessSpec \"hspec-discover/test-data/nested-spec/Foo/Bar/BazSpec.hs\" (describe \"Foo.Bar.Baz\" Foo.Bar.BazSpec.spec)" , ">> postProcessSpec \"hspec-discover/test-data/nested-spec/Foo/BarSpec.hs\" (describe \"Foo.Bar\" Foo.BarSpec.spec)" , ">> postProcessSpec \"hspec-discover/test-data/nested-spec/FooSpec.hs\" (describe \"Foo\" FooSpec.spec)" ]@@ -51,7 +53,9 @@ , "module Main where" , "import Test.Hspec.Discover" , "main :: IO ()"- , "main = hspec $ return ()"+ , "main = hspec spec"+ , "spec :: Spec"+ , "spec = return ()" ] describe "getFilesRecursive" $ do@@ -91,10 +95,10 @@ describe "driverWithFormatter" $ do it "generates a test driver that uses a custom formatter" $ do- driverWithFormatter "Some.Module.formatter" "" `shouldBe` intercalate "\n" [+ driverWithFormatter "Some.Module.formatter" "" `shouldBe` unlines [ "import qualified Some.Module" , "main :: IO ()"- , "main = hspecWithFormatter Some.Module.formatter $ "+ , "main = hspecWithFormatter Some.Module.formatter spec" ] describe "moduleName" $ do
hspec.cabal view
@@ -1,5 +1,5 @@ name: hspec-version: 1.12.0+version: 1.12.1 license: MIT license-file: LICENSE copyright: (c) 2011-2014 Simon Hengel,@@ -7,7 +7,7 @@ (c) 2011 Greg Weber maintainer: Simon Hengel <sol@typeful.net> build-type: Simple-cabal-version: >= 1.8+cabal-version: >= 1.10 category: Testing stability: experimental bug-reports: https://github.com/hspec/hspec/issues@@ -79,6 +79,7 @@ Test.Hspec.Runner.Tree Test.Hspec.Formatters.Internal Test.Hspec.Timer+ default-language: Haskell2010 executable hspec-discover ghc-options:@@ -94,6 +95,7 @@ base == 4.* , filepath , directory+ default-language: Haskell2010 test-suite spec type:@@ -137,11 +139,12 @@ , hspec-expectations , async - , hspec-meta == 1.12.0+ , hspec-meta == 1.12.1 , process , directory , stringbuilder , ghc-paths+ default-language: Haskell2010 test-suite example type:@@ -156,6 +159,7 @@ base == 4.* , hspec , QuickCheck+ default-language: Haskell2010 test-suite hspec-discover-spec type:@@ -175,3 +179,4 @@ , filepath , directory , hspec-meta+ default-language: Haskell2010