module Collage.Commands.Test (runTest) where import Control.Monad (forM_) import qualified Data.Text as T import qualified System.Process as Sys import Collage.Opts import Collage.Config dbg :: [String] -> IO () dbg = putStrLn . unwords runTest :: Config -> Options -> IO () runTest conf _ = do dbg ["testing", T.unpack (confDocument conf) ] forM_ (confSources conf) $ \ samp -> do dbg ["-", "building source", T.unpack (sourceName samp) ] runCommand samp runCommand :: Source -> IO () runCommand src = do forM_ (sourceCommands src) $ \ln -> do dbg [" ", "- running", show ln] let process = (Sys.shell ln) { Sys.cwd = Just ("example/" ++ sourceDir src) } (_, _, _, h) <- Sys.createProcess process Sys.waitForProcess h