packages feed

hspec-server 0.2.1 → 0.2.2

raw patch · 3 files changed

+29/−14 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Test/Hspec/Server/Command.hs view
@@ -1,6 +1,7 @@ module Test.Hspec.Server.Command where  import System.Exit+import Control.Monad import Control.Monad.IO.Class import Data.Monoid import Text.Regex.Posix@@ -10,7 +11,9 @@ package :: ServerType dat => String -> ServerExample dat ServerStatus package pkg = do   dat <- getServerData-  (_,out,_) <- liftIO $ cmd dat "dpkg" ["-l",pkg] []+  c@(code,out,_) <- liftIO $ cmd dat "dpkg" ["-l",pkg] []+  when (code /= ExitSuccess) $ do+    error $ "pacakge error:" ++ show c   if or (map (\v -> v  =~ ("^ii +" <> pkg <> " ")) (lines out))     then return Installed     else return None@@ -26,7 +29,9 @@ service :: ServerType dat => String -> ServerExample dat ServerStatus service s = do   dat <- getServerData-  (_,out,_) <- liftIO $ cmd dat ("/etc/init.d/"++s) ["status"] []+  c@(code,out,_) <- liftIO $ cmd dat ("/etc/init.d/"++s) ["status"] []+  when (code /= ExitSuccess) $ do+    error $ "service error:" ++ show c   if or (map (\v ->                (v  =~ ("is running" :: String)) ||                (v  =~ ("start/running" :: String))@@ -37,7 +42,9 @@ port :: ServerType dat => Int -> ServerExample dat ServerStatus port p = do   dat <- getServerData-  (_,out,_) <- liftIO $ cmd dat "netstat" ["-tanp"] []+  c@(code,out,_) <- liftIO $ cmd dat "netstat" ["-tanp"] []+  when (code /= ExitSuccess) $ do+    error $ "port error:" ++ show c   if or (map (\v ->                (v  =~ ("^tcp[ 6] +[0-9]+ +[0-9]+ :::" <> show p <> " +[^ ]+ +LISTEN")) ||                (v  =~ ("^tcp[ 6] +[0-9]+ +[0-9]+ [0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+:" <> show p <> " +[^ ]+ +LISTEN"))
Test/Hspec/Server/Type.hs view
@@ -6,6 +6,7 @@ import Control.Monad.Trans.Writer import qualified Test.Hspec.Core.Spec as Hspec +import Control.Monad import Data.Monoid import Data.List import Data.Maybe@@ -122,16 +123,23 @@  detectOS :: ServerType dat => dat -> IO (Maybe ServerOS) detectOS dat = do-  (_,out,_) <- cmd dat "sh" ["-c","echo $OSTYPE"] []-  case (head (lines out)) of-    "linux-gnu" -> detectLinux dat-    'd':'a':'r':'w':'i':'n':o -> return $ Just $ MacOS o-    "msys" -> return $ Just $ Windows "msys"-    "cygwin" -> return $ Just $ Windows "cygwin"-    "win32" -> return $ Just $ Windows "win32"-    "win64" -> return $ Just $ Windows "win64"-    'f':'r':'e':'e':'b':'s':'d':o -> return $ Just $ FreeBSD o-    o -> return $ Just $ OtherOS o+  v@(code,out,_) <- cmd dat "sh" ["-c","echo $OSTYPE"] []+  when (code /= ExitSuccess) $ do+    error $ "detectOS's error;" ++ show v+  case listToMaybe (lines out) of+    Just str -> checkEnv str+    Nothing -> return Nothing+  where+    checkEnv str =   +      case str of+        "linux-gnu" -> detectLinux dat+        'd':'a':'r':'w':'i':'n':o -> return $ Just $ MacOS o+        "msys" -> return $ Just $ Windows "msys"+        "cygwin" -> return $ Just $ Windows "cygwin"+        "win32" -> return $ Just $ Windows "win32"+        "win64" -> return $ Just $ Windows "win64"+        'f':'r':'e':'e':'b':'s':'d':o -> return $ Just $ FreeBSD o+        o -> return $ Just $ OtherOS o  detectLinux :: ServerType dat => dat -> IO (Maybe ServerOS) detectLinux dat = do
hspec-server.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                hspec-server-version:             0.2.1+version:             0.2.2 synopsis:            Test Framework for Server's status description:         Hspec-Server is test framework for checking server's status.                      It is inspired by the Ruby library ServerSpec.