git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Tests could be run in random order
72359d7Oleg Grenrus
psci/tests/Main.hs+3
@@ -24,8 +24,11 @@ import PSCi
24import Completion
24import Completion
25import Types
25import Types
26
26
27+import TestsSetup
28+
27main :: IO ()
29main :: IO ()
28main = do
30main = do
31+ fetchSupportCode
29 Counts{..} <- runTestTT allTests
32 Counts{..} <- runTestTT allTests
30 when (errors + failures > 0) exitFailure
33 when (errors + failures > 0) exitFailure
31
34
purescript.cabal+4−2
@@ -243,8 +243,9 @@ test-suite tests
243 Glob -any
243 Glob -any
244 type: exitcode-stdio-1.0
244 type: exitcode-stdio-1.0
245 main-is: Main.hs
245 main-is: Main.hs
246+ other-modules: TestsSetup
246 buildable: True
247 buildable: True
247− hs-source-dirs: tests
248+ hs-source-dirs: tests tests/common
248
249
249test-suite psci-tests
250test-suite psci-tests
250 build-depends: base >=4 && <5, containers -any, directory -any, filepath -any,
251 build-depends: base >=4 && <5, containers -any, directory -any, filepath -any,
@@ -254,6 +255,7 @@ test-suite psci-tests
254 Glob -any
255 Glob -any
255 type: exitcode-stdio-1.0
256 type: exitcode-stdio-1.0
256 main-is: Main.hs
257 main-is: Main.hs
258+ other-modules: TestsSetup
257 buildable: True
259 buildable: True
258− hs-source-dirs: psci psci/tests
260+ hs-source-dirs: psci psci/tests tests/common
259 ghc-options: -Wall
261 ghc-options: -Wall
tests/Main.hs+2−15
@@ -66,6 +66,8 @@ import qualified System.FilePath.Glob as Glob
66
66
67import Text.Parsec (ParseError)
67import Text.Parsec (ParseError)
68
68
69+import TestsSetup
70+
69modulesDir :: FilePath
71modulesDir :: FilePath
70modulesDir = ".test_modules" </> "node_modules"
72modulesDir = ".test_modules" </> "node_modules"
71
73
@@ -166,11 +168,6 @@ assertDoesNotCompile inputFiles foreigns = do
166 trim =
168 trim =
167 dropWhile isSpace >>> reverse >>> dropWhile isSpace >>> reverse
169 dropWhile isSpace >>> reverse >>> dropWhile isSpace >>> reverse
168
170
169−findNodeProcess :: IO (Maybe String)
170−findNodeProcess = runMaybeT . msum $ map (MaybeT . findExecutable) names
171− where
172− names = ["nodejs", "node"]
173−
174main :: IO ()
171main :: IO ()
175main = do
172main = do
176 fetchSupportCode
173 fetchSupportCode
@@ -205,16 +202,6 @@ main = do
205 in putStrLn $ fp' ++ ": " ++ err
202 in putStrLn $ fp' ++ ": " ++ err
206 exitFailure
203 exitFailure
207
204
208−fetchSupportCode :: IO ()
209−fetchSupportCode = do
210− setCurrentDirectory "tests/support"
211− callProcess "npm" ["install"]
212− -- Sometimes we run as a root (e.g. in simple docker containers)
213− -- And we are non-interactive: https://github.com/bower/bower/issues/1162
214− callProcess "node_modules/.bin/bower" ["--allow-root", "install", "--config.interactive=false"]
215− callProcess "node" ["setup.js"]
216− setCurrentDirectory "../.."
217−
218supportModules :: [String]
205supportModules :: [String]
219supportModules =
206supportModules =
220 [ "Control.Monad.Eff.Class"
207 [ "Control.Monad.Eff.Class"
tests/common/TestsSetup.hsnew file+41
@@ -0,0 +1,41 @@
1+-----------------------------------------------------------------------------
2+--
3+-- Module : Main
4+-- License : MIT (http://opensource.org/licenses/MIT)
5+--
6+-- Maintainer : Phil Freeman <paf31@cantab.net>
7+-- Stability : experimental
8+-- Portability :
9+--
10+-- |
11+--
12+-----------------------------------------------------------------------------
13+module TestsSetup where
14+
15+import Data.Maybe (fromMaybe)
16+import Control.Applicative
17+
18+import Control.Monad
19+
20+import Control.Applicative
21+
22+import Control.Monad.Trans.Maybe
23+
24+import System.Process
25+import System.Directory
26+
27+findNodeProcess :: IO (Maybe String)
28+findNodeProcess = runMaybeT . msum $ map (MaybeT . findExecutable) names
29+ where
30+ names = ["nodejs", "node"]
31+
32+fetchSupportCode :: IO ()
33+fetchSupportCode = do
34+ node <- fromMaybe (error "cannot find node executable") <$> findNodeProcess
35+ setCurrentDirectory "tests/support"
36+ callProcess "npm" ["install"]
37+ -- Sometimes we run as a root (e.g. in simple docker containers)
38+ -- And we are non-interactive: https://github.com/bower/bower/issues/1162
39+ callProcess "node_modules/.bin/bower" ["--allow-root", "install", "--config.interactive=false"]
40+ callProcess node ["setup.js"]
41+ setCurrentDirectory "../.."