summaryrefslogtreecommitdiff
path: root/testkiki/testkiki.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2016-04-27 19:33:31 -0400
committerjoe <joe@jerkface.net>2016-04-27 19:33:31 -0400
commit7cb2a0f142d3999d06285c7a0e438bba8c765057 (patch)
tree370c1c528850c9d036e8a8d2751c94187a9d2980 /testkiki/testkiki.hs
parent4048a2857dbb3eddd78e864ad12fe8e04efc98d2 (diff)
parent7ce261e22cdfe09bb2b4daa7f6d1b42ed07d4f5f (diff)
Merge branch 'master' of oxio4inifatsetlx.onion:samizdat/kiki
Diffstat (limited to 'testkiki/testkiki.hs')
-rw-r--r--testkiki/testkiki.hs20
1 files changed, 12 insertions, 8 deletions
diff --git a/testkiki/testkiki.hs b/testkiki/testkiki.hs
index 64c1a6a..ea6ad80 100644
--- a/testkiki/testkiki.hs
+++ b/testkiki/testkiki.hs
@@ -268,7 +268,6 @@ doTests tkConfig = hspec $ do
268 gnuhome = home </> ".gnupg" 268 gnuhome = home </> ".gnupg"
269 cfg = cfg' { gnupghome = gnuhome } 269 cfg = cfg' { gnupghome = gnuhome }
270 etcFile = chroot cfg </> "etc" </> "ssh" </> "ssh_config" 270 etcFile = chroot cfg </> "etc" </> "ssh" </> "ssh_config"
271 etcFileBS = B.pack etcFile
272 -- dump stderr here 271 -- dump stderr here
273 withErrFile (takeDirectory (chroot cfg)) $ \myStdErr -> do 272 withErrFile (takeDirectory (chroot cfg)) $ \myStdErr -> do
274 -- initialize config file with actual systems 273 -- initialize config file with actual systems
@@ -278,16 +277,18 @@ doTests tkConfig = hspec $ do
278 copyFile "/etc/ssh/ssh_config" etcFile 277 copyFile "/etc/ssh/ssh_config" etcFile
279 -- copy ssh_config to ssh_config.old, preserving timestamps 278 -- copy ssh_config to ssh_config.old, preserving timestamps
280 (mtime0,etcFile0) <- saveFileInfo etcFile 279 (mtime0,etcFile0) <- saveFileInfo etcFile
281 let hasSubStr x file = B.isPrefixOf x . snd . B.breakSubstring x <$> B.readFile file 280 let hasSubStr file x =
281 doesFileExist file >>=
282 (bool (return False) $ B.isPrefixOf x . snd . B.breakSubstring x <$> B.readFile file)
282 -- does it already mention /var/cache/kiki/ssh_known_hosts? expect not 283 -- does it already mention /var/cache/kiki/ssh_known_hosts? expect not
283 subStr0 <- etcFileBS `hasSubStr` "/var/cache/kiki/ssh_known_hosts" 284 subStr0 <- etcFile `hasSubStr` "/var/cache/kiki/ssh_known_hosts"
284 cokiki cfg ["ssh-client"] myStdErr 285 cokiki cfg ["ssh-client"] myStdErr
285 -- get counts of lines subtracted, and lines added, expect (1,1) 286 -- get counts of lines subtracted, and lines added, expect (1,1)
286 (lost,gained) <- linesSubtractedAndAdded etcFile 287 (lost,gained) <- linesSubtractedAndAdded etcFile
287 -- did Sha1 change? expect it did 288 -- did Sha1 change? expect it did
288 bChanged <- compareSha1 etcFile 289 bChanged <- compareSha1 etcFile
289 -- does it mention /var/cache/kiki/ssh_known_hosts now? expect it does 290 -- does it mention /var/cache/kiki/ssh_known_hosts now? expect it does
290 subStr <- etcFileBS `hasSubStr` "/var/cache/kiki/ssh_known_hosts" 291 subStr <- etcFile `hasSubStr` "/var/cache/kiki/ssh_known_hosts"
291 -- new mtime 292 -- new mtime
292 mtime <- getModificationTime etcFile 293 mtime <- getModificationTime etcFile
293 (lost,gained,bChanged,(subStr0,subStr),compare mtime mtime0) `shouldBe` (1,1,True,(False,True),GT) 294 (lost,gained,bChanged,(subStr0,subStr),compare mtime mtime0) `shouldBe` (1,1,True,(False,True),GT)
@@ -333,14 +334,17 @@ doTests tkConfig = hspec $ do
333 (\(_,h) -> hClose h) $ \(errfile,myStdErr) -> 334 (\(_,h) -> hClose h) $ \(errfile,myStdErr) ->
334 flip catch (\(e::SomeException) -> (do 335 flip catch (\(e::SomeException) -> (do
335 b <- hIsOpen myStdErr 336 b <- hIsOpen myStdErr
336 x <- if b then do 337 x <- if b then try $ do
337 x' <- hGetContents myStdErr 338 x' <- hGetContents myStdErr
338 hClose myStdErr 339 hClose myStdErr
339 return x' 340 return x'
340 else readFile errfile 341 else try $ readFile errfile :: IO (Either SomeException String)
341 let e' = show e 342 let e' = show e
342 if "Pending" `isPrefixOf` e' then throw e 343 let showR (Right x) = show x
343 else return (x,show e) 344 showR _ = ""
345 if ("Pending" `isPrefixOf` e'
346 || "HUnit" `isPrefixOf` e') then throw e
347 else return (showR x,show e)
344 ) `shouldReturn` (drop len errfile,"EXCEPTION")) $ action myStdErr 348 ) `shouldReturn` (drop len errfile,"EXCEPTION")) $ action myStdErr
345 349
346 kiki'Env config args = do 350 kiki'Env config args = do