git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #1382 from phadej/test-random-order
1c78f66Phil Freeman
.travis.yml+39−26
@@ -1,14 +1,32 @@
1+language: c
1sudo: false
2sudo: false
2−env:
3+matrix:
4+ include:
3− - GHCVER=7.8.4 COVERAGE_SUITE=tests
5+ - env: GHCVER=7.8.4 COVERAGE_SUITE=tests
6+ compiler: ": #GHC 7.8.4 - tests"
7+ # ^ HACK before https://github.com/travis-ci/travis-ci/issues/4393 is resolved
8+ addons: {apt: {packages: [cabal-install-1.22,ghc-7.8.4,happy-1.19.5,alex-3.1.4], sources: [hvr-ghc]}}
4− - GHCVER=7.8.4 COVERAGE_SUITE=psci-tests
9+ - env: GHCVER=7.8.4 COVERAGE_SUITE=psci-tests
5− - GHCVER=7.6.3
10+ compiler: ": #GHC 7.8.4 - psci-tests"
11+ addons: {apt: {packages: [cabal-install-1.22,ghc-7.8.4,happy-1.19.5,alex-3.1.4], sources: [hvr-ghc]}}
6− - GHCVER=7.10.1
12+ - env: GHCVER=7.8.4 STACKAGE=lts-22
13+ compiler: ": #GHC 7.8.4 - lts-2.22"
14+ addons: {apt: {packages: [cabal-install-1.22,ghc-7.8.4,happy-1.19.5,alex-3.1.4], sources: [hvr-ghc]}}
7− - GHCVER=7.8.4 STACKAGE=lts-2.22
15+ - env: GHCVER=7.6.3
16+ compiler: ": #GHC 7.6.3"
17+ addons: {apt: {packages: [cabal-install-1.22,ghc-7.6.3,happy-1.19.5,alex-3.1.4], sources: [hvr-ghc]}}
18+ - env: GHCVER=7.10.1
19+ compiler: ": #GHC 7.10.1"
20+ addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.1,happy-1.19.5,alex-3.1.4], sources: [hvr-ghc]}}
8− # 7.10.2 Pending https://github.com/travis-ci/apt-package-whitelist/pull/686
21+ # 7.10.2 Pending https://github.com/travis-ci/apt-package-whitelist/pull/686
9− - GHCVER=7.10.1 STACKAGE=lts-3.1
22+ - env: GHCVER=7.10.1 STACKAGE=lts=3.1 RUNSDISTTESTS=YES
23+ compiler: ": #GHC 7.10.1 lts-3.1"
24+ addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.1,happy-1.19.5,alex-3.1.4], sources: [hvr-ghc]}}
10− - GHCVER=7.10.1 STACKAGE=nightly-2015-08-12
25+ - env: GHCVER=7.10.1 STACKAGE=nightly-2015-08-12
26+ compiler: ": #GHC 7.10.1 nightly-2015-08-12"
27+ addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.1,happy-1.19.5,alex-3.1.4], sources: [hvr-ghc]}}
11before_install:
28before_install:
29+ - unset CC
12 - export PATH="/opt/ghc/$GHCVER/bin:$PATH"
30 - export PATH="/opt/ghc/$GHCVER/bin:$PATH"
13 - export PATH="/opt/cabal/1.22/bin:$PATH"
31 - export PATH="/opt/cabal/1.22/bin:$PATH"
14 - export PATH="$HOME/.cabal/bin:$PATH"
32 - export PATH="$HOME/.cabal/bin:$PATH"
@@ -23,13 +41,20 @@ install:
23 # cabal and ghc tries to use them all. Which is bad idea on a shared box.
41 # cabal and ghc tries to use them all. Which is bad idea on a shared box.
24 # See also: https://ghc.haskell.org/trac/ghc/ticket/9221
42 # See also: https://ghc.haskell.org/trac/ghc/ticket/9221
25 - sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
43 - sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
26− - mkdir -p sandboxes/$GHCVER/${STACKAGE:-none}
44+ # Cache sandboxes in ~/cabal-sandboxes
45+ # Move right sandbox to .cabal-sandbox if exists
46+ - if [ -d ~/cabal-sandboxes/$GHCVER-${STACKAGE:-none} ]; then
47+ mv ~/cabal-sandboxes/$GHCVER-${STACKAGE:-none} .cabal-sandbox;
48+ fi
49+ - mkdir -p .cabal-sandbox
27− - cabal sandbox init --sandbox sandboxes/$GHCVER/${STACKAGE:-none}
50+ - cabal sandbox init --sandbox .cabal-sandbox
28− # Download stackage cabal.config
51+ # Download stackage cabal.config, not sure whether filtering is necessary
29− # Not sure whether filtering out purescript is necessary
30 - if [ -n "$STACKAGE" ]; then curl http://www.stackage.org/$STACKAGE/cabal.config | grep -v purescript > cabal.config; fi
52 - if [ -n "$STACKAGE" ]; then curl http://www.stackage.org/$STACKAGE/cabal.config | grep -v purescript > cabal.config; fi
31 - cabal install --only-dependencies --enable-tests
53 - cabal install --only-dependencies --enable-tests
32 - cabal install hpc-coveralls
54 - cabal install hpc-coveralls
55+ # Snapshot state of the sandbox now, so we don't need to make new one for test install
56+ - rm -rf ~/cabal-sandboxes/$GHCVER-${STACKAGE:-none}
57+ - cp -r .cabal-sandbox ~/cabal-sandboxes/$GHCVER-${STACKAGE:-none}
33script:
58script:
34 - ./travis/configure.sh
59 - ./travis/configure.sh
35 - cabal build
60 - cabal build
@@ -50,18 +75,6 @@ deploy:
50 on:
75 on:
51 all_branches: true
76 all_branches: true
52 tags: true
77 tags: true
53−addons:
54− apt:
55− sources:
56− - hvr-ghc
57− packages:
58− - cabal-install-1.22
59− - ghc-7.6.3
60− - ghc-7.8.4
61− - ghc-7.10.1
62− - happy-1.19.5
63− - alex-3.1.4
64cache:
78cache:
65 directories:
79 directories:
66− - sandboxes/
67− - ../install-test/sandboxes/
80+ - ~/cabal-sandboxes
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 "../.."
travis/test-install.sh+11−6
@@ -1,13 +1,18 @@
1set -e
1set -e
2
2
3# Check that a source distribution can be successfully generated, and that
3# Check that a source distribution can be successfully generated, and that
4−# the generated source distribution can be installed
4+# the generated source distribution can be installed and tested
5cabal sdist
5cabal sdist
6if SRC_TGZ="$PWD/dist/$(cabal info . | awk '{print $2;exit}').tar.gz"
6if SRC_TGZ="$PWD/dist/$(cabal info . | awk '{print $2;exit}').tar.gz"
7then
7then
8+ if [ "$RUNSDISTTESTS" = "YES" ]; then
8− mkdir -p ../install-test
9+ mkdir test-install
9− cd ../install-test
10+ cd test-install
10− mkdir -p sandboxes/$GHCVER/${STACKAGE:-none}
11+ tar --strip-components=1 -xzf $SRC_TGZ
11− cabal sandbox init --sandbox sandboxes/$GHCVER/${STACKAGE:-none}
12+ cabal sandbox init --sandbox ../.cabal-sandbox
12− cabal install -j2 --ghc-options='+RTS -A32m -RTS' "$SRC_TGZ"
13+ cabal install --enable-tests --force-reinstalls
14+ cabal test
15+ else
16+ cabal install "$SRC_TGZ"
17+ fi
13fi
18fi