git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Tests could be run in random order
commit72359d72fd3679024cc71d4776434785b5569fbe authorOleg Grenrus <oleg.grenrus@iki.fi> dateFri 14 Aug 2015, 06:39 (11 years ago) parent7e8e8ca
4 files changed+50−17
psci/tests/Main.hs+3 purescript.cabal+4−2 tests/Main.hs+2−15 tests/common/TestsSetup.hs+41
psci/tests/Main.hs+3
@@ -24,8 +24,11 @@ import PSCi
2424import Completion
2525import Types
2626
27+import TestsSetup
28+
2729main :: IO ()
2830main = do
31+ fetchSupportCode
2932 Counts{..} <- runTestTT allTests
3033 when (errors + failures > 0) exitFailure
3134
purescript.cabal+4−2
@@ -243,8 +243,9 @@ test-suite tests
243243 Glob -any
244244 type: exitcode-stdio-1.0
245245 main-is: Main.hs
246+ other-modules: TestsSetup
246247 buildable: True
247− hs-source-dirs: tests
248+ hs-source-dirs: tests tests/common
248249
249250test-suite psci-tests
250251 build-depends: base >=4 && <5, containers -any, directory -any, filepath -any,
@@ -254,6 +255,7 @@ test-suite psci-tests
254255 Glob -any
255256 type: exitcode-stdio-1.0
256257 main-is: Main.hs
258+ other-modules: TestsSetup
257259 buildable: True
258− hs-source-dirs: psci psci/tests
260+ hs-source-dirs: psci psci/tests tests/common
259261 ghc-options: -Wall
tests/Main.hs+2−15
@@ -66,6 +66,8 @@ import qualified System.FilePath.Glob as Glob
6666
6767import Text.Parsec (ParseError)
6868
69+import TestsSetup
70+
6971modulesDir :: FilePath
7072modulesDir = ".test_modules" </> "node_modules"
7173
@@ -166,11 +168,6 @@ assertDoesNotCompile inputFiles foreigns = do
166168 trim =
167169 dropWhile isSpace >>> reverse >>> dropWhile isSpace >>> reverse
168170
169−findNodeProcess :: IO (Maybe String)
170−findNodeProcess = runMaybeT . msum $ map (MaybeT . findExecutable) names
171− where
172− names = ["nodejs", "node"]
173−
174171main :: IO ()
175172main = do
176173 fetchSupportCode
@@ -205,16 +202,6 @@ main = do
205202 in putStrLn $ fp' ++ ": " ++ err
206203 exitFailure
207204
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−
218205supportModules :: [String]
219206supportModules =
220207 [ "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 "../.."