Skip to content

Commit

Permalink
cosmetic, get ready to migrate to libraries/
Browse files Browse the repository at this point in the history
  • Loading branch information
process-bot committed May 2, 2014
1 parent c02c704 commit caefc1c
Showing 1 changed file with 32 additions and 13 deletions.
45 changes: 32 additions & 13 deletions tests/compiler/LibTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,38 @@ import Elm.Internal.Paths as Elm
main :: IO ()
main = do
top <- getCurrentDirectory
let ioScript s = top</>"IO"</>s
runCmd "git submodule update --init"

-- setup submodules and npm
runCmd "git" ["submodule", "update", "--init"]
out <- readProcess "npm" ["ls", "--parseable"] ""
unless ("jsdom" `isInfixOf` out) $ runCmd "npm install jsdom"
setCurrentDirectory $ top</>"tests"</>"elm"
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"]
runCmd $ unwords ["cat ", ioScript "prescript.js", Elm.runtime, "build"</>"Test.js", ioScript "handler.js", "> exe.js"]
unless ("jsdom" `isInfixOf` out) $ runCmd "npm" ["install","jsdom"]

-- setup actual library tests
setCurrentDirectory $ top </> "tests" </> "libraries"
let localCompiler = joinPath [ top, "dist", "build", "elm", "elm" ]
runCmd localCompiler [ "--make"
, "--only-js"
, "--src-dir=" ++ top </> "automaton"
, "--src-dir=" ++ top </> "IO"
, "--src-dir=" ++ top </> "Elm-Test"
, "Test.elm"
]

-- run tests
let ioScript s = top </> "IO" </> s
files = [ ioScript "prescript.js"
, Elm.runtime
, "build" </> "Test.js"
, ioScript "handler.js"
]
exe <- readProcess "cat" files ""
writeFile "exe.js" exe
exitWith =<< waitForProcess =<< (runCommand "node exe.js")
where runCmd cmd = do
putStrLn cmd
exitCode <- waitForProcess =<< runCommand cmd
case exitCode of
ExitSuccess -> return ()
ExitFailure _ -> error "something went wrong"


runCmd :: String -> [String] -> IO ()
runCmd cmd args = do
putStrLn (cmd ++ " " ++ unwords args)
(exitCode, _stdout, stderr) <- readProcessWithExitCode cmd args ""
case exitCode of
ExitSuccess -> return ()
ExitFailure _ -> error stderr

0 comments on commit caefc1c

Please sign in to comment.