Permalink
Browse files

testing: run baysig tests

  • Loading branch information...
1 parent e3d5056 commit ebcb0a15a54224acb280a1d65c1cdde7f6e8a8ad Tom Nielsen committed Apr 6, 2012
Showing with 57 additions and 13 deletions.
  1. +7 −12 Vishnu/Cmds/Pull.hs
  2. +14 −0 Vishnu/Lib/Common.hs
  3. +32 −0 Vishnu/Lib/Testing.hs
  4. +4 −1 Vishnu/Vis.hs
View
@@ -5,29 +5,24 @@ import Control.Monad.Trans
import System.Directory
import System.Cmd
import Control.Monad.Reader
-
+import Data.List
import Vishnu.Lib.Common
import Vishnu.Lib.Repo
-perRepoFromArgs ma = do
- args <- fmap moreArgs ask
--- liftIO $ print args
- case args of
- [] -> perRepo ma
- repos -> mapM_ ma repos
-
-
-perRepo ma = do
- repos <- fmap words $ getConfig "localrepos" ""
- forM_ repos ma
pull :: VisM ()
pull = perRepoFromArgs $ \repo -> liftIO $ do
putStr $ repo ++ ": "
gotoHomeSubDir repo
system $ "git pull"
+diff :: VisM ()
+diff = perRepoFromArgs $ \repo -> liftIO $ do
+ gotoHomeSubDir repo
+ system $ "git diff"
+
+
showConf :: VisM ()
showConf = do
VisS conf _ _ <- ask
View
@@ -69,3 +69,17 @@ sh cmd = liftIO $ do (hin, hout, herr, ph) <- runInteractiveCommand cmd
" :",
serr
]
+
+perRepoFromArgs ma = do
+ args <- fmap moreArgs ask
+-- liftIO $ print args
+ case args of
+ [] -> perRepo ma
+ repos -> do localRepos <- fmap words $ getConfig "localrepos" ""
+ forM_ localRepos $ \lr->
+ when (any (`isPrefixOf` lr) repos) $ ma lr >> return ()
+
+
+perRepo ma = do
+ repos <- fmap words $ getConfig "localrepos" ""
+ forM_ repos ma
View
@@ -0,0 +1,32 @@
+module Vishnu.Lib.Testing where
+
+import Control.Monad
+import Control.Monad.Trans
+import System.Environment
+import System.Directory
+import Data.List
+import Data.Ord
+
+import Vishnu.Lib.Common
+import Vishnu.Lib.Repo
+
+test :: VisM ()
+test = perRepoFromArgs $ \repo -> do
+ liftIO $ gotoHomeSubDir repo
+ ex <- liftIO $ doesDirectoryExist "tests"
+ when ex $ runTestsIn repo
+
+runTestsIn repo = do
+ liftIO $ gotoHomeSubDir $ repo++"/tests"
+ files <- liftIO $ getDirectoryContents "."
+ liftIO$ putStrLn $ "Repo: "++repo
+ mapM_ dispatchTest files
+
+dispatchTest file | ".bug" `isSuffixOf` file = bugTest file
+ | otherwise = return ()
+
+bugTest file = do
+ liftIO $ putStrLn $ " file "++file
+ out <- sh $ "bays --test "++file
+ liftIO $ putStrLn $ unlines $ map (" "++) $ lines out
+ return ()
View
@@ -2,11 +2,14 @@ module Main where
import Vishnu.Lib.RunVis
+import Vishnu.Lib.Testing
import Vishnu.Cmds.Pull
main = runVis [("pull", pull),
("showconf", showConf),
("status", status),
- ("build", build) ]
+ ("build", build),
+ ("diff", diff),
+ ("test", test) ]

0 comments on commit ebcb0a1

Please sign in to comment.