test-sandbox 0.1.3 → 0.1.4
raw patch · 4 files changed
+52/−12 lines, 4 files
Files
- ChangeLog.md +8/−0
- src/Test/Sandbox/Internals.hs +3/−1
- test-sandbox.cabal +2/−2
- test/test.hs +39/−9
ChangeLog.md view
@@ -1,3 +1,11 @@+## 0.1.4++* Allow '.' and '-' for valid procsss name++## 0.1.3.1++* Replace nc with runhaskell+ ## 0.1.3 * Fix build failure with directory-1.2.2.0 which exposes findExecutables
src/Test/Sandbox/Internals.hs view
@@ -9,7 +9,9 @@ module Test.Sandbox.Internals where +#if __GLASGOW_HASKELL__ <= 708 import Control.Applicative (Applicative)+#endif import Control.Concurrent import Control.Exception.Lifted hiding (throwTo) import Control.Monad@@ -194,7 +196,7 @@ isValidProcessName s = not (null s) && isAlpha (head s) && all isAllowed (tail s)- where isAllowed c = isAlphaNum c || c == '_'+ where isAllowed c = isAlphaNum c || ( c `elem` ['_','-','.'] ) getProcess :: String -> Sandbox SandboxedProcess getProcess name = do
test-sandbox.cabal view
@@ -1,5 +1,5 @@ Name: test-sandbox-Version: 0.1.3+Version: 0.1.4 Cabal-Version: >= 1.14 Category: Testing Synopsis: Sandbox for system tests@@ -28,7 +28,7 @@ Source-Repository this Type: git Location: https://github.com/gree/haskell-test-sandbox- Tag: test-sandbox_0.1.3+ Tag: test-sandbox_0.1.4 Library Exposed-modules: Test.Sandbox
test/test.hs view
@@ -38,14 +38,29 @@ main = withSandbox $ \gref -> do hspec $ do describe "Basic Test" $ do- it "Run nc : port 12181" $ do+ it "Run server like nc : port 12181" $ do runSandbox' gref $ do file <- setFile "ncfile1"- [str|#!/usr/bin/env bash- |echo hoge | nc -l 12181+ [str|import Network+ |import System.IO+ |import Control.Monad+ |import Control.Concurrent+ |+ |main :: IO ()+ |main = withSocketsDo $ do+ | let val = "hoge\n"+ | sock <- listenOn $ PortNumber 12181+ | forever $ do+ | (handle, _host, _port) <- accept sock+ | forkFinally (talk handle val) (\_ -> hClose handle)+ | where+ | talk h val = do+ | hPutStr h val+ | v <- hGetContents h+ | putStr v |]- liftIO $ setExecuteMode file- start =<< register "ncserver1" file [] def { psCapture = Just CaptureStdout }+ --liftIO $ setExecuteMode file+ start =<< register "ncserver1" "runhaskell" [file] def { psCapture = Just CaptureStdout } it "isBinable' 12181" $ do I.isBindable' 12181 `shouldReturn` False it "isBinable' 12180" $ do@@ -59,12 +74,27 @@ p <- getPort "ncport" file <- setFile' "ncfile" [("port",p)]- [str|#!/usr/bin/env bash- |echo hoge | nc -l {{port}}+ [str|import Network+ |import System.IO+ |import Control.Monad+ |import Control.Concurrent+ |+ |main :: IO ()+ |main = withSocketsDo $ do+ | let val = "hoge\n"+ | sock <- listenOn $ PortNumber {{port}}+ | forever $ do+ | (handle, _host, _port) <- accept sock+ | forkFinally (talk handle val) (\_ -> hClose handle)+ | where+ | talk h val = do+ | hPutStr h val+ | v <- hGetContents h+ | putStr v |] liftIO $ I.isBindable p `shouldReturn` True- liftIO $ setExecuteMode file- start =<< register "ncserver" file [] def { psCapture = Just CaptureStdout }+ -- liftIO $ setExecuteMode file+ start =<< register "ncserver" "runhaskell" [file] def { psCapture = Just CaptureStdout } liftIO $ I.isBindable p `shouldReturn` False sendTo "ncport" "hogehoge\n" 1 `shouldReturn` "hoge\n" it "interactive Test by sandbox" $ do