aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2015-08-21 09:26:50 +0200
committerDaniel Gröber <dxld@darkboxed.org>2015-08-21 09:30:50 +0200
commit8aaf5142f1593b1a32f220173a4196119c67c124 (patch)
tree370975ceef90c01a8dd5dac48e96cd8ad12c3fa3
parentc7aba0dbaaf7889e2cc653bf203e4b046b9a5029 (diff)
spec: Compile with every Cabal version under the sun
-rw-r--r--.travis.yml18
-rw-r--r--cabal-helper.cabal13
-rw-r--r--tests/Spec.hs74
3 files changed, 104 insertions, 1 deletions
diff --git a/.travis.yml b/.travis.yml
index d48e656..04b16d4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,6 +4,21 @@ ghc:
- 7.6
- 7.8
+sudo: false
+
+addons:
+ apt:
+ packages:
+ - zlib1g-dev
+
+cache:
+ apt: true
+ directories:
+ - ~/.cabal
+ - ~/.ghc
+ - ~/.ghc-mod
+ - ~/.stack
+
install:
- export HOME=/tmp
- cabal update
@@ -13,6 +28,9 @@ install:
- if [ -n "$(ghc --version | awk '{ print $8 }' | sed -n '/^7.4/p')" ]; then cabal install Cabal --constraint "Cabal == 1.16.*"; fi
+before_script:
+ - rm -f ~/.ghc-mod cabal-helper-*-Cabal-*
+
script:
- touch ChangeLog # Create ChangeLog if we're not on the release branch
- cabal check
diff --git a/cabal-helper.cabal b/cabal-helper.cabal
index 183afba..b0df657 100644
--- a/cabal-helper.cabal
+++ b/cabal-helper.cabal
@@ -86,10 +86,21 @@ Test-Suite spec
Default-Language: Haskell2010
Type: exitcode-stdio-1.0
Main-Is: Spec.hs
- Hs-Source-Dirs: tests
+ Hs-Source-Dirs: tests, .
GHC-Options: -Wall
Build-Depends: base >= 4.5 && < 5
, cabal-helper
, extra
, unix
+ , Cabal >= 1.14 && < 1.23
+ , data-default
+ , directory
+ , filepath
+ , transformers
+ , mtl
, process
+ , ghc-prim
+ , bytestring
+ , utf8-string
+ , template-haskell
+ , temporary \ No newline at end of file
diff --git a/tests/Spec.hs b/tests/Spec.hs
index 296702e..a334f36 100644
--- a/tests/Spec.hs
+++ b/tests/Spec.hs
@@ -2,10 +2,84 @@ import Distribution.Helper
import System.Environment.Extra (lookupEnv)
import System.Posix.Env (setEnv)
import System.Process
+import System.Exit
import Data.Maybe
+import Data.Either
+import Data.Version
import Data.Functor
+import Control.Exception
+import Control.Arrow
+
+import CabalHelper.Common
+import CabalHelper.Compile
+import CabalHelper.Types
main :: IO ()
main = do
flip (setEnv "HOME") True =<< fromMaybe "/tmp" <$> lookupEnv "TMPDIR"
writeAutogenFiles readProcess "." "./dist"
+
+ _ <- system "cabal update"
+
+ let vers :: [(Version, [Version])]
+ vers = map (parseVer *** map parseVer) [
+ ("7.4", [ "1.14.0"
+ ]),
+
+ ("7.6", [ "1.16.0"
+ , "1.16.0.1"
+ , "1.16.0.2"
+ , "1.16.0.3"
+ ]),
+
+ ("7.8", [
+-- "1.18.0"
+-- , "1.18.1"
+ "1.18.1.1"
+-- , "1.18.1.2"
+ , "1.18.1.3"
+ , "1.18.1.4"
+ , "1.18.1.5"
+ , "1.18.1.6"
+
+ , "1.20.0.0"
+ , "1.20.0.1"
+ , "1.20.0.2"
+ , "1.20.0.3"
+ , "1.22.0.0"
+ , "1.22.1.0"
+ , "1.22.1.1"
+ ]),
+
+ ("7.10", [
+ "1.22.2.0"
+ , "1.22.3.0"
+ , "1.22.4.0"
+ ])
+ ]
+
+ ghcVer <- ghcVersion defaultOptions
+
+ let cabalVers = concat $ map snd $ dropWhile ((<ghcVer) . fst) vers
+
+ rvs <- mapM compilePrivatePkgDb cabalVers
+
+ if any isLeft' rvs
+ then exitFailure
+ else exitSuccess
+ where
+ isLeft' (Left _) = True
+ isLeft' (Right _) = False
+
+compilePrivatePkgDb :: Version -> IO (Either ExitCode FilePath)
+compilePrivatePkgDb cabalVer = do
+ db <- installCabal defaultOptions cabalVer `catch`
+ \(SomeException _) -> errorInstallCabal cabalVer "dist"
+ compileWithPkg "." (Just db) cabalVer
+
+compileWithPkg :: FilePath -> Maybe FilePath -> Version -> IO (Either ExitCode FilePath)
+compileWithPkg chdir mdb ver =
+ compile "dist" defaultOptions $ Compile chdir Nothing mdb ver [cabalPkgId ver]
+
+cabalPkgId :: Version -> String
+cabalPkgId v = "Cabal-" ++ showVersion v