on 4bec310 help sign in
elk/tests/hs/LibTest.hs
30 lines 1.1 kB history raw
1module Main where
3import Control.Monad (unless)
4import Data.List (isInfixOf)
5import System.Directory
6import System.Exit
7import System.FilePath
8import System.Process
10import Elm.Internal.Paths as Elm
12main :: IO ()
13main = do
14 top <- getCurrentDirectory
15 let ioScript s = top</>"IO"</>s
16 runCmd "git submodule update --init"
17 out <- readProcess "npm" ["ls", "--parseable"] ""
18 unless ("jsdom" `isInfixOf` out) $ runCmd "npm install jsdom"
19 setCurrentDirectory $ top</>"tests"</>"elm"
20 runCmd $ concat [top</>"dist"</>"build"</>"elm"</>"elm --make --only-js --src-dir=" , top</>"automaton", " --src-dir=", top</>"IO", " --src-dir=", top</>"Elm-Test", " Test.elm"]
21 runCmd $ unwords ["cat ", ioScript "prescript.js", Elm.runtime, "build"</>"Test.js", ioScript "handler.js", "> exe.js"]
22 exitWith =<< waitForProcess =<< (runCommand "node exe.js")
23 where runCmd cmd = do
24 putStrLn cmd
25 exitCode <- waitForProcess =<< runCommand cmd
26 case exitCode of
27 ExitSuccess -> return ()
28 ExitFailure _ -> error "something went wrong"