Test.hs 763 B

1234567891011121314151617181920212223242526
  1. module Collage.Commands.Test (runTest) where
  2. import Control.Monad (forM_)
  3. import qualified Data.Text as T
  4. import qualified System.Process as Sys
  5. import Collage.Opts
  6. import Collage.Config
  7. dbg :: [String] -> IO ()
  8. dbg = putStrLn . unwords
  9. runTest :: Config -> Options -> IO ()
  10. runTest conf _ = do
  11. dbg ["testing", T.unpack (confDocument conf) ]
  12. forM_ (confSources conf) $ \ samp -> do
  13. dbg ["-", "building source", T.unpack (sourceName samp) ]
  14. runCommand samp
  15. runCommand :: Source -> IO ()
  16. runCommand src = do
  17. forM_ (sourceCommands src) $ \ln -> do
  18. dbg [" ", "- running", show ln]
  19. let process = (Sys.shell ln) { Sys.cwd = Just ("example/" ++ sourceDir src) }
  20. (_, _, _, h) <- Sys.createProcess process
  21. Sys.waitForProcess h