@@ -12,19 +12,38 @@ import Elm.Internal.Paths as Elm
12main :: IO ()
12main :: IO ()
14 top <- getCurrentDirectory
14 top <- getCurrentDirectory
15− let ioScript s = top</>"IO"</>s
15+
16+ -- setup submodules and npm
16− runCmd "git submodule update --init"
17+ runCmd "git" ["submodule", "update", "--init"]
17 out <- readProcess "npm" ["ls", "--parseable"] ""
18 out <- readProcess "npm" ["ls", "--parseable"] ""
18− unless ("jsdom" `isInfixOf` out) $ runCmd "npm install jsdom"
19+ unless ("jsdom" `isInfixOf` out) $ runCmd "npm" ["install","jsdom"]
21+ -- setup actual library tests
19− setCurrentDirectory $ top</>"tests"</>"elm"
22+ setCurrentDirectory $ top </> "tests" </> "libraries"
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"]
23+ let localCompiler = joinPath [ top, "dist", "build", "elm", "elm" ]
21− runCmd $ unwords ["cat ", ioScript "prescript.js", Elm.runtime, "build"</>"Test.js", ioScript "handler.js", "> exe.js"]
24+ runCmd localCompiler [ "--make"
26+ , "--src-dir=" ++ top </> "automaton"
27+ , "--src-dir=" ++ top </> "IO"
28+ , "--src-dir=" ++ top </> "Elm-Test"
33+ let ioScript s = top </> "IO" </> s
34+ files = [ ioScript "prescript.js"
36+ , "build" </> "Test.js"
37+ , ioScript "handler.js"
39+ exe <- readProcess "cat" files ""
40+ writeFile "exe.js" exe
22 exitWith =<< waitForProcess =<< (runCommand "node exe.js")
41 exitWith =<< waitForProcess =<< (runCommand "node exe.js")
23− where runCmd cmd = do
25− exitCode <- waitForProcess =<< runCommand cmd
27− ExitSuccess -> return ()
28− ExitFailure _ -> error "something went wrong"
30−
43+runCmd :: String -> [String] -> IO ()
45+ putStrLn (cmd ++ " " ++ unwords args)
46+ (exitCode, _stdout, stderr) <- readProcessWithExitCode cmd args ""
48+ ExitSuccess -> return ()
49+ ExitFailure _ -> error stderr