aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2017-09-25 11:10:25 +0200
committerDaniel Gröber <dxld@darkboxed.org>2017-09-25 13:11:28 +0200
commit77afb51613df5777582627e8c505fde57b0be188 (patch)
tree4fa0da681316b42286ef888ed6ab1a781867933c /tests
parentb42f9095993f5862d4450a84f6cf535b7a252d48 (diff)
Add support for running Cabal's Setup.hs directly
cabal-install 1.24 broke installing older Cabal versions which use build-type:custom. See https://github.com/haskell/cabal/pull/4787. This still breaks with HEAD on GHC<8. See https://github.com/haskell/cabal/pull/4786.
Diffstat (limited to 'tests')
-rw-r--r--tests/CompileTest.hs30
1 files changed, 8 insertions, 22 deletions
diff --git a/tests/CompileTest.hs b/tests/CompileTest.hs
index b408788..6385f9e 100644
--- a/tests/CompileTest.hs
+++ b/tests/CompileTest.hs
@@ -10,7 +10,6 @@ import Data.Function
import qualified Distribution.Compat.ReadP as Dist
import Distribution.Version hiding (Version, showVersion)
import Distribution.Text
-import Control.Exception as E
import Control.Arrow
import Control.Monad
import Prelude
@@ -119,31 +118,18 @@ main = do
isLeft' (Left _) = True
isLeft' (Right _) = False
-data HEAD = HEAD deriving (Eq, Show)
-
compilePrivatePkgDb :: Either HEAD Version -> IO (Either ExitCode FilePath)
-compilePrivatePkgDb (Left HEAD) = do
- res <- (Right <$> installCabalHEAD defaultOptions { verbose = True })
- `E.catch` \(SomeException ex) -> return $ Left $
- "ERROR: Installing cabal HEAD failed: " ++ show ex
- case res of
- Left err -> do
- hPutStrLn stderr err
- return $ Left $ ExitFailure 1
- Right (db, commit) ->
- compileWithPkg (Just db) (Left commit)
-compilePrivatePkgDb (Right cabalVer) = do
- db <- installCabal defaultOptions { verbose = True } cabalVer `E.catch`
- \(SomeException _) -> do
- errorInstallCabal cabalVer "/does-not-exist"
- compileWithPkg (Just db) (Right cabalVer)
-
-compileWithPkg :: Maybe FilePath
+compilePrivatePkgDb eCabalVer = do
+ (db, e_commit_ver)
+ <- installCabal defaultOptions { verbose = True } eCabalVer
+ compileWithPkg (Just db) e_commit_ver
+
+compileWithPkg :: Maybe PackageDbDir
-> Either String Version
-> IO (Either ExitCode FilePath)
-compileWithPkg mdb ver =
+compileWithPkg mdb eCabalVer =
compile "/does-not-exist" defaultOptions { verbose = True } $
- Compile Nothing mdb ver [cabalPkgId ver]
+ Compile Nothing mdb eCabalVer [cabalPkgId eCabalVer]
cabalPkgId :: Either String Version -> String
cabalPkgId (Left _commitid) = "Cabal"