packages feed

hspec-meta 1.8.1 → 1.8.2

raw patch · 5 files changed

+34/−10 lines, 5 files

Files

LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2011-2013 Simon Hengel <sol@typeful.net>+Copyright (c) 2011-2014 Simon Hengel <sol@typeful.net> Copyright (c) 2011-2012 Trystan Spangler <trystan.s@comcast.net> Copyright (c) 2011-2011 Greg Weber <greg@gregweber.info> 
hspec-discover/src/Config.hs view
@@ -5,28 +5,38 @@ , usage ) where +import           Data.Maybe import           System.Console.GetOpt  data Config = Config {   configNested :: Bool , configFormatter :: Maybe String+, configNoMain :: Bool } deriving (Eq, Show)  defaultConfig :: Config-defaultConfig = Config False Nothing+defaultConfig = Config False Nothing False  options :: [OptDescr (Config -> Config)] options = [     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}) ""   ]  usage :: String -> String-usage prog = "\nUsage: " ++ prog ++ " SRC CUR DST [--formatter=FORMATTER]\n"+usage prog = "\nUsage: " ++ prog ++ " SRC CUR DST [--formatter=FORMATTER] [--no-main]\n"  parseConfig :: String -> [String] -> Either String Config parseConfig prog args = case getOpt Permute options args of-    (opts, [], []) -> Right (foldl (flip id) defaultConfig opts)+    (opts, [], []) -> let+        c = (foldl (flip id) defaultConfig opts)+      in+        if (configNoMain c && isJust (configFormatter c))+           then+             formatError "option `--formatter=<fmt>' does not make sense with `--no-main'\n"+           else+             Right c     (_, _, err:_)  -> formatError err     (_, arg:_, _)  -> formatError ("unexpected argument `" ++ arg ++ "'\n")   where
hspec-discover/src/Run.hs view
@@ -15,6 +15,7 @@ import           Control.Monad import           Control.Applicative import           Data.List+import           Data.Char import           Data.Maybe import           Data.String import           System.Environment@@ -49,7 +50,7 @@ mkSpecModule :: FilePath -> Config -> [Spec] -> String mkSpecModule src c nodes =   ( "{-# LINE 1 " . shows src . " #-}"-  . showString "module Main where\n"+  . showString ("module " ++ module_ ++" where\n")   . importList nodes   . maybe driver (driverWithFormatter (null nodes)) (configFormatter c)   . formatSpecs nodes@@ -57,8 +58,19 @@   where     driver =         showString "import Test.Hspec.Meta\n"-      . showString "main :: IO ()\n"-      . showString "main = hspec $ "+      . 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"+    pathToModule f = let+        fileName = last $ splitDirectories f+        m:ms = takeWhile (/='.') fileName+     in+        toUpper m:ms  driverWithFormatter :: Bool -> String -> ShowS driverWithFormatter isEmpty f =
hspec-meta.cabal view
@@ -1,8 +1,8 @@ name:             hspec-meta-version:          1.8.1+version:          1.8.2 license:          MIT license-file:     LICENSE-copyright:        (c) 2011-2013 Simon Hengel,+copyright:        (c) 2011-2014 Simon Hengel,                   (c) 2011-2012 Trystan Spangler,                   (c) 2011 Greg Weber maintainer:       Simon Hengel <sol@typeful.net>
src/Test/Hspec.hs view
@@ -30,6 +30,8 @@ , hspec ) where +import           Control.Exception (finally)+ import           Test.Hspec.Core.Type hiding (describe, it) import           Test.Hspec.Runner import           Test.Hspec.HUnit ()@@ -84,7 +86,7 @@  -- | Run a custom action after every spec item. after :: IO () -> Spec -> Spec-after action = around (>> action)+after action = around (`finally` action)  -- | Run a custom action before and/or after every spec item. around :: (IO () -> IO ()) -> Spec -> Spec