From ee5f119e148ccc7584ac36cd081ce2fc9dde2bfd Mon Sep 17 00:00:00 2001 From: Jim Date: Wed, 27 Apr 2016 18:56:37 -0400 Subject: Testsuite fixes --- testkiki/testkiki.hs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'testkiki') diff --git a/testkiki/testkiki.hs b/testkiki/testkiki.hs index 64c1a6a..0b0f263 100644 --- a/testkiki/testkiki.hs +++ b/testkiki/testkiki.hs @@ -278,7 +278,9 @@ doTests tkConfig = hspec $ do copyFile "/etc/ssh/ssh_config" etcFile -- copy ssh_config to ssh_config.old, preserving timestamps (mtime0,etcFile0) <- saveFileInfo etcFile - let hasSubStr x file = B.isPrefixOf x . snd . B.breakSubstring x <$> B.readFile file + let hasSubStr x file = + doesFileExist file >>= + (bool (return False) $ B.isPrefixOf x . snd . B.breakSubstring x <$> B.readFile file) -- does it already mention /var/cache/kiki/ssh_known_hosts? expect not subStr0 <- etcFileBS `hasSubStr` "/var/cache/kiki/ssh_known_hosts" cokiki cfg ["ssh-client"] myStdErr @@ -333,14 +335,17 @@ doTests tkConfig = hspec $ do (\(_,h) -> hClose h) $ \(errfile,myStdErr) -> flip catch (\(e::SomeException) -> (do b <- hIsOpen myStdErr - x <- if b then do + x <- if b then try $ do x' <- hGetContents myStdErr hClose myStdErr return x' - else readFile errfile + else try $ readFile errfile :: IO (Either SomeException String) let e' = show e - if "Pending" `isPrefixOf` e' then throw e - else return (x,show e) + let showR (Right x) = show x + showR _ = "" + if ("Pending" `isPrefixOf` e' + || "HUnit" `isPrefixOf` e') then throw e + else return (showR x,show e) ) `shouldReturn` (drop len errfile,"EXCEPTION")) $ action myStdErr kiki'Env config args = do -- cgit v1.2.3