From 77afb51613df5777582627e8c505fde57b0be188 Mon Sep 17 00:00:00 2001 From: Daniel Gröber Date: Mon, 25 Sep 2017 11:10:25 +0200 Subject: 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. --- tests/CompileTest.hs | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'tests') 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" -- cgit v1.2.3